-
Notifications
You must be signed in to change notification settings - Fork 1
Merging the pipeline #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,8 @@ public class HeapMemStoreLAB implements MemStoreLAB { | |
|
|
||
| private AtomicReference<Chunk> curChunk = new AtomicReference<Chunk>(); | ||
| // A queue of chunks from pool contained by this memstore LAB | ||
| // TODO: in the future, it would be better to have List implementation instead of Queue, | ||
| // as FIFO order is not so important here | ||
| @VisibleForTesting | ||
| BlockingQueue<PooledChunk> pooledChunkQueue = null; | ||
| private final int chunkSize; | ||
|
|
@@ -106,6 +108,13 @@ public HeapMemStoreLAB(Configuration conf) { | |
| MAX_ALLOC_KEY + " must be less than " + CHUNK_SIZE_KEY); | ||
| } | ||
|
|
||
| /** | ||
| * To be used for merging multiple MSLABs | ||
| */ | ||
| public void addPooledChunkQueue(BlockingQueue<PooledChunk> targetQueue) { | ||
| targetQueue.drainTo(pooledChunkQueue); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the complexity here O(#items in queue)? How many items in queue, roughly? Could this become a bottleneck in merging/compaction?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The complexity is O(#items in targetQueue). Can not say how many items are in the queue as it depends on how many chunks we have per segment and this can vary. But I don't believe there are so many chunks that this would become a bottleneck, however this is for us to see later with stress benchmarking... Added the comment |
||
| } | ||
|
|
||
| /** | ||
| * Allocate a slice of the given length. | ||
| * | ||
|
|
@@ -242,8 +251,8 @@ Chunk getCurrentChunk() { | |
| return this.curChunk.get(); | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| BlockingQueue<PooledChunk> getChunkQueue() { | ||
|
|
||
| public BlockingQueue<PooledChunk> getChunkQueue() { | ||
| return this.pooledChunkQueue; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,7 +79,7 @@ protected ImmutableSegment(Segment segment) { | |
| * are going to be introduced. | ||
| */ | ||
| protected ImmutableSegment(CellComparator comparator, MemStoreCompactorIterator iterator, | ||
| MemStoreLAB memStoreLAB, int numOfCells, Type type) { | ||
| MemStoreLAB memStoreLAB, int numOfCells, Type type, boolean doMerge) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all these doMerge flags should be part of the policy state and should not be passed throughout the code. |
||
|
|
||
| super(null, // initiailize the CellSet with NULL | ||
| comparator, memStoreLAB, | ||
|
|
@@ -88,7 +88,7 @@ protected ImmutableSegment(CellComparator comparator, MemStoreCompactorIterator | |
| ClassSize.CELL_ARRAY_MAP_ENTRY); | ||
|
|
||
| // build the true CellSet based on CellArrayMap | ||
| CellSet cs = createCellArrayMapSet(numOfCells, iterator); | ||
| CellSet cs = createCellArrayMapSet(numOfCells, iterator, doMerge); | ||
|
|
||
| this.setCellSet(null, cs); // update the CellSet of the new Segment | ||
| this.type = type; | ||
|
|
@@ -194,19 +194,26 @@ public boolean flatten() { | |
| ///////////////////// PRIVATE METHODS ///////////////////// | ||
| /*------------------------------------------------------------------------*/ | ||
| // Create CellSet based on CellArrayMap from compacting iterator | ||
| private CellSet createCellArrayMapSet(int numOfCells, MemStoreCompactorIterator iterator) { | ||
| private CellSet createCellArrayMapSet(int numOfCells, MemStoreCompactorIterator iterator, | ||
| boolean doMerge) { | ||
|
|
||
| Cell[] cells = new Cell[numOfCells]; // build the Cell Array | ||
| int i = 0; | ||
| while (iterator.hasNext()) { | ||
| Cell c = iterator.next(); | ||
| // The scanner behind the iterator is doing all the elimination logic | ||
| // now we just copy it to the new segment (also MSLAB copy) | ||
| cells[i] = maybeCloneWithAllocator(c); | ||
| boolean usedMSLAB = (cells[i] != c); | ||
| if (doMerge) { | ||
| // if this is merge we just move the Cell object without copying MSLAB | ||
| // the sizes still need to be updated in the new segment | ||
| cells[i] = c; | ||
| } else { | ||
| // now we just copy it to the new segment (also MSLAB copy) | ||
| cells[i] = maybeCloneWithAllocator(c); | ||
| } | ||
| boolean useMSLAB = (getMemStoreLAB()!=null); | ||
| // second parameter true, because in compaction addition of the cell to new segment | ||
| // is always successful | ||
| updateMetaInfo(c, true, usedMSLAB); // updates the size per cell | ||
| updateMetaInfo(c, true, useMSLAB); // updates the size per cell | ||
| i++; | ||
| } | ||
| // build the immutable CellSet | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having the merge flag affecting the swap suffix seems wrong
applying the close in the outer scope seems to be better.
this change could be deferred to the policy jira, but if there's no policy jira, should do it here.