mpeterv / luacheck

A tool for linting and static analysis of Lua code.
MIT License
1.92k stars 322 forks source link

Memory usage increase #166

Closed Zash closed 1 year ago

Zash commented 6 years ago

We have observed that running luacheck over all Lua files in Prosody (current-ish trunk) hits a peak RSS of around 100M RSS.

Using bisect to narrow it down, these commits stood out as major jumps in memory usage (20-25M increase wrt the previous):

mpeterv commented 6 years ago

That's a lot! It seems that the warning filtering stage tries to avoid mutating tables too hard, by creating a lot of fresh objects, and these commits increased amount of various filtering done. This situation can definitely be improved, I'll try to look into it soon.

mpeterv commented 6 years ago

After some improvements on master branch peak RSS went down from ~92MB to ~68MB (running luacheck . with Lua 5.1 and --cache enabled and fully hit). I'll keep working on this and make a patch release in a week or so.

mpeterv commented 6 years ago

0.22.1 released, peak RSS down to ~55MB. I'll keep working on this, some optimizations require slightly changing behavior in some corner cases so they'll go into 0.23.0.

Zash commented 6 years ago

Thanks! Will try.

FWIW, the backstory here was that we were playing with CI test runners on a virtual machine with 1GB RAM, with about half of that in use by other things. We had 4 different test environments, which used about 20M each when idle. So you can imagine how much was left when a test run was triggered and it ran 4 instances of luacheck at the same time.

So, this helps a lot. We'll also be looking into smarter scheduling and isolating things from other more important services.