Skip to content

Commit

Permalink
Make merge context always win
Browse files Browse the repository at this point in the history
  • Loading branch information
uschindler committed Mar 22, 2024
1 parent 9ed1da7 commit 242e5e9
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,15 @@ private final MemorySegment[] map(
}

private OptionalInt mapContextToMadvise(IOContext context) {
// Merging always wins and implies sequential access, because kernel is advised to free pages
// after use:
if (context.context == Context.MERGE) {
return OptionalInt.of(NativeAccess.POSIX_MADV_SEQUENTIAL);
}
if (context.randomAccess) {
return OptionalInt.of(NativeAccess.POSIX_MADV_RANDOM);
}
if (context.readOnce || context.context == Context.MERGE) {
if (context.readOnce) {
return OptionalInt.of(NativeAccess.POSIX_MADV_SEQUENTIAL);
}
return OptionalInt.empty();
Expand Down

0 comments on commit 242e5e9

Please sign in to comment.