hubgeter opened a new pull request, #71380:
URL: https://github.com/apache/doris/pull/71380
### Background
The native Parquet reader uses definition levels to align logical rows with
stored values. A hybrid RLE stream can mix repeated runs and groups of
bit-packed literals. The decoder already unpacks literals into a fixed-size
buffer.
### What problem does this PR solve?
Issue Number: None
Related PR: None
PR Type: Performance
Problem Summary:
When a run spans many literals, the reader copies one value and checks
decoder state for each level. Scanning the existing buffer for the first
different level reduces this overhead. Across 103 SF10 queries the sum of
median latencies fell by 1.21% and BE process CPU by 2.15%.
### Details
- **Why it was slow:** The old loop repeatedly called `GetLiteralValues(1)`
even for adjacent levels equal to the validated first value.
- **Optimization:** Search the buffered span up to the run limit. Advance
over matches and retain one validated differing level for the next read. Share
first-level handling between single and run reads.
- **Results:** Iceberg / Parquet SF10 on one 4-vCPU BE with four pipeline
tasks and an 8 GiB query memory limit. Latency is median Profile Total in
seconds over eight hot runs after one warmup. Totals sum per-query medians.
Positive savings mean lower cost.
| Workload | Before | After | Savings | Reverse pass (before → after) |
|---|---:|---:|---:|---:|
| 103 queries | 99.1415 | 97.9395 | +1.21% | — |
| BE process CPU (CPU-s) | 278.7500 | 272.7700 | +2.15% | — |
| Q9 | 4.1160 | 3.7370 | +9.21% | 4.0680 → 3.7395 (+8.08%) |
| Q28 | 3.2590 | 3.0570 | +6.20% | 3.2405 → 3.0105 (+7.10%) |
| Q44 | 1.2125 | 1.1380 | +6.14% | 1.2270 → 1.1330 (+7.66%) |
| Q88 | 2.7965 | 2.5825 | +7.65% | 2.8385 → 2.5630 (+9.71%) |
| Q67 | 7.8935 | 7.9420 | -0.61% | — |
| Q6 | 0.1350 | 0.1550 | -14.81% | 0.1395 → 0.1550 (-11.11%) |
| Q45 | 0.1110 | 0.1245 | -12.16% | 0.1150 → 0.1140 (+0.87%) |
| Q53 | 0.1930 | 0.2060 | -6.74% | 0.1940 → 0.1950 (-0.52%) |
| Q54 | 0.2165 | 0.2340 | -8.08% | 0.1990 → 0.2090 (-5.03%) |
| Q61 | 0.1565 | 0.1995 | -27.48% | 0.1795 → 0.1595 (+11.14%) |
| Q62 | 0.1800 | 0.1930 | -7.22% | 0.1860 → 0.1805 (+2.96%) |
| Q95 | 0.1885 | 0.2045 | -8.49% | 0.2175 → 0.1875 (+13.79%) |
| Q33 | 0.3230 | 0.3210 | +0.62% | 0.3080 → 0.3325 (-7.95%) |
| Q86 | 0.1870 | 0.1800 | +3.74% | 0.1605 → 0.1770 (-10.28%) |
60 queries got faster, 43 slower and 0 tied. The full pass ran the patched
BE first. We reversed the order for 17 queries, including every slowdown of at
least 100 ms or both 5% and 10 ms. Q6 and Q54 crossed that threshold in both
passes. In the reverse pass, median FE planning grew by 18.5 ms on Q6 and 11 ms
on Q54, while BE process CPU was flat or lower. Both remain latency risks. Q33
and Q86 crossed the threshold only in the reverse pass. Q67 had the largest
absolute increase in the full pass (+48.5 ms, +0.61%).
- **Applicability and cost:** Only the hybrid RLE cursor changes. Short
alternating runs may gain little. Repeated runs still use arithmetic skips. The
standalone BIT_PACKED path is unchanged. No new allocation or setting is
required.
### Testing
- On master, 156 ASAN tests passed across `ParquetV2NativeDecoderTest`,
`BitRle`, `Rle`, `RlePageTest` and `TestRle`. The toolchain provides glibc
compatibility, so the test build used `GLIBC_COMPATIBILITY=OFF`. Two new cases
cover unpack boundaries, logical limits, rewind, padding, invalid lookahead and
truncated literals.
- The benchmark used two 4.2 RELEASE AVX2 builds based on `ddecccd2a6c` with
the same existing sparse dictionary change. The only difference was this patch.
The FE, original SQL, 24 table snapshots and session settings were fixed. SQL
cache was off and file cache was on.
- 102 EXPLAIN outputs matched byte for byte. Q95 differed only in runtime
filter IDs and listing order. Q97 read 0.36% fewer raw rows. Excluding both
gives a 1.25% latency reduction. Results matched on all runs allowing
permutations within tied sort keys for Q65, Q71 and Q79 and absolute or
relative tolerance of 1e-9 on two floating-point columns for Q39 and Q39.1.
### Release note
Reduce CPU overhead when scanning Parquet columns with runs of matching
definition levels in hybrid RLE data.
### Check List (For Author)
- Behavior changed: No
- Does this need documentation: No
- Pre-submission status: Partially verified: performance measured on 4.2.
Performance on master and the full regression suite remain unverified.
### AI Disclosure
- Tool: Codex (GPT-6)
- Generated: implementation, unit tests, benchmark analysis and PR
description
- Human review: not stated
--
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]