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


##########
lucene/core/src/java20/org/apache/lucene/internal/vectorization/PanamaVectorUtilSupport.java:
##########
@@ -77,6 +77,47 @@ final class PanamaVectorUtilSupport implements 
VectorUtilSupport {
         VectorizationProvider.TESTS_FORCE_INTEGER_VECTORS || 
(isAMD64withoutAVX2 == false);
   }
 
+  private static final String MANAGEMENT_FACTORY_CLASS = 
"java.lang.management.ManagementFactory";
+  private static final String HOTSPOT_BEAN_CLASS = 
"com.sun.management.HotSpotDiagnosticMXBean";
+
+  // best effort to see if FMA is fast (this is architecture-independent 
option)
+  private static boolean hasFastFMA() {
+    // on ARM cpus, FMA works fine but is a slight slowdown: don't use it.
+    if (Constants.OS_ARCH.equals("amd64") == false) {
+      return false;
+    }
+    try {
+      final Class<?> beanClazz = Class.forName(HOTSPOT_BEAN_CLASS);
+      // we use reflection for this, because the management factory is not part
+      // of Java 8's compact profile:
+      final Object hotSpotBean =

Review Comment:
   Haha, I know this code from the RamUsage code parts. The comment should 
possibly be updated at both places to mention module system and that it is 
optional there.
   
   This module is declared optional in our module-info: 
https://github.com/apache/lucene/blob/f5776c88449ff16f7347ccbe6e26e5bddd8c94f7/lucene/core/src/java/module-info.java#L26
   
   So basically this code is fine, we do not want to hardcode the module (as it 
is not part of the JDK platform standard). Maybe we should add the "FMA 
enabled" also to the logger message. Should be easy by making the flag pkg 
private and refer to it from the initialization code where the log message is 
printed: 
https://github.com/apache/lucene/blob/f5776c88449ff16f7347ccbe6e26e5bddd8c94f7/lucene/core/src/java20/org/apache/lucene/internal/vectorization/PanamaVectorizationProvider.java#L60-L67
   
   Let's add the same with `PanamaVectorUtilSupport.HAS_FAST_FMA ? "; FMA 
enabled" : ""`
   
   We should maybe add this code to some common class in utils package (like 
`Constants#getVMOption(String name)`). We can create a separate PR for that.



-- 
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