[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 14:59:06 PDT 2017


That explains what I saw with my test.

On Fri, Nov 3, 2017 at 1:21 PM, 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.
>

That's very interesting. One theory would be that the hit rate of the fast
lookup table is very high for gcc's outputs while it's not for clang's
outputs, but it contradicts to what I observed. IIRC, the hit rate of the
fast lookup table for clang's output is almost 100% (if not exactly 100%).

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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171103/8c7f6666/attachment.html>


More information about the llvm-commits mailing list