Stream: t-compiler/rust-analyzer

Topic: Remaining memory leak?


Jonas Schievink [he/him] (Apr 01 2021 at 20:02, on Zulip):

r-a is currently sitting at >4GB RAM usage (built from git), it seems like we might have another memory usage issue/leak somewhere?

leak sanitizer doesn't report anything

Jonas Schievink [he/him] (Apr 01 2021 at 20:39, on Zulip):

7.3 GB, and I haven't done much, this is growing very fast

Jonas Schievink [he/him] (Apr 01 2021 at 20:40, on Zulip):

looking at the commit history I can't see anything suspicious since the token text leak was fixed

Jonas Schievink [he/him] (Apr 01 2021 at 21:00, on Zulip):

nevermind, for some reason my VS Code config was broken and still used the old version, not my local build

Jonas Schievink [he/him] (Apr 01 2021 at 22:01, on Zulip):

no, that wasn't it, it's still leaking like crazy, but only when actively editing code maybe?

Jonas Schievink [he/him] (Apr 01 2021 at 22:04, on Zulip):

uuh, the "Show RA Version" command changes when I recompile, even without restarting the server, that's confusing

Jonas Schievink [he/him] (Apr 01 2021 at 22:09, on Zulip):

hmm, I thought it was the global interning PR, but it seems like it doesn't always reproduce immediately

Jonas Schievink [he/him] (Apr 01 2021 at 22:09, on Zulip):

when it does happen, parsing diagnostics take quite a while to show up

Jade (Apr 02 2021 at 09:00, on Zulip):

I'm also seeing this with RA open against a bunch of rustc code, is there anything I can do to help debug?

Jade (Apr 02 2021 at 09:31, on Zulip):

:O I can't seem to find the RA version in the log output. this seems very surprising as an omission, unless I accidentally turned off the requisite item or something

Laurențiu (Apr 02 2021 at 09:32, on Zulip):

The binary is here https://rust-analyzer.github.io/manual.html#vs-code, run it with --version

Jade (Apr 02 2021 at 09:46, on Zulip):

"nightly" :O well, hm, hahaha

Laurențiu (Apr 02 2021 at 09:50, on Zulip):

That might be an older version

Laurențiu (Apr 02 2021 at 09:51, on Zulip):

What's the file date?

Jade (Apr 02 2021 at 09:51, on Zulip):

Its birth time was March 31

Jade (Apr 02 2021 at 09:51, on Zulip):

not sure how I can ask it with Coc

Laurențiu (Apr 02 2021 at 09:52, on Zulip):

That's strange. There was a bug, but it was fixed in https://github.com/rust-analyzer/rust-analyzer/pull/8194

Laurențiu (Apr 02 2021 at 09:52, on Zulip):

And the latest nightly says rust-analyzer nightly-11-gea8feca31

Laurențiu (Apr 02 2021 at 09:53, on Zulip):

If your server binary is older than that, it probably doesn't have https://github.com/rust-analyzer/rust-analyzer/pull/8191

Jade (Apr 02 2021 at 09:54, on Zulip):

hm. weird. filed https://github.com/rust-analyzer/rust-analyzer/pull/8291 because it would be good to have it in the logs

Jade (Apr 02 2021 at 09:55, on Zulip):

I'll try to figure out what coc-rust-analyzer is doing here... actually, maybe it's on a release version

Jade (Apr 02 2021 at 09:59, on Zulip):

alright, can still repro the nasty leak on rust-analyzer nightly-11-gea8feca31

Jade (Apr 02 2021 at 10:11, on Zulip):

hmmm i may have a consistent repro that may be transferable to someone else more familiar with RA innards (and for whom it is not 3am haha).

Try opening rust/compiler/rustc_span/src/symbol.rs (i have rev 2a32abbcdea97c6bf1d0445bc657f16c50ca103b on my computer)

Jade (Apr 02 2021 at 10:12, on Zulip):

that seems to be the file that was causing it in my nvim session file. also repros in code with just that file open

Jade (Apr 02 2021 at 10:12, on Zulip):

so something in that triggers the mem leak, I hope, not just on my computer, but also on others'

Jade (Apr 02 2021 at 10:35, on Zulip):

presently bisecting it

Jade (Apr 02 2021 at 10:58, on Zulip):

argh, still was in the rev from the 29th. going to go and try something real old, bleh

Jade (Apr 02 2021 at 11:37, on Zulip):

:scream: it seems like it is maybe 90% reproducible rather than 100% reproducible. wonder if i had some bad revs marked good :///

Jade (Apr 02 2021 at 12:11, on Zulip):

ok I'm going to bed because I'm extremely tired and also Nvidia crashed my computer again. it's something in the vicinity of b4c20e358, according to my bisecting

Jonas Schievink [he/him] (Apr 02 2021 at 19:30, on Zulip):

This can be reproduced by having hir_expand/src/name.rs open in an editor. r-a takes a long time to compute diagnostics for that due to a known bug, but it also seems to be leaking (a lot of) memory somewhere.

Jonas Schievink [he/him] (Apr 02 2021 at 19:30, on Zulip):

the known bug is tracked in https://github.com/rust-analyzer/rust-analyzer/issues/8268

Jonas Schievink [he/him] (Apr 02 2021 at 19:48, on Zulip):

with --features jemalloc, memory doesn't seem to ever climb beyond 3 GB

Jonas Schievink [he/him] (Apr 02 2021 at 19:48, on Zulip):

cursed. why are computers.

Jonas Schievink [he/him] (Apr 02 2021 at 19:48, on Zulip):

after running the memory usage command it outputs "644mb Remaining", so I think there's still something odd going on maybe? but it doesn't seem to increase indefinitely anymore

Jonas Schievink [he/him] (Apr 02 2021 at 19:50, on Zulip):

hmm, and that command really does recycle almost all the memory

Jonas Schievink [he/him] (Apr 02 2021 at 19:50, on Zulip):

that didn't really happen without jemalloc

Jade (Apr 02 2021 at 21:35, on Zulip):

how does changing the allocator make it not leak indefinitely anymore? :scream: cursed sand machine

Jade (Apr 03 2021 at 04:44, on Zulip):

hm, so I checked again, and the version prior to https://github.com/rust-analyzer/rust-analyzer/commit/b4c20e3589372ba1536cec1bfe7de6acd2f40a4d does not leak rapidly whereas it seems like versions starting with that commit do leak on my repro.

Jade (Apr 03 2021 at 04:44, on Zulip):

ah, hmm. image.png

Jade (Apr 03 2021 at 04:45, on Zulip):

so uh this little guy leaked 42mb + several several more instances of the same :D little leak that could

Jade (Apr 03 2021 at 04:59, on Zulip):

(since been removed, different source I imagine now? unsure)

Laurențiu (Apr 03 2021 at 07:20, on Zulip):

That was https://github.com/rust-analyzer/rust-analyzer/pull/8191

Laurențiu (Apr 03 2021 at 07:22, on Zulip):

Jade said:

how does changing the allocator make it not leak indefinitely anymore? :scream: cursed sand machine

Sometimes it's not a leak, it's fragmentation or an allocation pattern that the allocator barfs on.

Jonas Schievink [he/him] (Apr 03 2021 at 17:20, on Zulip):

I've been using a jemalloc-enable rust-analyzer for development yesterday and RAM usage hasn't climbed much beyond 3 GB in the worst case. Currently sitting at 2.6 GB. I guess this really is just hitting a bad allocation pattern for the glibc allocator then.

In that case, implementing lazy diagnostic fixes should resolve this.

Last update: Jul 27 2021 at 21:00UTC