-
-
Notifications
You must be signed in to change notification settings - Fork 39
Consuming 30G when used via noevim coc #33
Comments
There's a certain chance that this got fixed in #37, but I really want to look at this before getting a 0.2.0 out. |
I was not able to reproduce issue for past 2 days (effective run-time ~7 minutes). I tried keeping |
THanks a lot for reporting back! In case you stumble upon this again, please let us know! I'll leave this open for another two weeks to see if you, me or somebody else can reproduce this. |
I've had this same problem, but it seems like the incremental expression-updates commit has fixed it. Thanks! |
In case somebody still stumbles upon the issue on a recent One (hacky, I guess?) way to do this is to kill |
Damn it, I just experienced this again :/ Unfortunately my kernel was faster with OOMing rnix-lsp than I could |
Any chance to instrument some memory debugging into @Ma27 , any chance that it happened for you on Nix 2.3.x? |
Good idea :)
Nope, Nix 2.4 |
@Ma27 I have finally managed to catch it before freezing my PC. Here's a screenshot of the coredump as my terminal somehow got messed up and I couldn't copy the text from it. The circumstances are: I was editing a I could send the file if it helps. |
Can you still access the core file? That one would be quite helpful! :) |
I'm not sure whether you mean the coredump file (I don't know where it's located), but this is the nix file that caused it to leak. https://gist.github.com/fufexan/61244c3949ec631d6f1483bbbc682b61 |
@fufexan are you on NixOS? In that case |
I have found it. https://gofile.io/d/WJElaV |
@fufexan one last question: do you have a custom overlay for your |
@Ma27 I'm using the flake in this repo along with |
The main motiviation is to get `crossbeam-channel` at at least 0.5.1 as this appears to fix a memory like[1] which is probably the root-cause of our own memory issues[2]. This also included some changes to the LSP type-system as a few more changes in the LSP protocol are now incorporated, such as a clarification that numbers are usually unsigned 32bit rather than 64bit[3]. [1] https://github.com/crossbeam-rs/crossbeam/blob/crossbeam-channel-0.5.1/crossbeam-channel/CHANGELOG.md#version-051 [2] nix-community#33 [3] gluon-lang/lsp-types@f654090
@ony @fufexan there's now #49 which contains a few dependency updates (including a fix for crossbeam which resolves a severe memory leak in their code). Since I still cannot reproduce the bug reliably (although I get bitten by it occasionally), this is only a theory, unfortunately. In order to find out whether this is an actual fix, it'd be really awesome if you could also test this PR :) |
@Ma27 tried building it, but it failed. Here's the build log https://gist.github.com/fufexan/f82d75bae6cfcfb95f984bb92b07ebc4. |
You'll need at least cargo+rustc 1.52 (should be on available nixos 21.05). |
I'm on unstable from a week ago, I think it should work even with that. |
Your log says |
Manually overriding |
@Ma27 it seems to leak again, managed to freeze my computer while I was writing |
Oh damn it! Anyway, thanks a lot for testing! The thing is, I hit that issue twice in the last two months, so reproducing is rather hard on my side (I tried to re-do my steps, but without any success, so I'd say that it's not related to certain files or patterns). You use kakoune, right? Do you have a Nix expression for your setup that I can build locally? Just a wild guess, but perhaps it's easier to trigger with your setup, but idk. Anyway, I'm afraid, I'll have to leave it for a few days and get back to it with a fresh mind, perhaps I come up with something else then. |
I use Kakoune, Neovim and Emacs 😄 |
…ions First of all, big thanks to @fufexan who helped me to reliably reproduce this. Originally discovered in `rnix-lsp`[1], but I confirmed that `nixpkgs-fmt` is also affected. Basically, when having an expression such as let inherit the parser would wait for a `TOKEN_SEMICOLON` indefinitely. The actual problem however is that `self.parse_val()` always detects the SAME syntax-error, i.e. "unexpected EOF". This will be written indefinetely into `self.errors`. However, `errors` is of type `Vec<ParseError>` and a vector in Rust grows in an amortized fashion[2] which means that if an entry is pushed and the vector exceeds the currently allocated size, it will be ~doubled (though the exact growth-factor isn't constant). This essentially means that the buffer is growing exponentially pretty fast and - according to KDE heaptrack - my system allocated ~9.5GB after 20s while running some tests. I added an exit-condition to the loop traversing through `inherit`-subexpressions to avoid that. Checking for an "unexpected EOF" is actually sufficient here: * There's either a `;` later in the expression causing the loop to terminate and causing an actual "unexpected token" error then. * Otherwise, `parse_val` will go through the tokens until a matching semicolon is found (which is not the case) and then reach the end of the file. In that case, `unexpected EOF` is returned by `parse_val`. [1] nix-community/rnix-lsp#33 [2] https://www.cs.cornell.edu/courses/cs3110/2011sp/Lectures/lec20-amortized/amortized.htm
-> https://github.com/nix-community/rnix-parser/pull/31/files Big thanks to @fufexan for helping me to reproduce this! Feel free to remind me on the next in-person NixCon (or something similar) that I owe you a beverage of your choice :) |
This release incorporates a fix for the severe memleaks we're experiencing. Fixes nix-community#33
* Write a dedication to jD91mZM2 * Say thank you to fufexan who helped us to reproduce and investigate the memory leak from nix-community#33.
Hello,
I had two incidents already when with
rnix-lsp
consumed almost all RAM.It is interesting that in both cases I had in parallel other terminal running
nix repl
while editinghome.nix
(home-manager) with error syntax error.The text was updated successfully, but these errors were encountered: