mirror of https://github.com/apache/cassandra
Reenable HeapPool
Patch by marcuse; reviewed by Branimir Lambov for CASSANDRA-12900
This commit is contained in:
parent
d70b336de3
commit
8cb9693a6b
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
// }
|
||||
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);
|
||||
// }
|
||||
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
public ByteBuffer allocate(int size, OpOrder.Group opGroup)
|
||||
{
|
||||
super.onHeap().allocate(size, opGroup);
|
||||
return ByteBuffer.allocate(size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -106,11 +106,6 @@ public class SlabAllocator extends MemtableBufferAllocator
|
|||
}
|
||||
}
|
||||
|
||||
public DataReclaimer reclaimer()
|
||||
{
|
||||
return NO_OP;
|
||||
}
|
||||
|
||||
public void setDiscarded()
|
||||
{
|
||||
for (Region region : offHeapRegions)
|
||||
|
|
|
|||
Loading…
Reference in New Issue