shubhamvishu opened a new pull request, #16977:
URL: https://github.com/apache/lucene/pull/16977

   ### Description
   
   Worked with Claude/AI, with a human in the loop. 
   
   In #16806, we proposed changing the graph builders visited set from a 
`FixedBitSet` to an `IntHashSet` for large graphs, because clearing the bits 
dominated merges into large segments, since the visited set is cleared before 
each search (i.e. adding each node). Queries don't have this same problem: a 
query clears its visited set only twice (once for the entry-point search and 
once for the level 0 search), so maybe we could try using `FixedBitSet` more 
aggressively to get the faster HNSW benefits with some memory tradeoffs. This 
PR doesn't change the graph builders' threshold for choosing between 
`FixedBitSet` and `IntHashSet `(so there are no trade-offs there; its still 
`graphSize / 128`). It only changes it at query time.
   
   For graphs of up to ~2M nodes (1 << 21), a query now uses a `FixedBitSet` 
unless the expected number of visited nodes is less than `graphSize / 2048` 
(instead of earlier `graphSize / 128`). This gets the benefit of faster HNSW 
search without using much memory. Builders stick to the existing `graphSize / 
128` rule.
   
   For graphs above 2^21 nodes nothing changes, and below it a query's 
FixedBitSet is at most 256 KB (deliberately capped - we could tweak if we 
want). 
   
   I was seeing about **10%** faster HNSW searchers on 1M Cohere luceneutil 
benchmarks.  Will share the results soon.
   
   ```
   // Query only
   static VisitedSet createForQuery(int expectedVisitedNodes, int graphSize) {
       return create(expectedVisitedNodes, graphSize, graphSize <= (1 << 21) ? 
11 : 7);
     }
     
    // Builders
    static VisitedSet create(int expectedVisitedNodes, int graphSize) {
       return create(expectedVisitedNodes, graphSize, 7);
     }
   ```
   
   cc - @goankur 
   
   <!--
   If this is your first contribution to Lucene, please make sure you have 
reviewed the contribution guide.
   https://github.com/apache/lucene/blob/main/CONTRIBUTING.md
   -->
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

  • [PR] Use FixedBitSet more aggr... shubhamvishu (via GitHub) via issues

Reply via email to