hubgeter opened a new pull request, #71357:
URL: https://github.com/apache/doris/pull/71357

   ### Background
   
   A Parquet scan can filter on one column and then read selected rows from 
other dictionary-encoded columns. The native reader decodes and validates 
dictionary IDs even for the gaps between selected ranges.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: None
   PR Type: Performance
   
   Problem Summary:
   
   When a predicate keeps roughly one row in twenty, repeatedly switching 
between skipping a short gap and decoding one ID makes the scan CPU-intensive. 
Reusing the batch decoder for these patterns cut Doris TPC-DS SF10 Q28 latency 
by about 30% in two comparisons with all six scans in the plan.
   
   ### Details
   
   - **Why it was slow:** The density check excluded sparse selections even 
when the gaps were short. On Q28, selected dictionary value decoding appeared 
in 790 of 2,259 sampled BE stacks before the change and 155 of 2,201 after it.
   - **Optimization:** Both dictionary entry points can now decode and validate 
the batch once, then compact the selected IDs in order. The new case requires 
at least eight ranges, a nonempty selection, at most four selected IDs per 
range on average, more than one range per 32 input IDs and at most 8,192 input 
IDs.
   - **Results:** Doris before and after applying this diff to `ddecccd2a6` 
(4.2.0-rc01). The measurements below are from that build. The port to `master` 
still needs its own benchmark.
   
     Original TPC-DS SF10 SQL on 24 fixed Iceberg snapshots, one four-core BE, 
the same FE, RELEASE AVX2, four pipeline tasks and an 8 GiB query limit. Each 
time is the median of eight hot runs after one warmup. The first comparison ran 
baseline then patch for 103 queries. The repeat ran patch then baseline for 48 
selected queries. Negative changes mean lower elapsed time.
   
     | Query | Before (s) | After (s) | Change | Repeat before (s) | Repeat 
after (s) |
     |---|---:|---:|---:|---:|---:|
     | Q28 | 4.6615 | 3.2855 | −29.5% | 4.6310 | 3.2540 |
     | Q75 | 1.3280 | 1.1165 | −15.9% | 1.3560 | 1.0510 |
     | Q89 | 0.3020 | 0.2430 | −19.5% | 0.2920 | 0.2280 |
     | Q53 | 0.2625 | 0.2120 | −19.2% | 0.2445 | 0.2015 |
     | Q9 | 4.0465 | 4.0535 | +0.2% | 4.0440 | 4.1050 |
     | Q29 | 0.7910 | 0.8100 | +2.4% | 0.7890 | 0.7950 |
     | Q86 | 0.1845 | 0.2010 | +8.9% | 0.1645 | 0.1780 |
     | **Sum of 103 medians** | **105.0785** | **99.2635** | **−5.53%** | — | — 
|
   
     Q28 BE CPU time fell from 17.86 to 12.41 CPU seconds on the first pass. 
Both versions scanned 172,799,529 rows. The full-suite result includes 
variability in Q51 and Q67, whose initial gains largely disappeared on repeat. 
Q9, Q29 and Q86 were slower in both comparisons.
   
   - **Applicability and cost:** The extra case uses up to 32 KiB of active 
scratch per decoder for 32-bit IDs. Retained capacity may be larger. The 
32-value unpack granularity motivates the density heuristic. The 8,192-ID 
cutoff bounds scratch. Both thresholds need more measurements across selection 
patterns and encodings.
   
   ### Testing
   
   - On the 4.2 baseline with this patch, all 142 tests in 
`ParquetV2NativeDecoderTest.*` passed under ASAN. With the original header the 
new test observed 10 and 391 consumer calls where it expected one.
   - The new test covers 192, 8,192 and 8,193 IDs, preserves order through both 
entry points and rejects an invalid ID in a skipped range.
   - All 103 Doris plans matched. Results matched row for row for 98 queries. 
Q65, Q71 and Q79 differed only in order. Q39 and Q39.1 had floating-point 
differences of at most 6e-16.
   - On the master port, the patch ID matches the measured diff. Clang-format 
16, `git diff --check` and `build-support/check-build-hygiene.sh` passed.
   
   ### Release note
   
   Selective filters can reduce CPU time on native Parquet scans when matching 
rows form many short ranges.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: No
   - Pre-submission status: Partially verified: master build, unit tests, 
regression suite and benchmarks are pending. The original clang-tidy run 
crashed in `modernize-use-scoped-lock` and reported an unmatched suppression in 
an existing header.
   
   ### AI Disclosure
   
   - Tool: Codex (GPT-6)
   - Generated: Implementation, unit tests, benchmark harness, analysis and PR 
description
   - Human review: Pending
   


-- 
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]

Reply via email to