This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Remove StringRefZ
ClosedPublic

Authored by MaskRay on Jan 19 2022, 12:45 AM.

Details

Summary

StringRefZ does not improve performance. Non-local symbols always have eagerly
computed lengths. Most local symbols's lengths will be updated in either:

  • shouldKeepInSymtab
  • SymbolTableBaseSection::addSymbol

Its benefit is offseted by strlen in every call site (sums to 5KiB code in a release
x86-64 build), so using StringRefZ may be slower.

In a -s link (uncommon) there is minor speedup, like ~0.3% for clang and chrome.

Diff Detail

Event Timeline

MaskRay created this revision.Jan 19 2022, 12:45 AM
MaskRay requested review of this revision.Jan 19 2022, 12:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 19 2022, 12:45 AM
alexander-shaposhnikov added inline comments.
lld/ELF/Symbols.h
251–253

it looks like in both cases this code tries to "unpack" a StringRef into nameData and nameSize
(here and inside setName) - maybe just store StringRef itself ?

MaskRay marked an inline comment as done.Jan 19 2022, 1:05 AM
MaskRay added inline comments.
lld/ELF/Symbols.h
251–253

The idea is to use 32-bit nameSize to save some space...

MaskRay edited the summary of this revision. (Show Details)Jan 19 2022, 1:06 AM
arichardson added inline comments.Jan 19 2022, 1:17 AM
lld/ELF/Symbols.h
251–253

It might be worth adding that as comment above the two fields since I had the same thought.

This revision is now accepted and ready to land.Jan 19 2022, 1:22 AM
MaskRay updated this revision to Diff 401480.Jan 19 2022, 7:04 PM
MaskRay marked an inline comment as done.

Add a comment

This revision was automatically updated to reflect the committed changes.