cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [02/10] cassandra git commit: Reenable HeapPool
Date Wed, 30 Nov 2016 13:34:46 GMT
Reenable HeapPool

Patch by marcuse; reviewed by Branimir Lambov for CASSANDRA-12900


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

Branch: refs/heads/cassandra-3.11
Commit: 8cb9693a6b334498ca7edd42e4a934c11b581f2c
Parents: d70b336
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Tue Nov 15 15:03:51 2016 +0100
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Wed Nov 30 14:24:43 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 src/java/org/apache/cassandra/db/Memtable.java  |  4 -
 .../db/partitions/AtomicBTreePartition.java     | 19 -----
 .../apache/cassandra/utils/memory/HeapPool.java | 77 ++++----------------
 .../utils/memory/MemtableAllocator.java         | 36 ---------
 .../cassandra/utils/memory/NativeAllocator.java |  6 --
 .../cassandra/utils/memory/SlabAllocator.java   |  5 --
 7 files changed, 15 insertions(+), 133 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb9693a/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 32bd821..58a29e7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,7 @@
  * LocalToken ensures token values are cloned on heap (CASSANDRA-12651)
  * AnticompactionRequestSerializer serializedSize is incorrect (CASSANDRA-12934)
  * Prevent reloading of logback.xml from UDF sandbox (CASSANDRA-12535)
+ * Reenable HeapPool (CASSANDRA-12900)
 Merged from 2.2:
  * cqlsh: fix DESC TYPES errors (CASSANDRA-12914)
  * Fix leak on skipped SSTables in sstableupgrade (CASSANDRA-12899)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb9693a/src/java/org/apache/cassandra/db/Memtable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java
index 3c77092..1a7d6cb 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -249,10 +249,6 @@ public class Memtable implements Comparable<Memtable>
                 allocator.onHeap().allocate(overhead, opGroup);
                 initialSize = 8;
             }
-            else
-            {
-                allocator.reclaimer().reclaimImmediately(cloneKey);
-            }
         }
 
         long[] pair = previous.addAllWithSizeDelta(update, opGroup, indexer);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb9693a/src/java/org/apache/cassandra/db/partitions/AtomicBTreePartition.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/partitions/AtomicBTreePartition.java b/src/java/org/apache/cassandra/db/partitions/AtomicBTreePartition.java
index 2be882e..7f2de82 100644
--- a/src/java/org/apache/cassandra/db/partitions/AtomicBTreePartition.java
+++ b/src/java/org/apache/cassandra/db/partitions/AtomicBTreePartition.java
@@ -244,7 +244,6 @@ public class AtomicBTreePartition extends AbstractBTreePartition
         long dataSize;
         long heapSize;
         long colUpdateTimeDelta = Long.MAX_VALUE;
-        final MemtableAllocator.DataReclaimer reclaimer;
         List<Row> inserted; // TODO: replace with walk of aborted BTree
 
         private RowUpdater(AtomicBTreePartition updating, MemtableAllocator allocator, OpOrder.Group
writeOp, UpdateTransaction indexer)
@@ -254,7 +253,6 @@ public class AtomicBTreePartition extends AbstractBTreePartition
             this.writeOp = writeOp;
             this.indexer = indexer;
             this.nowInSec = FBUtilities.nowInSeconds();
-            this.reclaimer = allocator.reclaimer();
         }
 
         private Row.Builder builder(Clustering clustering)
@@ -296,7 +294,6 @@ public class AtomicBTreePartition extends AbstractBTreePartition
             if (inserted == null)
                 inserted = new ArrayList<>();
             inserted.add(reconciled);
-            discard(existing);
 
             return reconciled;
         }
@@ -306,22 +303,7 @@ public class AtomicBTreePartition extends AbstractBTreePartition
             this.dataSize = 0;
             this.heapSize = 0;
             if (inserted != null)
-            {
-                for (Row row : inserted)
-                    abort(row);
                 inserted.clear();
-            }
-            reclaimer.cancel();
-        }
-
-        protected void abort(Row abort)
-        {
-            reclaimer.reclaimImmediately(abort);
-        }
-
-        protected void discard(Row discard)
-        {
-            reclaimer.reclaim(discard);
         }
 
         public boolean abortEarly()
