Issue |
148042
|
Summary |
[BOLT] Aligning function offsets of two binaries for benchmarking
|
Labels |
BOLT
|
Assignees |
|
Reporter |
iluuu1994
|
Hi! I originally asked this question on Discord but will repeat it here for visibility.
Binary layout can greatly influence the performance characteristics of programs. Sometimes, seemingly minuscule code changes can lead large performance regressions due to small layout changes. [^1] I'm working on an interpreter where we frequently experience this issue, for example by laying out opcode handlers in a way that leads to repeated L1i cache evictions when two or more opcodes are executed in a loop. This makes it incredibly hard to understand whether small, incremental changes are profitable, disregarding uncontrollable layout changes. There are some compiler flags to minimize this problem (`-falign-functions`, `-falign-loops`, etc.) but I found them to be ineffective.
I was thinking about building a tool that takes two binary files as input, and inserts NOPs between functions to reconcile the layout of the two binaries as much as possible. Bolt has a different purpose but requires much of the same infrastructure (reading of binary files, function reordering or inserting padding through `--pad-funcs[-before]`, fixing up of jump targets, re-emission of binary files, etc.).
I have a few questions:
* Is there an existing solution, or something simpler I can try? lld's `--randomize-section-padding` was already pointed out to me by @pwaller.
* Would this be a sensible addition to Bolt? If so, can you give me any pointers on how to best go about this task?
Thank you!
[^1]: https://www.youtube.com/watch?v=IX16gcX4vDQ
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs