Prechádzať zdrojové kódy

Merge pull request #10833 from ghalliday/issue19035

HPCC-19035 Use __builtin_prefetch when expanding hash tables

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 7 rokov pred
rodič
commit
5a34420561
2 zmenil súbory, kde vykonal 8 pridanie a 1 odobranie
  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)
         {