[Lldb-commits] [PATCH] D13652: Change ConstString to support massive multi-threaded access

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 12 13:38:19 PDT 2015


clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

It would be nice to compute one hash per string and use that during insertion. I really like the patch, but can we avoid two string hashes?


================
Comment at: source/Core/ConstString.cpp:147-152
@@ -165,7 +146,8 @@
 protected:
-    //------------------------------------------------------------------
-    // Typedefs
-    //------------------------------------------------------------------
-    typedef StringPool::iterator iterator;
-    typedef StringPool::const_iterator const_iterator;
+    uint8_t
+    hash(const llvm::StringRef &s)
+    {
+        uint32_t h = llvm::HashString(s);
+        return ((h >> 24) ^ (h >> 16) ^ (h >> 8) ^ h) & 0xff;
+    }
 
----------------
Is there a way we can use the hash that llvm uses for its string pool here? We are calculating two hashes: one for this to see which pool it will go into, and then another when the string is hashed into the string pool object. It would be nice if we can calculate the hash once and maybe do/add a string pool insertion that the pool with use to verify the string is in the pool or insert it using the supplied hash?


http://reviews.llvm.org/D13652





More information about the lldb-commits mailing list