Tweek segment sizes again.

This commit is contained in:
Peter Lawrey
2014-11-10 15:07:08 +00:00
parent 6e2881a014
commit 1774a4d331
3 changed files with 36 additions and 39 deletions
@@ -372,10 +372,8 @@ public abstract class AbstractChronicleMapBuilder<K, V,
if (segments == 1)
return entries;
double poorDistEntriesScale = Math.log(segments) * entries;
if (segments <= 8)
return Math.min(entries * segments,
(long) (entries + poorDistEntriesScale * 0.11 + segments * 8)); // 11% was min for tests
return (long) (entries + poorDistEntriesScale * 0.11 + 80); // 11% was min for tests
return Math.min(entries * segments,
(long) (entries + poorDistEntriesScale * 0.14 + 32)); // 12% was min for tests
}
@Override
@@ -390,24 +388,22 @@ public abstract class AbstractChronicleMapBuilder<K, V,
}
private int estimateSegments() {
for (int power = 1; power < 64; power *= 2) {
if (entries <= power * power * power)
return power;
}
long size = (entrySize + 32) * entries;
if (size < 10L * 1000 * 1000) // 10 MB
return 64;
if (size < 100L * 1000 * 1000) // 100 MB
return 128;
if (size < 400L * 1000 * 1000) // 400 MB
return 256;
if (size < 1L * 1000 * 1000 * 1000) // 1 GB
return (int) Math.min(Maths.nextPower2(entries / 32, 1), estimateSegementBasedOnSize());
}
private int estimateSegementBasedOnSize() {
// based on entries with multimap of 100 bytes.
long size = (long) (Math.log10(entrySize + 32) / 2 * entries);
if (size < 10 * 1000)
return 512;
if (size < 10L * 1000 * 1000 * 1000) // 10 GB
if (size < 100 * 1000)
return 1024;
if (size < 100L * 1000 * 1000 * 1000) // 100 GB
if (size < 1000 * 1000)
return 2048;
return 4096;
if (size < 10 * 1000 * 1000)
return 4096;
return 8192;
}
@Override
@@ -937,7 +933,7 @@ public abstract class AbstractChronicleMapBuilder<K, V,
int segmentHeaderSize() {
int segments = actualSegments();
// reduce false sharing unless we have a lot of segments.
return segments <= 8192 ? 64 : 16;
return segments <= 8192 ? 128 : 64;
}
public MultiMapFactory multiMapFactory() {