asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject incubator-asterixdb-hyracks git commit: 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 configuratio
Date Tue, 04 Aug 2015 18:22:09 GMT
Repository: incubator-asterixdb-hyracks
Updated Branches:
  refs/heads/master d48d18fd2 -> b5e88a2a3


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>


Project: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/commit/b5e88a2a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/tree/b5e88a2a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/diff/b5e88a2a

Branch: refs/heads/master
Commit: b5e88a2a3d3a68f93ec46f8e6dbc93af6c77a75d
Parents: d48d18f
Author: Yingyi Bu <buyingyi@gmail.com>
Authored: Tue Aug 4 00:35:58 2015 -0700
Committer: Yingyi Bu <buyingyi@gmail.com>
Committed: Tue Aug 4 11:17:56 2015 -0700

----------------------------------------------------------------------
 .../uci/ics/hyracks/storage/common/buffercache/BufferCache.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/b5e88a2a/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java
----------------------------------------------------------------------
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 @@ public class BufferCache implements IBufferCacheInternal, ILifeCycleComponent
{
         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 @@ public class BufferCache implements IBufferCacheInternal, ILifeCycleComponent
{
     }
 
     private int hash(long dpid) {
-        return (int) (dpid % pageMap.length);
+        int hashValue = (int) (dpid ^ (dpid >>> 32));
+        return hashValue % pageMap.length;
     }
 
     private static class CacheBucket {


Mime
View raw message