Meaningful comparison of CTF and DWARF
Meaningful comparison of CTF and DWARF
Posted Aug 7, 2019 0:03 UTC (Wed) by roc (subscriber, #30627)In reply to: Meaningful comparison of CTF and DWARF by nix
Parent article: The Compact C Type Format in the GNU toolchain
I think it would not be very difficult to prototype a DWARF post-processing tool to do this. (If it was very difficult, that would be interesting!)
I really think this ought to be done for size comparisons to be meaningful. If it were possible to make some simple changes to DWARF to reduce its space usage, and configure DWARF producers emit a subset of DWARF that covers the functionality of CTF with not much more size, I think there would be a compelling argument to just do that instead of CTF.
> CTF has been designed with compression in mind from the start, and a number of its design decisions are aimed to increase compressibility: e.g. the almost complete eschewing of self-identifiers
Can you identify the specific DWARF design decisions that make it compress poorly?
> The deduplicator I had before was very slow, but I think I now have an algorithm that is O(n) in the number of nodes, i.e. not too bad.
Does it handle recursive data structures? I actually implemented this for a C static analysis tool many many years ago, and it was pretty hard to find all possible duplicates efficiently. To find all possible duplicates, you pretty much have to start by optimistically assuming all types with the same name are equivalent and then split those equivalence classes when you find they aren't, cascading the splits backwards along your type membership graph.
You can of course give up on finding all possible duplicates, but that would raise the question of how well your deduplicator works on C++ and complex applications.
Of course, a deduplicator for DWARF would face the same issues. I wonder what dwz does...
> We will soon be able to use multiple threads in GNU ld too, which should help as well (the algorithm is parallelizable).
Good. Though, when measuring overhead, it would be more meaningful in the context of a linker that's actually fast, e.g. LLD rather than GNU ld.
> We could perhaps have CTF augment DWARF in some future spec revision, so DWARF could optionally drop some of its type representations when CTF is present and use CTF's instead
That sounds pretty complicated unfortunately.