@@ -566,6 +566,7 @@ public class PropServerConfiguration implements ServerConfiguration {
566566 private final int walTxnNotificationQueueCapacity ;
567567 private final long walWriterDataAppendPageSize ;
568568 private final long walWriterEventAppendPageSize ;
569+ private final int walWriterMadviseMode ;
569570 private final int walWriterPoolMaxSegments ;
570571 private final long workStealTimeoutNanos ;
571572 private final long writerAsyncCommandBusyWaitTimeout ;
@@ -1471,6 +1472,7 @@ public PropServerConfiguration(
14711472 this .parallelIndexThreshold = getInt (properties , env , PropertyKey .CAIRO_PARALLEL_INDEX_THRESHOLD , 100000 );
14721473 this .readerPoolMaxSegments = getInt (properties , env , PropertyKey .CAIRO_READER_POOL_MAX_SEGMENTS , 10 );
14731474 this .poolSegmentSize = getIntSize (properties , env , PropertyKey .DEBUG_CAIRO_POOL_SEGMENT_SIZE , 32 );
1475+ this .walWriterMadviseMode = getWalWriterMadviseMode (properties , env , PropertyKey .CAIRO_WAL_WRITER_MADVISE_MODE );
14741476 this .walWriterPoolMaxSegments = getInt (properties , env , PropertyKey .CAIRO_WAL_WRITER_POOL_MAX_SEGMENTS , 10 );
14751477 this .viewWalWriterPoolMaxSegments = getInt (properties , env , PropertyKey .CAIRO_VIEW_WAL_WRITER_POOL_MAX_SEGMENTS , 4 );
14761478 this .spinLockTimeout = getMillis (properties , env , PropertyKey .CAIRO_SPIN_LOCK_TIMEOUT , 1_000 );
@@ -2255,6 +2257,27 @@ private int getSqlJitMode(Properties properties, @Nullable Map<String, String> e
22552257 return SqlJitMode .JIT_MODE_ENABLED ;
22562258 }
22572259
2260+ private int getWalWriterMadviseMode (Properties properties , @ Nullable Map <String , String > env , ConfigPropertyKey key ) throws ServerConfigurationException {
2261+ final String mode = getString (properties , env , key , "none" );
2262+
2263+ // must not be null because we provided non-null default value
2264+ assert mode != null ;
2265+
2266+ if (Chars .equalsLowerCaseAscii (mode , "none" )) {
2267+ return -1 ;
2268+ }
2269+
2270+ if (Chars .equalsLowerCaseAscii (mode , "sequential" )) {
2271+ return Files .POSIX_MADV_SEQUENTIAL ;
2272+ }
2273+
2274+ if (Chars .equalsLowerCaseAscii (mode , "random" )) {
2275+ return Files .POSIX_MADV_RANDOM ;
2276+ }
2277+
2278+ throw ServerConfigurationException .forInvalidKey (key .getPropertyPath (), mode );
2279+ }
2280+
22582281 // The enterprise version needs to add tcps and https
22592282 private String initIlpTransport () {
22602283 StringSink sink = Misc .getThreadLocalSink ();
@@ -4468,6 +4491,11 @@ public int getWalTxnNotificationQueueCapacity() {
44684491 return walTxnNotificationQueueCapacity ;
44694492 }
44704493
4494+ @ Override
4495+ public int getWalWriterMadviseMode () {
4496+ return walWriterMadviseMode ;
4497+ }
4498+
44714499 @ Override
44724500 public int getWalWriterPoolMaxSegments () {
44734501 return walWriterPoolMaxSegments ;
0 commit comments