goankur commented on PR #13572: URL: https://github.com/apache/lucene/pull/13572#issuecomment-2294502514
> also, would be good to compare apples-to-apples here. currently from what i see, benchmark compares `dot8s(MemorySegment..)` vs `BinaryDotProduct(byte[])`. To me this mixes up concerns about memorysegment vs java heap with C vs vector API, so it would be good to resolve for understanding purposes. As I understand, here is the call stack `PanamaVectorUtilSupport.dotProduct(MemorySegment, MemorySegment)` `PanamaVectorUtilSupport.dotProduct(byte[], byte[])` `VectorUtil.dotProduct(byte[], byte[])` `VectorUtilBenchmark.binaryDotProductVector()` So heap allocated `byte[]` gets wrapped into MemorySegment before the dotProduct computation that uses Panama APIs. For strict apples-to-apples comparison, one would wrap the heap-allocated `byte[]` into a MemorySegment and pass it to the native code -- `dot8s(MemorySegment..)` -- but this does not work and throws the following exception ``` Caused by: java.lang.IllegalArgumentException: Heap segment not allowed: MemorySegment{ heapBase: Optional[[B@53a133c5] address:0 limit: 768 } at java.base/jdk.internal.foreign.abi.SharedUtils.unboxSegment(SharedUtils.java:331) at org.apache.lucene.util.VectorUtil.dot8s(VectorUtil.java:217) ... 13 more ``` So I can't think of a good way to make the comparison fairer. Do you have any recommendations ? -- 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