-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate size of .rela.dyn
section on Linux
#76657
Comments
I'll have a peek at this. |
This section is to support pointer-sized relocations. Apparently a reloc on Linux costs like 24 bytes of metadata (vs ~2 bytes on Windows). I'm working on a change to remove a bunch of them in perf critical parts that we want to keep pointer-sized relocations in. I'll leave some that we should just change to 32bit relative relocs because there's no good reason to use pointer-size:
There's some that need to keep pointer-size relocs but cannot be switched to the new plan right away:
|
Couple of random notes:
|
That's not entirely accurate. COFF (object) relocation is 10 bytes. PE COFF (image) relocation is page-based, so that's 8 bytes for each page that has relocation and 2 bytes for each relocation within the page. The amortized cost of relocation basically depends on how close you have the pointers within the data structure. The closer they are the bigger chance that they fit within the page and have the 2-byte cost in the final executable.
For completeness, Mach-O also compresses the relocations in the final image file. The format is more complex though. |
This was fixed in the above mentioned pull requests. |
It seems like this section contributes significantly to the size of the output executable on Linux (20+% of the image size).
For reference, relocations on NativeAOT/Windows accounts for only about 2% of the image size.
We should investigate whether we're doing something wrong/what can we do about it.
The text was updated successfully, but these errors were encountered: