sgup432 commented on code in PR #15124:
URL: https://github.com/apache/lucene/pull/15124#discussion_r2364661528
##########
lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java:
##########
@@ -649,15 +680,23 @@ public Query rewrite(IndexSearcher indexSearcher) throws
IOException {
@Override
public void visit(QueryVisitor visitor) {
QueryVisitor sub = visitor.getSubVisitor(Occur.MUST, this);
- for (BooleanClause.Occur occur : clauseSets.keySet()) {
+ for (Occur occur : Occur.cachedValues()) {
Review Comment:
So even doing `clauseSets.forEach()` will create a iterator for the first
time(as can be seen in the code and profile below)
With this change, the ops/s dropped to 2M compared to the change as part of
this PR (which was 3M)
```
Benchmark Mode Cnt Score Error
Units
QueryCacheBenchmark.concurrentPutOnly thrpt 9 2179508.622 ± 117501.478
ops/s
```
In my case, because I am frequently calling `visit()` and subsequently
`forEach()`, it allocates many of these for different boolean queries showing
some impact in the micro benchmark. Also I start profiling after creating these
boolean queries
<img width="1179" height="110" alt="Screenshot 2025-09-19 at 2 55 50 PM"
src="https://github.com/user-attachments/assets/c9f26a6e-7093-4b94-a925-15476edd69c1"
/>
--
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]