This patch introduces relocation caching helper.
Instead of plain std::find by offset, caching helper
allows either to take relocation from cache or
to continue searching from last unvisited relocation.
That gives speedup by 55%. I used built-in benchmark for
perfomance estimating (D36076). It runs .gdb_index building in
a loop and calculated average time.
After 50 runs, results are:
- With patch: Avg: 2.700828e+00, N: 50 Min: 2.658942e+00, Max: 2.729724e+00, Last: 2.717378e+00
- W/o patch: Avg: 4.903375e+00, N: 50 Min: 4.889383e+00, Max: 4.949485e+00, Last: 4.928791e+00
2.7/4.9 == 0.551
I also tried traditional benchmarking approach, linked debug clang
(used clang objects and reproduce from clang-gdb-index folder
of lld-speed-test.tar.xz archive posted by Rafael earlier)
Without patch time is: 15,026934140 seconds time elapsed ( +- 0,50% )
With patch: 12,907121321 seconds time elapsed ( +- 0,72% )
So it is 15.02 / (15.02 - 12.9) == 7.08% speedup of total link timewith --gdb-index,
though calculations are not so accurate as built-in benchmark above shows.