Last active
January 8, 2023 00:25
-
-
Save MaskRay/219effe23a767b85059097f863ebc085 to your computer and use it in GitHub Desktop.
lld with different malloc implementations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build malloc implementations. | |
mkdir -p /tmp/p | |
pushd /tmp/p | |
if [[ ! -d jemalloc ]]; then | |
git clone https://github.com/jemalloc/jemalloc | |
(cd jemalloc | |
./autogen.sh | |
mkdir -p out/release && cd out/release | |
../../configure && make -j $(nproc)) | |
fi | |
if [[ ! -d mimalloc ]]; then | |
git clone https://github.com/microsoft/mimalloc | |
(cd mimalloc; cmake -GNinja -S. -Bout/release -DCMAKE_BUILD_TYPE=Release; ninja -C out/release) | |
fi | |
if [[ ! -d rpmalloc ]]; then | |
git clone https://github.com/mjansson/rpmalloc | |
(cd rpmalloc; ./configure.py; ninja) | |
fi | |
if [[ ! -d snmalloc ]]; then | |
git clone https://github.com/microsoft/snmalloc | |
(cd snmalloc; cmake -GNinja -S. -Bout/release -DCMAKE_BUILD_TYPE=Release -DSNMALLOC_STATIC_LIBRARY_PREFIX=; ninja -C out/release) | |
fi | |
popd | |
# In a directory extracted from an lld reproduce tarball | |
# In llvm-project, run: ninja lld; rm bin/lld; ninja -v lld; copy the command line, append -Wl,--reproduce=/tmp/lld.tar | |
# cd /tmp; tar xf lld.tar; cd lld | |
pushd /tmp/lld | |
sed -i '/--chroot/d' response.txt | |
ld.lld @response.txt -o lld.glibc | |
ld.lld /tmp/p/mimalloc/out/release/libmimalloc.a @response.txt -o lld.mi | |
ld.lld /tmp/p/jemalloc/out/release/lib/libjemalloc.a @response.txt -o lld.je | |
ld.lld /tmp/p/rpmalloc/build/ninja/linux/release/x86-64/rpmalloc-*/librpmalloc*.a @response.txt -o lld.rp | |
ld.lld /tmp/p/snmalloc/out/release/libsnmallocshim-static.a @response.txt /usr/lib/x86_64-linux-gnu/libatomic.so.1 -o lld.sn | |
popd | |
for m in glibc mi je rp sn; do | |
/tmp/lld/lld.$m -flavor gnu @response.txt --time-trace=$i.$m.time-trace | |
for i in 1 2 4 8 16 32 64; do | |
numactl -C 0-$[i-1] /tmp/lld/lld.$m -flavor gnu @response.txt --threads=$i --time-trace=$i.$m.time-trace | |
jq -r '.traceEvents[] | select(.name|contains("Total")) | "\(.dur/1000000) \(.name)"' < $i.$m.time-trace > $i.$m | |
done | |
done |
Just a quick question. When you built snmalloc
did you set -DSNMALLOC_STATIC_LIBRARY_PREFIX=
? It defaults to creating symbols like sn_malloc
. The performance numbers look like is more similar to glibc than I would have expected.
Just a quick question. When you built
snmalloc
did you set-DSNMALLOC_STATIC_LIBRARY_PREFIX=
? It defaults to creating symbols likesn_malloc
. The performance numbers look like is more similar to glibc than I would have expected.
Sorry, I didn't. Used -DSNMALLOC_STATIC_LIBRARY_PREFIX=
now and reran the tests. (Still updating chromium ones)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For glibc malloc and snmalloc,
--threads=8
has the peak performance.--threads=16
becomes slow and--threads=64
is very slow.Scan relocations
(since 2022-09-12 https://reviews.llvm.org/D133003) andSplit sections
appear to be affected the most.Scan relocations
calls (per-thread)sec->relocations.reserve(rels.size());
inRelocationScanner::scan
and a lot ofsec->relocations.push_back
inRelocationScanner::processAux
.clang
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=on
chromium