Repository: cassandra Updated Branches: refs/heads/cassandra-2.2 483c74533 -> ac9844b99 refs/heads/cassandra-3.0 411c56014 -> ecb4ae8da refs/heads/cassandra-3.7 02f8725d7 -> a8a3a7338 refs/heads/trunk d9083a9c2 -> 0f0b2dfce
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-2.2 Commit: ac9844b99decbcda5ed279203884154011cda618 Parents: 483c745 Author: Zhao Yang <[email protected]> Authored: Fri May 6 10:18:25 2016 +0800 Committer: Josh McKenzie <[email protected]> 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
