airborne12 commented on code in PR #67538: URL: https://github.com/apache/doris/pull/67538#discussion_r4002853406
########## regression-test/suites/inverted_index_p0/gram/test_gram_stop_gram.groovy: ########## @@ -0,0 +1,245 @@ +// 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. + +import org.apache.doris.regression.action.ProfileAction + +import java.util.regex.Pattern + +// stop-gram end to end: an index built with the posting lists of very common grams dropped +// must still answer LIKE/REGEXP exactly, and must actually have dropped them. +// +// A dropped gram matches every document, so it can only ever widen the candidate set the +// index proposes, and the predicate is re-evaluated on those candidates. The observable +// contract is therefore equality: every pattern must return exactly what a full scan +// returns. The rows below are built so that the common grams really are common -- a shared +// prefix on every row -- while the patterns being searched for are rare, which is the shape +// where dropping matters. +// +// There is no switch to turn the feature off, so the control arm is the row floor instead: +// a segment under kHighDfDigestDivisor (2000) rows never drops a posting. The same 4000 rows +// are therefore loaded twice, once as a single segment (dropping active, threshold +// 4000 / 2000 * 3 = df 6) and once as five segments of 800 (dropping inactive, every +// posting kept). The two tables must agree on every answer, and the single-segment index +// must be much smaller -- that difference is the dropped postings, and it also pins that +// the floor holds. +suite("test_gram_stop_gram", "p0") { Review Comment: Confirmed, and fixed in e2c741c645f by removing the phase. It could not have caught anything. `exceeds_candidate_budget` reads `gram_index_max_candidate_ratio_bp` only when the segment has no digest budget -- a positive budget returns before the ratio is consulted -- and even then not below `gram_index_candidate_ratio_min_rows` (65,536 rows). This suite's 4,000-row segment carries a digest, so zeroing the ratio changed neither the answers nor any gate decision, while it did change a cluster-wide BE setting from the parallel pool and wrote back a fixed 15. The phase, the `set_be_config` helper and the restore in `finally` are gone, so the suite no longer touches BE configuration. The straddling-pattern profile assertions stay: they are the part that reaches the dropped-posting path (a handful of candidates, thousands of rows pruned, no gate give-up). The suite passes on the bench build. ########## be/benchmark/README_gram_extractor.md: ########## @@ -0,0 +1,55 @@ +# Gram extraction benchmark + +`GramExtraction` measures the real `GramExtractor::extract` implementation, including +ASCII folding, boundary selection, per-row deduplication and allocations. It is not a +benchmark of complete token streams, index construction, or SQL queries. + +## Build and run + +Set `BUILD_TYPE=RELEASE` in the local `custom_env.sh` for this performance build, then +use the standard build entry point: + +```bash +./build.sh --benchmark -j "$(nproc)" +./output/be/lib/benchmark_test \ + --benchmark_filter='GramExtraction/' \ + --benchmark_min_time=0.3s \ + --benchmark_repetitions=7 \ + --benchmark_out=gram-extraction.json \ + --benchmark_out_format=json +``` + +On Linux, make the build's `libjvm.so` discoverable through `LD_LIBRARY_PATH` if +needed. Keep correctness tests in the normal ASAN build; do not compare an ASAN +timing with a RELEASE timing. + +## Matrix + +| Argument | Values | +| --- | --- | +| `bytes` | 128, 4096, 65536, 1048576 | +| `sparse` | 0: dense; 1: sparse | +| `lower_case` | 0: preserve ASCII case; 1: fold ASCII case | +| `corpus` | 0: deterministic diverse ASCII; 1: repeated ASCII log; 2: mixed UTF-8 log | +| `fresh` | 1: construct/destroy extractor and output vector per row; 0: reuse both | + +Other parameters use `GramScheme` defaults: minimum length 3, maximum length 16, Review Comment: Confirmed, and fixed in bcfb213c01b. `GramScheme::max_len` defaults to 4 (gram_scheme.h), not 16, and the index writers reuse one tokenizer and its buffers across rows -- the SNII writer keeps a single `GramTokenizer` -- so `fresh=1` no longer matches any production lifetime. The benchmark comment now calls `fresh=0` the writer-like case and `fresh=1` a synthetic measure of per-row construction and allocation, and refers to gram_scheme.h for the remaining defaults instead of restating values that drift. No other benchmark under be/benchmark carries a README, so `README_gram_extractor.md` is removed rather than kept in sync. -- 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]
