[lld] r317026 - Revert r316305: Remove a fast lookup table from MergeInputSection.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 18:17:36 PDT 2017


On Fri, Nov 3, 2017 at 6:00 PM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> One last thing I remembered. Most of the regression is because of massive
> branch mis prediction, which is not surprising in a hot binary search.
>
> In http://cglab.ca/~morin/misc/arraylayout-v2/ there more efficient
> algorithms that don't need mis predicted branches.
>

None of these algorithms can eliminate branch mis-predictions no? They
might be have better memory locality, but but they don't seem to improve
branch prediction.

I actually tried to implement the Eytzinger layout, but it didn't improve
performance. You can see my patch here (
https://github.com/rui314/llvm-project/commit/52ced61fe07e79b3c9307c013d0ec242bd67212c)
if you are interested.

Last time I tried clang was creating more branches than expected, but that
> might be fixed now.
>
> Cheers,
> Rafael
>
>
> On November 3, 2017 1:21:42 PM PDT, Rafael Avila de Espindola <
> rafael.espindola at gmail.com> wrote:
>
>> I found a fascinating fact about what regressed and what improved with
>> the cache:
>>
>> Testcases that are compiled by gcc and have debug info benefit
>> tremendously: scylla got 20% faster and mozilla 15%.
>>
>> Tests without debug information benefited a bit.
>>
>> The one test we have with clang debug info (clang-gdb-index) regressed a
>> bit (1.3%).
>>
>> So there is some difference that causes gcc produced debug info to hit a
>> lot more relocations to a symbol in a merge section. Not sure what that
>> is.
>>
>> Cheers,
>> Rafael
>>
>> Rui Ueyama via llvm-commits <llvm-commits at lists.llvm.org> writes:
>>
>>  Author: ruiu
>>>  Date: Tue Oct 31 12:14:06 2017
>>>  New Revision: 317026
>>>
>>>  URL: http://llvm.org/viewvc/llvm-project?rev=317026&view=rev
>>>  Log:
>>>  Revert r316305: Remove a fast lookup table from MergeInputSection.
>>>
>>>  This reverts commit r316305 because performance regression was observed.
>>>
>>>  Modified:
>>>      lld/trunk/ELF/InputSection.cpp
>>>      lld/trunk/ELF/InputSection.h
>>>
>>>  Modified: lld/trunk/ELF/InputSection.cpp
>>>  URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=317026&r1=317025&r2=317026&view=diff
>>> ------------------------------
>>>
>>>  --- lld/trunk/ELF/InputSection.cpp (original)
>>>  +++ lld/trunk/ELF/InputSection.cpp Tue Oct 31 12:14:06 2017
>>>  @@ -968,9 +968,24 @@ uint64_t MergeInputSection::getOffset(ui
>>>     if (!Live)
>>>       return 0;
>>>
>>>  -  const SectionPiece &Piece = *getSectionPiece(Offset);
>>>  +  // Initialize OffsetMap lazily.
>>>  +  llvm::call_once(InitOffsetMap, [&] {
>>>  +    OffsetMap.reserve(Pieces.size());
>>>  +    for (size_t I = 0; I < Pieces.size(); ++I)
>>>  +      OffsetMap[Pieces[I].InputOff] = I;
>>>  +  });
>>>  +
>>>  +  // Find a string starting at a given offset.
>>>  +  auto It = OffsetMap.find(Offset);
>>>  +  if (It != OffsetMap.end())
>>>  +    return Pieces[It->second].OutputOff;
>>>  +
>>>  +  // If Offset is not at beginning of a section piece, it is not in the map.
>>>  +  // In that case we need to search from the original section piece vector.
>>>  +  const SectionPiece &Piece = *this->getSectionPiece(Offset);
>>>     if (!Piece.Live)
>>>       return 0;
>>>  +
>>>     uint64_t Addend = Offset - Piece.InputOff;
>>>     return Piece.OutputOff + Addend;
>>>   }
>>>
>>>  Modified: lld/trunk/ELF/InputSection.h
>>>  URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=317026&r1=317025&r2=317026&view=diff
>>> ------------------------------
>>>
>>>  --- lld/trunk/ELF/InputSection.h (original)
>>>  +++ lld/trunk/ELF/InputSection.h Tue Oct 31 12:14:06 2017
>>>  @@ -263,6 +263,9 @@ private:
>>>     void splitStrings(ArrayRef<uint8_t> A, size_t Size);
>>>     void splitNonStrings(ArrayRef<uint8_t> A, size_t Size);
>>>
>>>  +  mutable llvm::DenseMap<uint32_t, uint32_t> OffsetMap;
>>>  +  mutable llvm::once_flag InitOffsetMap;
>>>  +
>>>     llvm::DenseSet<uint64_t> LiveOffsets;
>>>   };
>>>
>>>
>>>
>>> ------------------------------
>>>
>>>  llvm-commits mailing list
>>>  llvm-commits at lists.llvm.org
>>>  http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171103/c017b020/attachment-0001.html>


More information about the llvm-commits mailing list