Skip to content

Commit 23cb854

Browse files
fix: default MVStore pageSplitSize to 16 KB, not 16 bytes (#1293)
MVStoreModuleBuilder.pageSplitSize is documented as "16 KB" and is passed straight to MVStore.Builder.pageSplitSize, which takes bytes. Its value was 16, the same literal used for cacheSize (megabytes) and cacheConcurrency (a count), so every leaf page split as soon as it held more than one entry. Measured by rebuilding a 146 MB store of 46,926 entries at each setting: 93,781 pages at depth 13 with 16; 36,096 pages at depth 12 with MVStore's own persistent-store default of 16 KB; 13,327 pages at depth 6 with 64 KB, the largest value that survives H2's (cacheSize / cacheConcurrency) >> 4 clamp. The default is now 16 * 1024, matching the javadoc and MVStore's default. Existing files are unaffected until their pages are rewritten; there is nothing to migrate. The two tests that pinned the old literal through Short.SIZE are updated. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent a01e120 commit 23cb854

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎nitrite-mvstore-adapter/src/main/java/org/dizitart/no2/mvstore/MVStoreModuleBuilder.java‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,15 @@ public class MVStoreModuleBuilder {
107107

108108
/**
109109
* The amount of memory a MVStore page should contain at most, in bytes,
110-
* before it is split. The default is 16 KB.
111-
*/
112-
private int pageSplitSize = 16;
110+
* before it is split. The default is 16 KB, which is also MVStore's own
111+
* default for a persistent store.
112+
* <p>
113+
* MVStore reads this value in bytes. It used to default to {@code 16}, so
114+
* every leaf page split as soon as it held more than one entry: a store
115+
* carried roughly one entry per page, and every lookup descended a tree
116+
* about twice as deep as it needed to be.
117+
*/
118+
private int pageSplitSize = 16 * 1024;
113119

114120
/**
115121
* The file store used by the MVStore.

‎nitrite-mvstore-adapter/src/test/java/org/dizitart/no2/mvstore/MVStoreModuleBuilderTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void testConstructor() {
3333
assertTrue(actualMvStoreModuleBuilder.autoCommit());
3434
assertFalse(actualMvStoreModuleBuilder.recoveryMode());
3535
assertFalse(actualMvStoreModuleBuilder.readOnly());
36-
assertEquals(Short.SIZE, actualMvStoreModuleBuilder.pageSplitSize());
36+
assertEquals(16 * 1024, actualMvStoreModuleBuilder.pageSplitSize());
3737
assertNull(actualMvStoreModuleBuilder.fileStore());
3838
assertEquals("Path", actualMvStoreModuleBuilder.filePath());
3939
assertTrue(actualMvStoreModuleBuilder.eventListeners().isEmpty());
@@ -66,7 +66,7 @@ public void testConstructor2() {
6666
MVStoreModuleBuilder actualMvStoreModuleBuilder = new MVStoreModuleBuilder();
6767
assertTrue(actualMvStoreModuleBuilder.autoCommit());
6868
assertFalse(actualMvStoreModuleBuilder.recoveryMode());
69-
assertEquals(Short.SIZE, actualMvStoreModuleBuilder.pageSplitSize());
69+
assertEquals(16 * 1024, actualMvStoreModuleBuilder.pageSplitSize());
7070
assertTrue(actualMvStoreModuleBuilder.eventListeners().isEmpty());
7171
assertEquals(1024, actualMvStoreModuleBuilder.autoCommitBufferSize());
7272
assertEquals(Short.SIZE, actualMvStoreModuleBuilder.cacheSize());

‎nitrite-mvstore-adapter/src/test/java/org/dizitart/no2/mvstore/MVStoreModuleTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void testWithConfig() {
3333
MVStoreModuleBuilder actualWithConfigResult = MVStoreModule.withConfig();
3434
assertTrue(actualWithConfigResult.autoCommit());
3535
assertFalse(actualWithConfigResult.recoveryMode());
36-
assertEquals(Short.SIZE, actualWithConfigResult.pageSplitSize());
36+
assertEquals(16 * 1024, actualWithConfigResult.pageSplitSize());
3737
assertTrue(actualWithConfigResult.eventListeners().isEmpty());
3838
assertEquals(1024, actualWithConfigResult.autoCommitBufferSize());
3939
assertEquals(Short.SIZE, actualWithConfigResult.cacheSize());

0 commit comments

Comments
 (0)