mrkm4ntr opened a new pull request, #14771: URL: https://github.com/apache/lucene/pull/14771
### Description If a filter query in kNN is in query cache, it can be saved as a `BitSetIterator` wrapping a `FixedBitSet`. But we are creating new `FixedBitSet` combined with liveDocs for every query. This is really high cost because it needs to iterate over long BitSet in `applyMask`. Instead of creating new BitSet by iteration, I will create new BitSet implementing only reading methods. By using this, we don't need to iterate over BitSet. We can leverage `intersectionCount` of FixedBitSet that is super fast. This is the flamegraph when I ran filtered kNN queries (k=100, num_candidates=100, term filter that filters out about 50% of documents).  After applying this, `applyMask` disappeared completely.  <!-- 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: 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