mirror of https://github.com/apache/lucene.git
Better detect vector module in non-default setups (e.g., custom module layers) (#12677)
This commit is contained in:
parent
bac4dd28e0
commit
dbda33fb2f
|
@ -168,6 +168,9 @@ Improvements
|
||||||
is too old. It also logs partial vectorization support if old CPU or disabled AVX.
|
is too old. It also logs partial vectorization support if old CPU or disabled AVX.
|
||||||
(Uwe Schindler, Robert Muir)
|
(Uwe Schindler, Robert Muir)
|
||||||
|
|
||||||
|
* GITHUB#12677: Better detect vector module in non-default setups (e.g., custom module layers).
|
||||||
|
(Uwe Schindler)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
---------------------
|
---------------------
|
||||||
* GITHUB#12183: Make TermStates#build concurrent. (Shubham Chaudhary)
|
* GITHUB#12183: Make TermStates#build concurrent. (Shubham Chaudhary)
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.apache.lucene.util.SuppressForbidden;
|
import org.apache.lucene.util.SuppressForbidden;
|
||||||
|
@ -82,11 +83,14 @@ public abstract class VectorizationProvider {
|
||||||
}
|
}
|
||||||
// is the incubator module present and readable (JVM providers may to exclude them or it is
|
// is the incubator module present and readable (JVM providers may to exclude them or it is
|
||||||
// build with jlink)
|
// build with jlink)
|
||||||
if (!vectorModulePresentAndReadable()) {
|
final var vectorMod = lookupVectorModule();
|
||||||
|
if (vectorMod.isEmpty()) {
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"Java vector incubator module is not readable. For optimal vector performance, pass '--add-modules jdk.incubator.vector' to enable Vector API.");
|
"Java vector incubator module is not readable. For optimal vector performance, pass '--add-modules jdk.incubator.vector' to enable Vector API.");
|
||||||
return new DefaultVectorizationProvider();
|
return new DefaultVectorizationProvider();
|
||||||
}
|
}
|
||||||
|
vectorMod.ifPresent(VectorizationProvider.class.getModule()::addReads);
|
||||||
|
// check if client VM
|
||||||
if (!testMode && isClientVM()) {
|
if (!testMode && isClientVM()) {
|
||||||
LOG.warning("C2 compiler is disabled; Java vector incubator API can't be enabled");
|
LOG.warning("C2 compiler is disabled; Java vector incubator API can't be enabled");
|
||||||
return new DefaultVectorizationProvider();
|
return new DefaultVectorizationProvider();
|
||||||
|
@ -120,7 +124,7 @@ public abstract class VectorizationProvider {
|
||||||
} else if (runtimeVersion >= 22) {
|
} else if (runtimeVersion >= 22) {
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"You are running with Java 22 or later. To make full use of the Vector API, please update Apache Lucene.");
|
"You are running with Java 22 or later. To make full use of the Vector API, please update Apache Lucene.");
|
||||||
} else if (vectorModulePresentAndReadable()) {
|
} else if (lookupVectorModule().isPresent()) {
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"Java vector incubator module was enabled by command line flags, but your Java version is too old: "
|
"Java vector incubator module was enabled by command line flags, but your Java version is too old: "
|
||||||
+ runtimeVersion);
|
+ runtimeVersion);
|
||||||
|
@ -128,16 +132,13 @@ public abstract class VectorizationProvider {
|
||||||
return new DefaultVectorizationProvider();
|
return new DefaultVectorizationProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean vectorModulePresentAndReadable() {
|
/**
|
||||||
var opt =
|
* Looks up the vector module from Lucene's {@link ModuleLayer} or the root layer (if unnamed).
|
||||||
ModuleLayer.boot().modules().stream()
|
*/
|
||||||
.filter(m -> m.getName().equals("jdk.incubator.vector"))
|
private static Optional<Module> lookupVectorModule() {
|
||||||
.findFirst();
|
return Optional.ofNullable(VectorizationProvider.class.getModule().getLayer())
|
||||||
if (opt.isPresent()) {
|
.orElse(ModuleLayer.boot())
|
||||||
VectorizationProvider.class.getModule().addReads(opt.get());
|
.findModule("jdk.incubator.vector");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue