This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Devirtualize TargetInfo::getRelocAttrs
ClosedPublic

Authored by BertalanD on Jul 18 2022, 4:54 AM.

Details

Reviewers
int3
thakis
Group Reviewers
Restricted Project
Commits
rG1fb9466c6a4c: [lld-macho] Devirtualize TargetInfo::getRelocAttrs
Summary

This method is called on each relocation when parsing input files, so
the overhead of using virtual functions ends up being quite large. We
now have a single non-virtual method, which reads from the appropriate
array of relocation attributes set in the TargetInfo's constructor.

This change results in a modest 2.7% reduction in link time for
chromium_framework measured on my GCP instance:

x before
+ after
+---------------------------------------------------------------------+
|                          +                                          |
|     +   +   +            +             x      xx                    |
|+   +++ ++ + +++++ +     ++         x xxx    xxxxxx x xxx   x   x   x|
|     |_______A_______|                  |_______MA________|          |
+---------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x  20     11.992883     12.289202     12.107467     12.114866   0.079527048
+  20     11.662653     11.903168     11.785559     11.785649   0.073029551
Difference at 95.0% confidence
	-0.329216 +/- 0.0488658
	-2.71746% +/- 0.403354%
	(Student's t, pooled s = 0.0763475)

Diff Detail

Event Timeline

BertalanD created this revision.Jul 18 2022, 4:54 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 18 2022, 4:54 AM
BertalanD requested review of this revision.Jul 18 2022, 4:54 AM
BertalanD edited the summary of this revision. (Show Details)
int3 accepted this revision.Jul 18 2022, 6:19 AM
int3 added a subscriber: int3.

Nice! 2.7% is not modest :)

This revision is now accepted and ready to land.Jul 18 2022, 6:19 AM
thakis accepted this revision.EditedJul 18 2022, 6:47 AM
thakis added a subscriber: thakis.

Nice!

Slightly smaller win over here on my mbp:

% ministat ~/lld-arm-pre.txt ~/lld-arm-post.txt
x /Users/thakis/lld-arm-pre.txt
+ /Users/thakis/lld-arm-post.txt
+-------------------------------------------------------------------------------------+
|+ +             +   + x  ++    x+         *  x    *+     x           x x            x|
|         |________________A_|_______________|____AM___________________|              |
+-------------------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x  10     3.9939671       4.07289      4.029876     4.0286749   0.026863766
+  10      3.965914     4.0304928     3.9992213     3.9994131    0.02260193
Difference at 95.0% confidence
	-0.0292618 +/- 0.023325
	-0.726338% +/- 0.578974%
	(Student's t, pooled s = 0.0248245)

I did fudge up the test because I accidentally included an unrelated change. Here are the accurate numbers, still on GCE:

Difference at 95.0% confidence
    -0.181568 +/- 0.0814132
    -2.00135% +/- 0.897384%
    (Student's t, pooled s = 0.0866471)
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2022, 10:36 AM