goankur commented on code in PR #13572:
URL: https://github.com/apache/lucene/pull/13572#discussion_r1819694503


##########
lucene/core/src/java21/org/apache/lucene/internal/vectorization/Lucene99MemorySegmentByteVectorScorer.java:
##########
@@ -34,6 +37,8 @@ abstract sealed class Lucene99MemorySegmentByteVectorScorer
   final MemorySegmentAccessInput input;
   final MemorySegment query;
   byte[] scratch;
+  MemorySegment offHeapScratch;

Review Comment:
   > I'm concerned about the cost of creating these for every scorer() we 
create because that happens a lot.
   
   The `offHeapScratch` is only allocated in the rare case of vector data being 
split across multiple MemorySegments each representing a mmap region.
   
   > Hmm now I see we did do that! But then I wonder why we also need to do it 
here.
   
   When creating a `RandomVectorScorer()` for the give `byte[]` of query, we 
will need to copy these bytes to an off-heap for consumption within native 
dot-product. Native code can only work with memory that is outside the 
management of Java GC.
   
   In the next revision, I am going to refactor some of these and add 
documentation to hopefully make this more clear.
   



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