uschindler commented on code in PR #13196:
URL: https://github.com/apache/lucene/pull/13196#discussion_r1535283242


##########
lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInputProvider.java:
##########
@@ -92,10 +110,22 @@ private final MemorySegment[] map(
       }
       if (preload) {
         segment.load();
+      } else if (segSize > 0L && advice.isPresent()) { // not when preloading!
+        nativeAccess.madvise(segment, advice.getAsInt());
       }
       segments[segNr] = segment;
       startOffset += segSize;
     }
     return segments;
   }
+
+  private OptionalInt mapContextToMadvise(IOContext context) {
+    if (context.randomAccess) {
+      return OptionalInt.of(NativeAccess.POSIX_MADV_RANDOM);
+    }
+    if (context.readOnce || context.context == Context.MERGE) {

Review Comment:
   I moved the check for MERGE context to beginning in 
242e5e9064acb70430c9082b82b2258ce75beeb3. This makes it always win. The reason 
for that is: We often set MERGE context, but the other settings keep their 
defaults (like random access). So when merging is first, we always bail out and 
advise kernel: "may be freed soon after they are accessed" 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to