Yingyi Bu has submitted this change and it was merged.

Change subject: Performance fix for BufferCache. The dpid of a page of file is 
calculated by fileid<<32 + pageid. But BufferCache.hash(long dpid) returns the 
hash value dpid%pageMap.length. In many cases,  the asterix configuration 
results in power-of-2 pageMap.length (b
......................................................................


Performance fix for BufferCache.
The dpid of a page of file is calculated by fileid<<32 + pageid.
But BufferCache.hash(long dpid) returns the hash value dpid%pageMap.length.
In many cases,  the asterix configuration results in power-of-2 pageMap.length 
(buffer-cache-size/page-size), which makes fileid useless.
That used to result in serious consequences: different partitions contend for 
the same cache bucket (which contains a link list of size #partitions)
for most of the time and therefore the CPU couldn't be saturated.

Change-Id: I4afc406d612e569e23f65afdedc469459235ce7d
Reviewed-on: https://asterix-gerrit.ics.uci.edu/341
Tested-by: Jenkins <[email protected]>
Reviewed-by: Young-Seok Kim <[email protected]>
Reviewed-by: Pouria Pirzadeh <[email protected]>
---
M 
hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java
1 file changed, 3 insertions(+), 2 deletions(-)

Approvals:
  Pouria Pirzadeh: Looks good to me, but someone else must approve
  Young-Seok Kim: Looks good to me, approved
  Jenkins: Verified



diff --git 
a/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java
 
b/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java
index 94ad801..0ceab64 100644
--- 
a/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java
+++ 
b/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java
@@ -67,7 +67,7 @@
         this.pageSize = pageReplacementStrategy.getPageSize();
         this.maxOpenFiles = maxOpenFiles;
         pageReplacementStrategy.setBufferCache(this);
-        pageMap = new 
CacheBucket[pageReplacementStrategy.getMaxAllowedNumPages() * MAP_FACTOR];
+        pageMap = new 
CacheBucket[pageReplacementStrategy.getMaxAllowedNumPages() * MAP_FACTOR + 1];
         for (int i = 0; i < pageMap.length; ++i) {
             pageMap[i] = new CacheBucket();
         }
@@ -441,7 +441,8 @@
     }
 
     private int hash(long dpid) {
-        return (int) (dpid % pageMap.length);
+        int hashValue = (int) (dpid ^ (dpid >>> 32));
+        return hashValue % pageMap.length;
     }
 
     private static class CacheBucket {

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/341
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4afc406d612e569e23f65afdedc469459235ce7d
Gerrit-PatchSet: 4
Gerrit-Project: hyracks
Gerrit-Branch: master
Gerrit-Owner: Yingyi Bu <[email protected]>
Gerrit-Reviewer: Jenkins <[email protected]>
Gerrit-Reviewer: Pouria Pirzadeh <[email protected]>
Gerrit-Reviewer: Yingyi Bu <[email protected]>
Gerrit-Reviewer: Young-Seok Kim <[email protected]>

Reply via email to