rust-lang / rust-lang/rust-analyzer

Huge memory usage with `serde` proc macros

Open
#16,188 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-mir A-perf C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Problem description

Rust analyzer keeps using more and more memory. It seems to be connected with serdes proc_macros and many fields in the struct.

After the file is opened, during the first minute, memory keeps slowly rising to about 3gb.
At around 2 min mark, it suddenly spikes to 4.3gb.
Around 3-4 mins, it spikes to 7gb.
Around 6-7 mins, it spikes to 12gb.

During all this time, CPU usage is 100% (not all cores, just one).

Started happening a month or 2 ago (I do weekly rust-analyzer updates).

Steps to reproduce

  • Fresh install of VSCode on Ubuntu 20.04,
  • clone this repo
  • open main.rs and do nothing, just watch CPU/RAM

rust-analyzer version: 0.3.1774-standalone

rustc version: rustc 1.74.1 (a28077b28 2023-12-04)

relevant settings: fresh vs-code install, no custom settings, no ENV variables set

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using the linked rust-analyzer-serde-huge-memory-usage repository by opening main.rs in VSCode on Ubuntu 20.04, with the reported rust-analyzer and rustc versions. Monitor memory and single-core CPU usage during the first several minutes; done requires addressing the reported growth and spikes, with resource usage no longer escalating under these steps.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.