This is an archive of the discontinued LLVM Phabricator instance.

[Tooling] Optimize memory usage in InMemoryToolResults.
ClosedPublic

Authored by hokein on Apr 10 2018, 2:55 AM.

Details

Summary

Avoid storing duplicated "std::string"s.

Previsouly, clangd's global-symbol-builder consumes 20+GB memory when running across LLVM repository.
With this patch, the used memory is reduced to ~10GB (running on 48 threads, most of memory are AST-related).

Diff Detail

Repository
rC Clang

Event Timeline

hokein created this revision.Apr 10 2018, 2:55 AM
hokein retitled this revision from [Tooling] Optmized memory usage in InMemoryToolResults. to [Tooling] Optimize memory usage in InMemoryToolResults..Apr 10 2018, 4:09 AM
hokein edited the summary of this revision. (Show Details)
hokein added reviewers: sammccall, ilya-biryukov.

This definitely helps with memory consumption of clangd's global-symbol-indexer, I can now run it over LLVM on MacBook without it swapping out of RAM. The physical memory usage goes up to 3GB at some point, before it was > 20GB.

Strictly speaking, interning the strings is probably more work for some workloads, so I'm not sure it's a better in all cases.
On average this LG, though, so LGTM from my side.

ilya-biryukov accepted this revision.Apr 10 2018, 6:26 AM
This revision is now accepted and ready to land.Apr 10 2018, 6:26 AM
sammccall added inline comments.Apr 10 2018, 6:43 AM
include/clang/Tooling/Execution.h
58

please add a high-level comment explaining what this is caching and when we expect it to work well.

hokein updated this revision to Diff 141842.Apr 10 2018, 7:22 AM
hokein edited the summary of this revision. (Show Details)

Add a comment.

This revision was automatically updated to reflect the committed changes.