cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject git commit: Improve offheap memcpy performance
Date Tue, 13 Aug 2013 16:45:49 GMT
Updated Branches:
  refs/heads/cassandra-2.0 9806b7761 -> 89fc57674


Improve offheap memcpy performance

Patch by tjake; reviewed my jbellis for CASSANDRA-5884


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/89fc5767
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/89fc5767
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/89fc5767

Branch: refs/heads/cassandra-2.0
Commit: 89fc57674e68c834564cbcfd42e158fcb0aa4d33
Parents: 9806b77
Author: Jake Luciani <jake@apache.org>
Authored: Tue Aug 13 12:44:43 2013 -0400
Committer: Jake Luciani <jake@apache.org>
Committed: Tue Aug 13 12:44:43 2013 -0400

----------------------------------------------------------------------
 CHANGES.txt                                       | 1 +
 src/java/org/apache/cassandra/io/util/Memory.java | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/89fc5767/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a956048..f7e439c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,7 @@
  * Notify indexer of columns shadowed by range tombstones (CASSANDRA-5614)
  * Log Merkle tree stats (CASSANDRA-2698)
  * Switch from crc32 to adler32 for compressed sstable checksums (CASSANDRA-5862)
+ * Improve offheap memcpy performance (CASSANDRA-5884)
 
 
 2.0.0-rc2

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89fc5767/src/java/org/apache/cassandra/io/util/Memory.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/util/Memory.java b/src/java/org/apache/cassandra/io/util/Memory.java
index 051b427..b98dded 100644
--- a/src/java/org/apache/cassandra/io/util/Memory.java
+++ b/src/java/org/apache/cassandra/io/util/Memory.java
@@ -28,6 +28,7 @@ public class Memory
 {
     private static final Unsafe unsafe = NativeAllocator.unsafe;
     private static final IAllocator allocator = DatabaseDescriptor.getoffHeapMemoryAllocator();
+    private static final long BYTE_ARRAY_BASE_OFFSET = unsafe.arrayBaseOffset(byte[].class);
 
     protected long peer;
     // size of the memory region
@@ -94,8 +95,8 @@ public class Memory
         checkPosition(memoryOffset);
         long end = memoryOffset + count;
         checkPosition(end - 1);
-        while (memoryOffset < end)
-            unsafe.putByte(peer + memoryOffset++, buffer[bufferOffset++]);
+
+        unsafe.copyMemory(buffer, BYTE_ARRAY_BASE_OFFSET, null, peer + memoryOffset, count);
     }
 
     public byte getByte(long offset)
@@ -136,8 +137,8 @@ public class Memory
         checkPosition(memoryOffset);
         long end = memoryOffset + count;
         checkPosition(end - 1);
-        while (memoryOffset < end)
-            buffer[bufferOffset++] = unsafe.getByte(peer + memoryOffset++);
+
+        unsafe.copyMemory(null, peer + memoryOffset, buffer, BYTE_ARRAY_BASE_OFFSET, count);
     }
 
     private void checkPosition(long offset)


Mime
View raw message