stevenschlansker opened a new issue, #12026: URL: https://github.com/apache/lucene/issues/12026
### Description I am doing some performance profiling with Java Flight Recorder (if you haven't tried it yet, you should, it's awesome!) and am getting diagnostic warnings about thrown exception counts. In a few minutes long performance test, I see 25,000 instances of CollectionTerminationException thrown from within our search engine. In Java, the general guidance is not to use exceptions as flow control constructs - they are expensive to create (filling in stack trace, although this cost can be partially mitigated) and not particularly efficient to throw. It looks like LeafCollector uses this exception to terminate early, if there are no documents of interest left. Would it be possible, perhaps for Lucene 10, to change this interface to no longer use exceptions for flow control? Examples of alternate patterns include a null return value, a compound return type like a Optional<LeafCollector>, or flipping the control around to `visitLeafCollector(Consumer<LeafCollector>)` which might or might not call the consumer. It might even be possible to adapt the old pattern to the new style transparently to users, through clever default method implementations. -- 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]
