This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Use StringTableBuilder to optimize the string table
ClosedPublic

Authored by mstorsjo on Feb 28 2022, 1:25 PM.

Details

Summary

On a statically linked clang.exe, this shrinks the ~17 MB string
table by around 0.5 MB. This adds ~160 ms to the linking time
which originally was around 950 ms.

I've seen an extreme case where the string table would have been
shrunk from 149 MB to 107 MB though. (llvm-objcopy uses
StringTableBuilder, and thus a no-op copy with llvm-objcopy
currently optimizes the string table.)

Given the modest savings (and a noticable slowdown), do you
think is a worthwhile optimization to do, or should we just
keep things as-is?

For cases where -debug:symtab or -debug:dwarf isn't set, the
string table is only used for long section names, where this
shouldn't make any difference at all.

This requires D120676, because with this in place, strings for long
section names can be placed anywhere in the string table, and the
sprintf overflow becomes a real issue in large executables.

Diff Detail

Event Timeline

mstorsjo created this revision.Feb 28 2022, 1:25 PM
mstorsjo requested review of this revision.Feb 28 2022, 1:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2022, 1:25 PM
rnk accepted this revision.Feb 28 2022, 3:27 PM

The size improvements are entirely from string tail merging, right?

In any case, this looks good to me. Debug info and symbols are sufficiently large that it's worth taking the time to make it smaller where possible.

This revision is now accepted and ready to land.Feb 28 2022, 3:27 PM

FWIW, D113866 made the effect of this much smaller, by writing much less unnecessary symbols.

The size improvements are entirely from string tail merging, right?

Yes, tail merging or plain deduplication.

In any case, this looks good to me. Debug info and symbols are sufficiently large that it's worth taking the time to make it smaller where possible.

Ok, I’ll go ahead and push it soon then.