From c9c34bdc1af8bf0c2678aacad26b1552e0d79eee Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 5 Dec 2018 19:13:31 +0000 Subject: [PATCH] Do not use a hash table to uniquify mergeable strings. Previously, we have a hash table containing strings and their offsets to manage mergeable strings. Technically we can live without that, because we can do binary search on a vector of mergeable strings to find a mergeable strings. We did have both the hash table and the binary search because we thought that that is faster. We recently observed that lld tend to consume more memory than gold when building an output with debug info. A few percent of memory is consumed by the hash table. So, we needed to reevaluate whether or not having the extra hash table is a good CPU/memory tradeoff. I run a few benchmarks with and without the hash table. I got a mixed result for the benchmark. We observed a regression for some programs by removing the hash table (that's what we expected), but we also observed that performance imrpovements for some programs. This is perhaps due to reduced memory usage. Differential Revision: https://reviews.llvm.org/D55234 llvm-svn: 348401 --- lld/ELF/InputSection.cpp | 9 --------- lld/ELF/InputSection.h | 1 - 2 files changed, 10 deletions(-) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 97df033..5f3df54 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -1206,21 +1206,12 @@ void MergeInputSection::splitIntoPieces() { splitStrings(data(), Entsize); else splitNonStrings(data(), Entsize); - - OffsetMap.reserve(Pieces.size()); - for (size_t I = 0, E = Pieces.size(); I != E; ++I) - OffsetMap[Pieces[I].InputOff] = I; } SectionPiece *MergeInputSection::getSectionPiece(uint64_t Offset) { if (this->data().size() <= Offset) fatal(toString(this) + ": offset is outside the section"); - // Find a piece starting at a given offset. - auto It = OffsetMap.find(Offset); - if (It != OffsetMap.end()) - return &Pieces[It->second]; - // If Offset is not at beginning of a section piece, it is not in the map. // In that case we need to do a binary search of the original section piece vector. auto It2 = diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index d4edc06..34f411e 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -253,7 +253,6 @@ public: // Splittable sections are handled as a sequence of data // rather than a single large blob of data. std::vector Pieces; - llvm::DenseMap OffsetMap; // Returns I'th piece's data. This function is very hot when // string merging is enabled, so we want to inline. -- 2.7.4