Posting lists were copied into the final inverted index rather than
being moved. Also we weren't shrinking the vectors. This patch should help with
both peak memory usage while building dex (preamble/background-index) and it's
idle memory usage (unclear if copy constructor of vector preserves the capacity
or not).
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Get rid of shrink_to_fit as PostingList representation doesn't really make a copy of the vector, but rather build a new representation.
clang-tools-extra/clangd/index/dex/Dex.cpp | ||
---|---|---|
112 | the move here does nothing, we're passing as ArrayRef did you want to clear the map values (vectors) as you went, too? (this gets a bit verbose, but you could pull out a function template since all 4 cases are so regular) |
clang-tools-extra/clangd/index/dex/Dex.cpp | ||
---|---|---|
112 |
yes that's the idea. would you prefer an explicit destructor call?
the problem is 1 of these is a densemap, other three is a stringmap, and onther is a vector. densemap and the stringmap doesn't really go together because there's no common method to get the key (densemap has first as a field, or getFirst() as a method. stringmap has first() or getKey() as methods :/). buildPostingList(StringMap<..>, TokenKind, Out); if you think that's still helpful (that way we can also get rid of the calls to clear since we can just move the maps into the function arguments). |
clang-tools-extra/clangd/index/dex/Dex.cpp | ||
---|---|---|
112 |
I mean e.second.clear() in the loop.
Sounds too complicated, nevermind! |
the move here does nothing, we're passing as ArrayRef
did you want to clear the map values (vectors) as you went, too?
(this gets a bit verbose, but you could pull out a function template since all 4 cases are so regular)