[llvm] r249942 - [RuntimeDyld] Fix performance problem in resolveRelocations with many sections

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 11 00:28:21 PDT 2015


On Fri, Oct 9, 2015 at 10:37 PM, Keno Fischer via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: kfischer
> Date: Sat Oct 10 00:37:02 2015
> New Revision: 249942
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249942&view=rev
> Log:
> [RuntimeDyld] Fix performance problem in resolveRelocations with many sections
>
> Summary:
> Rather than just iterating over all sections and checking whether we have relocations for them, iterate over the relocation map instead. This showed up heavily in an artificial julia benchmark that does lots of compilation. On that particular benchmark, this patch gives
> ~15% performance improvements. As far as I can tell the primary reason why the original
> loop was so expensive is that Relocations[i] actually constructs a relocationList (allocating memory & doing lots of other unnecessary computing) if none is found.
>
> Reviewers: lhames
>
> Subscribers: llvm-commits
>
> Differential Revision: http://reviews.llvm.org/D13545
>
> Modified:
>     llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
>
> Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=249942&r1=249941&r2=249942&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Sat Oct 10 00:37:02 2015
> @@ -91,18 +91,18 @@ void RuntimeDyldImpl::resolveRelocations
>    // First, resolve relocations associated with external symbols.
>    resolveExternalSymbols();
>
> -  // Just iterate over the sections we have and resolve all the relocations
> -  // in them. Gross overkill, but it gets the job done.
> -  for (int i = 0, e = Sections.size(); i != e; ++i) {
> +  // Iterate over all outstanding relocations
> +  for (auto it = Relocations.begin(), e = Relocations.end(); it != e; ++it) {

Thanks for this optimization. Small comment: can't you use range-based
loop here, or am I missing something?

--
Davide


More information about the llvm-commits mailing list