diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index c06e2545e..d9cf61bd9 100755 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -553,8 +553,10 @@ public final class ChronicleMapBuilder implements Cloneable, private int estimateSegmentsBasedOnSize() { // based on entries with multimap of 100 bytes. - int segmentsForEntries = estimateSegmentsForEntries(); - return entrySize >= 100000 + int segmentsForEntries = estimateSegmentsForEntries(entries); + return entrySize >= 1000000 + ? segmentsForEntries * 16 + : entrySize >= 100000 ? segmentsForEntries * 8 : entrySize >= 10000 ? segmentsForEntries * 4 @@ -563,8 +565,7 @@ public final class ChronicleMapBuilder implements Cloneable, : segmentsForEntries; } - private int estimateSegmentsForEntries() { - long size = entries; + private static int estimateSegmentsForEntries(long size) { if (size > 200 << 20) return 256; if (size >= 1 << 20) @@ -575,6 +576,8 @@ public final class ChronicleMapBuilder implements Cloneable, return 32; if (size >= 4 << 10) return 16; + if (size >= 1 << 10) + return 8; return 1; } diff --git a/src/test/java/net/openhft/chronicle/map/LargeEntriesTest.java b/src/test/java/net/openhft/chronicle/map/LargeEntriesTest.java index 6e4a4c01d..a732624a5 100644 --- a/src/test/java/net/openhft/chronicle/map/LargeEntriesTest.java +++ b/src/test/java/net/openhft/chronicle/map/LargeEntriesTest.java @@ -103,24 +103,25 @@ public class LargeEntriesTest { @Ignore("Performance Test") public void testLargeStringsPerf() throws ExecutionException, InterruptedException, IOException { doLargeEntryPerf(10000, 100 * 1024); + doLargeEntryPerf(1000000, 1024); doLargeEntryPerf(100000, 10 * 1024); doLargeEntryPerf(10000, 100 * 1024); doLargeEntryPerf(3000, 1024 * 1024); } private void doLargeEntryPerf(int ENTRIES, final int ENTRY_SIZE) throws IOException, InterruptedException, ExecutionException { - System.out.printf("Testing %,d entries of %,d KB%n", ENTRIES, ENTRY_SIZE); + System.out.printf("Testing %,d entries of %,d KB%n", ENTRIES, ENTRY_SIZE / 1024); File file = File.createTempFile("largeEntries", ".deleteme"); file.deleteOnExit(); final ChronicleMap map = ChronicleMapBuilder .of(String.class, String.class) .valueMarshaller(SnappyStringMarshaller.INSTANCE) - .entries(ENTRIES * 2) - .entrySize(ENTRY_SIZE / 6) + .entries(ENTRIES) + .entrySize(ENTRY_SIZE / 7 + 200) .putReturnsNull(true) .createPersistedTo(file); { - warmUpCompression(ENTRY_SIZE); +// warmUpCompression(ENTRY_SIZE); int threads = Runtime.getRuntime().availableProcessors(); ExecutorService es = Executors.newFixedThreadPool(threads); final int block = ENTRIES / threads;