sgup432 commented on code in PR #16715: URL: https://github.com/apache/lucene/pull/16715#discussion_r4125909076
########## lucene/benchmark-jmh/src/java/org/apache/lucene/benchmark/jmh/SparseRequiredMustNotBenchmark.java: ########## @@ -0,0 +1,188 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.lucene.benchmark.jmh; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.concurrent.TimeUnit; +import org.apache.lucene.document.Document; +import org.apache.lucene.document.Field; +import org.apache.lucene.document.LongPoint; +import org.apache.lucene.document.NumericDocValuesField; +import org.apache.lucene.document.StringField; +import org.apache.lucene.index.DirectoryReader; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.index.IndexWriterConfig; +import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanClause.Occur; +import org.apache.lucene.search.BooleanQuery; +import org.apache.lucene.search.IndexOrDocValuesQuery; +import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.TermQuery; +import org.apache.lucene.search.TotalHitCountCollectorManager; +import org.apache.lucene.store.Directory; +import org.apache.lucene.store.MMapDirectory; +import org.apache.lucene.util.IOUtils; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; + +/** + * Compares MUST_NOT execution with sparse required queries. + * + * <p>The term, point and index-or-doc-values required queries match the same document IDs. The + * prohibited index-or-doc-values query matches all documents except one every 128 documents. + */ +@State(Scope.Benchmark) +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@Warmup(iterations = 3, time = 3) +@Measurement(iterations = 5, time = 5) +@Fork( + value = 1, + warmups = 1, + jvmArgsAppend = {"-Xmx4g", "-Xms4g", "-XX:+AlwaysPreTouch"}) +public class SparseRequiredMustNotBenchmark { Review Comment: I think we can probably skip to merge this micro-benchmark, doesn't seem useful beyond this PR. ########## lucene/core/src/java/org/apache/lucene/search/BooleanScorerSupplier.java: ########## @@ -238,11 +238,21 @@ BulkScorer booleanScorer() throws IOException { if (positiveScorer == null) { return null; } + final long positiveScorerCost = positiveScorer.cost(); + // Benchmarks from #16715 show a crossover around 0.3%: sparse required clauses are Review Comment: Maybe rephrase this comment better? Remove the "Benchmarks from #16715 " part and just have the reason as to why we chose 0.3% as our threshold for choosing ExclScorer, and beyond that choose BulkExclScorer. ########## lucene/CHANGES.txt: ########## @@ -529,6 +535,8 @@ Optimizations * GITHUB#16669: Use intoBitSet to speed up ReqExclBulkScorer with dense exclusions. (Ke Wei) +* GITHUB#16715: Use unbounded lead cost for prohibited clauses. (Ke Wei) Review Comment: Now with the recent change, maybe change this to something like "Optimize MUST_NOT scoring based on required-clause selectivity." ? -- 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]
