asterixdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yingyi Bu (Code Review)" <do-not-re...@asterix-gerrit.ics.uci.edu>
Subject Change in hyracks[master]: Performance fix for BufferCache. The dpid of a page of file ...
Date Tue, 04 Aug 2015 18:17:56 GMT
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 <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Young-Seok Kim <kisskys@gmail.com>
Reviewed-by: Pouria Pirzadeh <pouria.pirzadeh@gmail.com>
---
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 <buyingyi@gmail.com>
Gerrit-Reviewer: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Pouria Pirzadeh <pouria.pirzadeh@gmail.com>
Gerrit-Reviewer: Yingyi Bu <buyingyi@gmail.com>
Gerrit-Reviewer: Young-Seok Kim <kisskys@gmail.com>

Mime
View raw message