rmuir commented on PR #13133:
URL: https://github.com/apache/lucene/pull/13133#issuecomment-1964303622

   Hi, a couple suggestions:
   
   1. Somehow, we need to avoid Vector API code inside the MemorySegment code. 
Just because MemorySegment is available, does not mean Vector API is usable, 
one of them is "preview" and the other is "incubator". For example, user may 
have a recent JVM that supports MemorySegment, which is automatically enabled, 
but not have passed special command-line flags to their JVM to enable incubator 
vector api, hardware may not support vector api, etc.
   2. Need to guard use of vector api with checks, and fall back to scalar 
implementation when vector api would be very slow, see how it is currently 
done: 
https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/internal/vectorization/VectorizationProvider.java
 . There are many checks already there, they should be re-used. Especially for 
integer vectors such as ByteVector operations it is necessary to check e.g. 
that actual AVX is available: 
https://github.com/apache/lucene/blob/main/lucene/core/src/java20/org/apache/lucene/internal/vectorization/PanamaVectorUtilSupport.java#L74-L78
 . These checks prevent code from executing 100x slower, which is unfortunately 
what happens when the stars do not align in hotspot. You can pass 
`-XX:UseAVX=0` to your benchmark to see this slowness in action.
   
   


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