namefreezers wrote: @mjansson, I'd value your opinion on the rpmalloc part of this patch (`llvm/lib/Support/rpmalloc/rpmalloc.c`). LLVM still vendors 1.4.5. The patch fills in the empty `rpmalloc_thread_collect()` and adds an LLVM-only `rpmalloc_global_collect()`, close to the two trim modes you described in mjansson/rpmalloc#116. clangd calls them on each background-index worker once the index queue goes idle. After indexing LLVM, clangd's commit drops from 14.8 GiB to 5.2 GiB.
Each step reuses something rpmalloc already does at runtime. Only the owner thread touches its heap, and the global cache is only changed under its lock. The parts I'd most like a second opinion on: - `_rpmalloc_heap_cache_adopt_deferred(heap, 0)` on the owner thread outside the allocation slow path, while other threads may still push to `span_free_deferred`. - Master spans that still have mapped subspans stay in the caches (the rule `_rpmalloc_global_cache_insert_spans()` uses), and the heap reserve goes into the span cache instead of being unmapped, because a freed master can become the reserve. One case this patch doesn't cover: a span whose last block another thread frees, after its owner has freed some blocks itself, is completely free but stays on its partial list, so the collect doesn't see it (about 0.2 GiB here). I plan to handle that in a follow-up, similar to what mjansson/rpmalloc#439 does for 2.x. I saw that `rpmalloc_thread_collect()` on `develop` now does much the same for 2.x. Thanks! https://github.com/llvm/llvm-project/pull/242843 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
