[all-commits] [llvm/llvm-project] 4af90c: [BOLT] Reduce NameResolver memory usage during fil...
Rafael Auler via All-commits
all-commits at lists.llvm.org
Tue Jul 28 14:10:01 PDT 2026
Branch: refs/heads/users/rafaelauler/nameresolver-fix
Home: https://github.com/llvm/llvm-project
Commit: 4af90c760b90eb838722b5fee3b70d98b56126bd
https://github.com/llvm/llvm-project/commit/4af90c760b90eb838722b5fee3b70d98b56126bd
Author: Rafael Auler <rafaelauler at fb.com>
Date: 2026-07-28 (Tue, 28 Jul 2026)
Changed paths:
M bolt/include/bolt/Utils/NameResolver.h
M bolt/lib/Rewrite/RewriteInstance.cpp
Log Message:
-----------
[BOLT] Reduce NameResolver memory usage during file object discovery
Summary:
NameResolver used a StringMap<uint64_t> to count duplicate names. StringMap
owns its keys, so every uniquify()/getUniquifiedNameCount() query allocated a
full copy of each (potentially large, mangled) symbol name. During
discoverFileObjects on a large binary, this string-key duplication accounted
for ~2 GB (1 to 2% of RSS) of allocations in
StringMap::try_emplace_with_hash -> StringMapEntry::create -> allocateWithKey.
Replace the StringMap with a DenseMap<pair<uint64_t,uint64_t>, uint64_t> keyed
by a 128-bit xxh3 hash of the name. No string is ever stored: each distinct
name costs a fixed-size entry regardless of length. A 128-bit hash makes
collisions effectively impossible, so the per-name counts (and therefore the
generated 'Name/ID' unique names) are identical to the string-keyed map and
remain reproducible to match profile (fdata) names.
Also clear the map at the end of discoverFileObjects, since the resolver is not
needed afterwards; all NR.uniquify()/getUniquifiedNameCount() calls occur
within that function's dynamic extent (including processRelocations and
registerFragments).
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list