Description
As reported in https://reviews.llvm.org/D102707#3267278, after 8d25762 building the FreeBSD math/openturn
port with clang (assertions enabled) causes huge memory usage. For end-users, this regressed between clang 12 and 13, but bisection shows 8d25762 to be the cause, and the problem was still present when I built a recent main commit (cd8122b).
Running perf
on the affected clang command shows that it is spending lots of runtime in unsigned StringMapImpl::LookupBucketFor(StringRef Name)
and void StringMapImpl::RemoveKey(StringMapEntryBase *V)
:
Samples: 154K of event 'cycles', Event count (approx.): 175175930341
Overhead Command Shared Object Symbol
22.50% clang++ clang-14 [.] llvm::StringMapImpl::LookupBucketFor
17.64% clang++ libc-2.31.so [.] __memmove_avx_unaligned_erms
15.72% clang++ clang-14 [.] llvm::StringMapImpl::RemoveKey
3.94% clang++ [kernel.kallsyms] [k] prepare_exit_to_usermode
3.29% clang++ [kernel.kallsyms] [k] clear_page_erms
2.63% clang++ libc-2.31.so [.] __memchr_avx2
2.07% clang++ [kernel.kallsyms] [k] native_irq_return_iret
1.69% clang++ [kernel.kallsyms] [k] rmqueue
1.64% clang++ [kernel.kallsyms] [k] sync_regs
1.56% clang++ [kernel.kallsyms] [k] error_entry
1.55% clang++ [kernel.kallsyms] [k] swapgs_restore_regs_and_return_to_usermode
1.20% clang++ libc-2.31.so [.] __memcmp_avx2_movbe
0.76% clang++ [kernel.kallsyms] [k] zap_pte_range.isra.0
0.74% clang++ [kernel.kallsyms] [k] free_pcppages_bulk
Reproduction test case:
Dlib-min.cpp.txt
Reproduce with (-relaxed-aliasing
is vital here):
clang -cc1 -triple x86_64-- -S -relaxed-aliasing -O2 Dlib-min.cpp
NOTE: Be sure to run something like ulimit -v $((10*1024*1024))
before the reproduction command, or watch memory usage when it is running, so you prevent OOM-killing your system... :)