Browse Source

HPCC-19035 Use __builtin_prefetch when expanding hash tables

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 7 years ago
parent
commit
446df5cba3
2 changed files with 8 additions and 1 deletions
  1. 2 1
      ecl/hql/hqlexpr.cpp
  2. 6 0
      system/jlib/jsuperhash.cpp

+ 2 - 1
ecl/hql/hqlexpr.cpp

@@ -324,10 +324,11 @@ PURE(expression) - treat an expression as pure - probably superseded with WITHIN
 
 //---------------------------------------------------------------------------------------------------------------------
 
+const unsigned InitialExprCacheSize = 0x1000U; // Allocating larger than default has a very minor benefit
 class HqlExprCache : public JavaHashTableOf<CHqlExpression>
 {
 public:
-    HqlExprCache() : JavaHashTableOf<CHqlExpression>(false) {}
+    HqlExprCache() : JavaHashTableOf<CHqlExpression>(InitialExprCacheSize, false) {}
 
 protected:
     virtual unsigned getHashFromElement(const void * et) const

+ 6 - 0
system/jlib/jsuperhash.cpp

@@ -315,9 +315,15 @@ void SuperHashTable::expand(unsigned newsize)
     void * *newtable = (void * *) checked_malloc(newsize*sizeof(void *),-603);
     memset(newtable,0,newsize*sizeof(void *));
     void * *oldtable = table;
+#ifdef HASHSIZE_POWER2
+    const unsigned oldmask = tablesize-1;
+#endif
     unsigned i;
     for (i = 0; i < tablesize; i++)
     {
+#ifdef HASHSIZE_POWER2
+        __builtin_prefetch(oldtable[(i+1) & oldmask]);
+#endif
         void *et = oldtable[i];
         if (et)
         {