mirror of https://github.com/apache/lucene.git
Skip madvise calls on tiny inner files of compound files. (#13917)
This commit skips `madvise` calls on inner files of compound files that are smaller than the page size.
This commit is contained in:
parent
5fd45254d3
commit
f69b196ef2
|
@ -570,12 +570,20 @@ abstract class MemorySegmentIndexInput extends IndexInput
|
|||
if (NATIVE_ACCESS.isPresent() && advice != ReadAdvice.NORMAL) {
|
||||
// No need to madvise with a normal advice, since it's the OS' default.
|
||||
final NativeAccess nativeAccess = NATIVE_ACCESS.get();
|
||||
slice.advise(
|
||||
0,
|
||||
slice.length,
|
||||
segment -> {
|
||||
nativeAccess.madvise(segment, advice);
|
||||
});
|
||||
if (length >= nativeAccess.getPageSize()) {
|
||||
// Only set the read advice if the inner file is large enough. Otherwise the cons are likely
|
||||
// outweighing the pros as we're:
|
||||
// - potentially overriding the advice of other files that share the same pages,
|
||||
// - paying the cost of a madvise system call for little value.
|
||||
// We could align inner files with the page size to avoid the first issue, but again the
|
||||
// pros don't clearly overweigh the cons.
|
||||
slice.advise(
|
||||
0,
|
||||
slice.length,
|
||||
segment -> {
|
||||
nativeAccess.madvise(segment, advice);
|
||||
});
|
||||
}
|
||||
}
|
||||
return slice;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue