rui314 / mold

Mold: A Modern Linker 🦠
MIT License
13.67k stars 448 forks source link

Higher zstd compression levels for debug info #1290

Open ishitatsuyuki opened 1 week ago

ishitatsuyuki commented 1 week ago

https://github.com/facebook/zstd/issues/2832#issuecomment-2186664715 mentions that:

Starting v1.5.6, zstd at high compression levels features a better compression ratio on 32-bit structures. The .debug_str_offsets section is a pretty good example of this.

Note that compression at level 19 is very slow, and the mentioned optimization only applies to sections where there are lots of 32-bit integers. It will likely not yield benefits for ULEB128-dominated sections. We should test ratio for each section and build a list of sections where zstd-19 is beneficial.

I propose that we introduce new options for --compress-debug-sections:

rui314 commented 1 week ago

It feels a bit odd to me that we need to manually optimize compression levels. Ideally, zstd should (and I believe could) detect that the data being compressed contains lots of 32-bit integers and compress accordingly. Did you know why they can't do that?