This is an archive of the discontinued LLVM Phabricator instance.

Initialize OffsetMap in a known location
ClosedPublic

Authored by espindola on Mar 27 2018, 6:44 PM.

Details

Reviewers
ruiu
Summary

This is a small optimization: 3% in clang, probably noise everywhere else.

It is also a bit simpler IMHO.

Diff Detail

Event Timeline

espindola created this revision.Mar 27 2018, 6:44 PM
ruiu added inline comments.Mar 27 2018, 6:52 PM
ELF/SyntheticSections.cpp
2578–2579

Is the point of this patch to parallelize initOffsetMap?

How many sections do you usually have MS->Sections? I thought it's not many.

Did you try parallelizing initOffsetMap itself? We have a huge number of Pieces, so there might be a large room for parallelization.

espindola added inline comments.Mar 27 2018, 7:10 PM
ELF/SyntheticSections.cpp
2578–2579

No, I used a parallelForEach mostly because it is used when splitting the sections and was the parallelism we would get before this patch (via call_once). I benchmarked without threads.

MS->Sections will probably have about one section per file for the common case of a simple string section.

Would you be OK with parallelizing initOffsetMap as a followup?

ruiu added inline comments.Mar 27 2018, 7:20 PM
ELF/SyntheticSections.cpp
2578–2579

I'm fine with doing it in a follow-up patch, but what I was wondering is something different. I just tried to understand this patch.

If you have to call initOffsetMap after finalizeContents, can you call initOffsetMap from finalizeContents?

espindola added inline comments.Mar 27 2018, 7:40 PM
ELF/SyntheticSections.cpp
2578–2579

I can call it from finalizeContens, but there are two versions, one in MergeNoTailSection and one in MergeTailSection. Doing the call in here avoids duplication.

ruiu accepted this revision.Mar 27 2018, 7:52 PM

LGTM

This revision is now accepted and ready to land.Mar 27 2018, 7:52 PM