================
@@ -154,6 +156,38 @@ class RefSlab {
     llvm::DenseSet<Entry> Entries;
   };
 
+  /// RefSlab::Builder is a mutable container that can 'freeze' to RefSlab.
+  /// This variant is optimized to receive unique symbols
+  /// Use this when reading symbols which where previously written in a file.
+  class BuilderExpectUnique {
+  public:
+    BuilderExpectUnique() : UniqueStrings(Arena) {}
+    /// Adds a ref to the slab. Deep copy: Strings will be owned by the slab.
+    void insert(const SymbolID &ID, const Ref &S);
+    /// Consumes the builder to finalize the slab.
+    RefSlab build() &&;
+
+  private:
+    // A ref we're storing with its symbol to consume with build().
+    // All strings are interned, so DenseMapInfo can use pointer comparisons.
+    struct Entry {
+      SymbolID Symbol;
+      Ref Reference;
+      friend bool operator<(const Entry &L, const Entry &R) noexcept {
+        return std::tie(L.Symbol, L.Reference) <
----------------
JVApen wrote:

Before this fix, the performance improvement was from +/- 1minute15s & 50 CPU 
seconds to +/- 1minute real time to & 30 CPU seconds.
By comparing the pointers, it now is at +/-25s real time and +/-20 CPU seconds.

I'm a bit puzzled by the actual numbers here as the 1m real time seems to be a 
bit out of line here. However, the CPU times clearly show that this last change 
still a nice improvement, which is around a 60% reduction.

https://github.com/llvm/llvm-project/pull/156185
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to