@@ -337,7 +319,6 @@ public class AtomicBTreePartition extends AbstractBTreePartition
         protected void finish()
         {
             allocator.onHeap().adjust(heapSize, writeOp);
-            reclaimer.commit();
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb9693a/src/java/org/apache/cassandra/utils/memory/HeapPool.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/memory/HeapPool.java b/src/java/org/apache/cassandra/utils/memory/HeapPool.java
index 19f81be..57242c4 100644
--- a/src/java/org/apache/cassandra/utils/memory/HeapPool.java
+++ b/src/java/org/apache/cassandra/utils/memory/HeapPool.java
@@ -19,10 +19,7 @@
 package org.apache.cassandra.utils.memory;
 
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
 
-import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.utils.concurrent.OpOrder;
 
 public class HeapPool extends MemtablePool
@@ -39,66 +36,20 @@ public class HeapPool extends MemtablePool
 
     public MemtableAllocator newAllocator()
     {
-        // TODO
-        throw new UnsupportedOperationException();
-        //return new Allocator(this);
+        return new Allocator(this);
     }
 
-    // TODO
-    //public static class Allocator extends MemtableBufferAllocator
-    //{
-    //    Allocator(HeapPool pool)
-    //    {
-    //        super(pool.onHeap.newAllocator(), pool.offHeap.newAllocator());
-    //    }
-
-    //    public ByteBuffer allocate(int size, OpOrder.Group opGroup)
-    //    {
-    //        super.onHeap().allocate(size, opGroup);
-    //        return ByteBuffer.allocate(size);
-    //    }
-
-    //    public DataReclaimer reclaimer()
-    //    {
-    //        return new Reclaimer();
-    //    }
-
-    //    private class Reclaimer implements DataReclaimer
-    //    {
-    //        List<Cell> delayed;
-
-    //        public Reclaimer reclaim(Cell cell)
-    //        {
-    //            if (delayed == null)
-    //                delayed = new ArrayList<>();
-    //            delayed.add(cell);
-    //            return this;
-    //        }
-
-    //        public Reclaimer reclaimImmediately(Cell cell)
-    //        {
-    //            onHeap().release(cell.name().dataSize() + cell.value().remaining());
-    //            return this;
-    //        }
-
-    //        public Reclaimer reclaimImmediately(DecoratedKey key)
-    //        {
-    //            onHeap().release(key.getKey().remaining());
-    //            return this;
-    //        }
-
-    //        public void cancel()
-    //        {
-    //            if (delayed != null)
-    //                delayed.clear();
-    //        }
-
-    //        public void commit()
-    //        {
-    //            if (delayed != null)
-    //                for (Cell cell : delayed)
-    //                    reclaimImmediately(cell);
-    //        }
-    //    }
-    //}
+    private static class Allocator extends MemtableBufferAllocator
+    {
+        Allocator(HeapPool pool)
+        {
+            super(pool.onHeap.newAllocator(), pool.offHeap.newAllocator());
+        }
+
+        public ByteBuffer allocate(int size, OpOrder.Group opGroup)
+        {
+            super.onHeap().allocate(size, opGroup);
+            return ByteBuffer.allocate(size);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb9693a/src/java/org/apache/cassandra/utils/memory/MemtableAllocator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/memory/MemtableAllocator.java b/src/java/org/apache/cassandra/utils/memory/MemtableAllocator.java
index 5a64c3c..fa547ce 100644
--- a/src/java/org/apache/cassandra/utils/memory/MemtableAllocator.java
+++ b/src/java/org/apache/cassandra/utils/memory/MemtableAllocator.java
@@ -61,7 +61,6 @@ public abstract class MemtableAllocator
 
     public abstract Row.Builder rowBuilder(OpOrder.Group opGroup);
     public abstract DecoratedKey clone(DecoratedKey key, OpOrder.Group opGroup);
-    public abstract DataReclaimer reclaimer();
 
     public SubAllocator onHeap()
     {
@@ -102,41 +101,6 @@ public abstract class MemtableAllocator
         return state == LifeCycle.LIVE;
     }
 
-    public static interface DataReclaimer
-    {
-        public DataReclaimer reclaim(Row row);
-        public DataReclaimer reclaimImmediately(Row row);
-        public DataReclaimer reclaimImmediately(DecoratedKey key);
-        public void cancel();
-        public void commit();
-    }
-
-    public static final DataReclaimer NO_OP = new DataReclaimer()
-    {
-        public DataReclaimer reclaim(Row update)
-        {
-            return this;
-        }
-
-        public DataReclaimer reclaimImmediately(Row update)
-        {
-            return this;
-        }
-
-        public DataReclaimer reclaimImmediately(DecoratedKey key)
-        {
-            return this;
-        }
-
-        @Override
-        public void cancel()
-        {}
-
-        @Override
-        public void commit()
-        {}
-    };
-
     /** Mark the BB as unused, permitting it to be reclaimed */
     public static final class SubAllocator
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb9693a/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 4857f34..67f2a36 100644
--- a/src/java/org/apache/cassandra/utils/memory/NativeAllocator.java
+++ b/src/java/org/apache/cassandra/utils/memory/NativeAllocator.java
@@ -74,12 +74,6 @@ public class NativeAllocator extends MemtableAllocator
         return new NativeDecoratedKey(key.getToken(), this, writeOp, key.getKey());
     }
 
-    @Override
-    public MemtableAllocator.DataReclaimer reclaimer()
-    {
-        return NO_OP;
-    }
-
     public long allocate(int size, OpOrder.Group opGroup)
     {
         assert size >= 0;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cb9693a/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 8ffead1..e797575 100644
--- a/src/java/org/apache/cassandra/utils/memory/SlabAllocator.java
+++ b/src/java/org/apache/cassandra/utils/memory/SlabAllocator.java
@@ -106,11 +106,6 @@ public class SlabAllocator extends MemtableBufferAllocator
         }
     }
 
-    public DataReclaimer reclaimer()
-    {
-        return NO_OP;
-    }
-
     public void setDiscarded()
     {
         for (Region region : offHeapRegions)


Mime
View raw message