mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
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:
@@ -165,19 +165,14 @@ public abstract class MapEntryStages<K, V> extends HashEntryStages<K>
|
||||
"entry takes " + newSizeInChunks + " chunks, " +
|
||||
m.maxChunksPerEntry + " is maximum.");
|
||||
}
|
||||
if (s.freeList.isRangeClear(pos + entrySizeInChunks, pos + newSizeInChunks)) {
|
||||
s.freeList.setRange(pos + entrySizeInChunks, pos + newSizeInChunks);
|
||||
if (s.realloc(pos, entrySizeInChunks, newSizeInChunks)) {
|
||||
break newValueDoesNotFit;
|
||||
}
|
||||
relocation(newValue, newSizeOfEverythingBeforeValue);
|
||||
return;
|
||||
} else if (newSizeInChunks < entrySizeInChunks) {
|
||||
// Freeing extra chunks
|
||||
s.freeList.clearRange(pos + newSizeInChunks, pos + entrySizeInChunks);
|
||||
// Do NOT reset nextPosToSearchFrom, because if value
|
||||
// once was larger it could easily became larger again,
|
||||
// But if these chunks will be taken by that time,
|
||||
// this entry will need to be relocated.
|
||||
s.free(pos + newSizeInChunks, entrySizeInChunks - newSizeInChunks);
|
||||
}
|
||||
// new size != old size => size is not constant => size is actually written =>
|
||||
// to prevent (at least) this execution:
|
||||
|
||||
@@ -46,9 +46,7 @@ public abstract class QueryMapEntryStages<K, V> extends MapEntryStages<K, V> {
|
||||
} else {
|
||||
newSizeInChunks = entrySizeInChunks;
|
||||
}
|
||||
if (pos + newSizeInChunks < s.freeList.logicalSize() &&
|
||||
s.freeList.isRangeClear(pos, pos + newSizeInChunks)) {
|
||||
s.freeList.setRange(pos, pos + newSizeInChunks);
|
||||
if (s.realloc(pos, 0, newSizeInChunks)) {
|
||||
s.innerWriteLock.lock();
|
||||
allocatedChunks.incrementSegmentEntriesIfNeeded();
|
||||
if (newValueSizeIsDifferent) {
|
||||
|
||||
Reference in New Issue
Block a user