You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jm...@apache.org on 2016/05/09 00:34:34 UTC

[02/10] cassandra git commit: Improve comments for SlabAllocator and NativeAllocator

Improve comments for SlabAllocator and NativeAllocator

Patch by zyang; reviewed by blambov for CASSANDRA-11541


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

Branch: refs/heads/cassandra-3.0
Commit: ac9844b99decbcda5ed279203884154011cda618
Parents: 483c745
Author: Zhao Yang <zh...@worksap.co.jp>
Authored: Fri May 6 10:18:25 2016 +0800
Committer: Josh McKenzie <jo...@datastax.com>
Committed: Sun May 8 20:31:43 2016 -0400

----------------------------------------------------------------------
 .../apache/cassandra/utils/memory/NativeAllocator.java    | 10 ++++++++++
 .../org/apache/cassandra/utils/memory/SlabAllocator.java  |  6 +++---
 2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ac9844b9/src/java/org/apache/cassandra/utils/memory/NativeAllocator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/memory/NativeAllocator.java b/src/java/org/apache/cassandra/utils/memory/NativeAllocator.java
index 88846c5..98878c0 100644
--- a/src/java/org/apache/cassandra/utils/memory/NativeAllocator.java
+++ b/src/java/org/apache/cassandra/utils/memory/NativeAllocator.java
@@ -37,6 +37,16 @@ import org.apache.cassandra.db.NativeDeletedCell;
 import org.apache.cassandra.db.NativeExpiringCell;
 import org.apache.cassandra.utils.concurrent.OpOrder;
 
+/**
+ * This NativeAllocator uses global slab allocation strategy
+ * with slab size that scales exponentially from 8kb to 1Mb to
+ * serve allocation of up to 128kb.
+ * <p>
+ * </p>
+ * The slab allocation reduces heap fragmentation from small
+ * long-lived objects.
+ *
+ */
 public class NativeAllocator extends MemtableAllocator
 {
     private final static int MAX_REGION_SIZE = 1 * 1024 * 1024;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ac9844b9/src/java/org/apache/cassandra/utils/memory/SlabAllocator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/memory/SlabAllocator.java b/src/java/org/apache/cassandra/utils/memory/SlabAllocator.java
index 8defd25..8ffead1 100644
--- a/src/java/org/apache/cassandra/utils/memory/SlabAllocator.java
+++ b/src/java/org/apache/cassandra/utils/memory/SlabAllocator.java
@@ -31,9 +31,9 @@ import org.apache.cassandra.utils.concurrent.OpOrder;
 import sun.nio.ch.DirectBuffer;
 
 /**
- * The SlabAllocator is a bump-the-pointer allocator that allocates
- * large (2MB by default) regions and then doles them out to threads that request
- * slices into the array.
++ * The SlabAllocator is a bump-the-pointer allocator that allocates
++ * large (1MB) global regions and then doles them out to threads that
++ * request smaller sized (up to 128kb) slices into the array.
  * <p></p>
  * The purpose of this class is to combat heap fragmentation in long lived
  * objects: by ensuring that all allocations with similar lifetimes