Skip to content

Commit

Permalink
#13196, #13213: Remove logging relic from 9.x branch and add it to ge…
Browse files Browse the repository at this point in the history
…neral logging on MMapDirectory startup
  • Loading branch information
uschindler committed Mar 26, 2024
1 parent ae5d353 commit a2ca63f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.nio.channels.FileChannel.MapMode;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Locale;
import java.util.Optional;
import java.util.logging.Logger;
import org.apache.lucene.util.Constants;
Expand All @@ -37,9 +38,11 @@ public MemorySegmentIndexInputProvider() {
this.nativeAccess = NativeAccess.getImplementation();
var log = Logger.getLogger(getClass().getName());
log.info(
"Using MemorySegmentIndexInput with Java 21 or later; to disable start with -D"
+ MMapDirectory.ENABLE_MEMORY_SEGMENTS_SYSPROP
+ "=false");
String.format(
Locale.ENGLISH,
"Using MemorySegmentIndexInput%s with Java 21 or later; to disable start with -D%s=false",
nativeAccess.map(n -> " and native madvise support").orElse(""),
MMapDirectory.ENABLE_MEMORY_SEGMENTS_SYSPROP));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,15 @@ static Optional<NativeAccess> getInstance() {
private static MethodHandle lookupMadvise() {
final Linker linker = Linker.nativeLinker();
final SymbolLookup stdlib = linker.defaultLookup();
final MethodHandle mh =
findFunction(
linker,
stdlib,
"posix_madvise",
FunctionDescriptor.of(
ValueLayout.JAVA_INT,
ValueLayout.ADDRESS,
ValueLayout.JAVA_LONG,
ValueLayout.JAVA_INT));
LOG.info("posix_madvise() available on this platform");
return mh;
return findFunction(
linker,
stdlib,
"posix_madvise",
FunctionDescriptor.of(
ValueLayout.JAVA_INT,
ValueLayout.ADDRESS,
ValueLayout.JAVA_LONG,
ValueLayout.JAVA_INT));
}

private static MethodHandle findFunction(
Expand Down

0 comments on commit a2ca63f

Please sign in to comment.