Replace nextPosToSearchFrom with lowestPossiblyFreeChunk semantically, that allows to avoid searching free chunks though a full tier, when segment is tiered, again and again. Also, make chunk block reallocation in innerDefaultReplaceValue() and putValueDeletedEntry() check it doesn't overflow actualChunksPerSegmentTier

This commit is contained in:
leventov
2015-12-07 07:20:47 +03:00
parent 82988e7435
commit 2f58bfb399
15 changed files with 125 additions and 138 deletions
@@ -50,10 +50,11 @@ public final class BigSegmentHeader implements SegmentHeader {
static final int WAIT_PARTY = 1;
static final long SIZE_OFFSET = LOCK_OFFSET + 8L; // 32-bit
static final long NEXT_POS_TO_SEARCH_FROM_OFFSET = SIZE_OFFSET + 4L;
static final long LOWEST_POSSIBLY_FREE_CHUNK_OFFSET = ENTRIES_OFFSET + 4L;
static final long EXCLUSIVE_LOCK_HOLDER_THREAD_ID_OFFSET = NEXT_POS_TO_SEARCH_FROM_OFFSET + 4L;
static final long EXCLUSIVE_LOCK_HOLDER_THREAD_ID_OFFSET =
LOWEST_POSSIBLY_FREE_CHUNK_OFFSET + 4L;
static final long DELETED_OFFSET = EXCLUSIVE_LOCK_HOLDER_THREAD_ID_OFFSET + 8L;
@@ -89,13 +90,14 @@ public final class BigSegmentHeader implements SegmentHeader {
}
@Override
public long nextPosToSearchFrom(long address) {
return OS.memory().readInt(address + NEXT_POS_TO_SEARCH_FROM_OFFSET) & UNSIGNED_INT_MASK;
public long lowestPossiblyFreeChunk(long address) {
return OS.memory().readInt(address + LOWEST_POSSIBLY_FREE_CHUNK_OFFSET) & UNSIGNED_INT_MASK;
}
@Override
public void nextPosToSearchFrom(long address, long nextPosToSearchFrom) {
OS.memory().writeInt(address + NEXT_POS_TO_SEARCH_FROM_OFFSET, (int) nextPosToSearchFrom);
public void lowestPossiblyFreeChunk(long address, long lowestPossiblyFreeChunk) {
OS.memory().writeInt(address + LOWEST_POSSIBLY_FREE_CHUNK_OFFSET,
(int) lowestPossiblyFreeChunk);
}
private static long getLockWord(long address) {