This decreases the size of NameAttrEntry from 20 bytes to 16 bytes on 64-bit platforms.
Details
Diff Detail
- Repository
- rLLD LLVM Linker
- Build Status
Buildable 25398 Build 25397: arc lint + arc unit
Event Timeline
I believe the memory savings of this patch is not free; it now has to scan the same string more than once to find a null terminator. Even though we want to reduce memory usage of lld for Google, in general, saving memory is not always the goal that we want to achieve. We need to get a right balance. To do that, can you tell me how much memory you can save with this patch, and how much is the performance penalty of this patch?
I think the memory saving may be negligible but interestingly my testing says it makes it faster when linking clang. My understanding is that the smaller size of NameAttrs improves caching a bit.
cmake -H. -BStaticDebug -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXE_LINKER_FLAGS=-Wl,--gdb-index ...
rm bin/clang-8; ninja -C StaticDebug -v -n clang to extract the clang command line, append '-###' to get the ld.lld command line. bin/clang-8 is of 601,059,920 bytes
perf stat -r 20 /tmp/link-clang => run several times without and with the patch. Without the patch it is usually 4.8 seconds (4.884600870 seconds time elapsed) while with the patch, it is usually 4.7 seconds (4.743274463 seconds time elapsed).
Even though we want to reduce memory usage of lld for Google
Thanks for the reminder but please believe I weigh much the general-purpose usability a lot.
I tried this patch myself, but it is hard to say if this patch makes a difference. Probably the performance difference is negligible.
Do you know how many NameAttrEntry's are created for your test case? (I.e. how many bytes are saved?)
- For clang, the total number of NameAttrs is 32496
- For an internal larger executable, it is 193776
I think both memory/space changes are negligible (I made a mistake when giving the statistics "4.8 seconds (4.884600870 seconds time elapsed) while with the patch, it is usually 4.7": used a wrong ld.lld).
Thank you for measuring it. Given these numbers, I wouldn't land this change as StringRef is more straightforward.