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

   ### Background
   
   For a filtered nullable Parquet column, the native reader maps logical rows 
to physical values and builds the NULL layout of the selected rows. A fused 
path produces both from the same sequence of runs.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: None
   PR Type: Performance
   
   Problem Summary:
   
   Isolated NULLs can split a batch into many runs even when fewer than 10% of 
rows are NULL. The previous density check prevented these batches from using 
the fused path. This change uses the existing run-count threshold for nonempty 
NULL sets.
   
   ### Details
   
   - **Why it was slow:** The fallback builds an intermediate selection vector 
and then reconstructs physical ranges and selected NULL positions. The extra 
work grows with fragmentation.
   - **Optimization:** Remove the density cutoff. Keep the 1,024-row minimum 
and require at least `max(32, num_values / 64)` runs. The reader still checks 
for an active filter and a supported nullable column.
   - **Results:** On Iceberg / Parquet SF10, Q9 and Q28 together saved 530 ms 
of the 604.5 ms total. The other 101 queries combined improved by 0.08%. Times 
are 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.3320 | 98.7275 | +0.61% | — |
     | BE process CPU (CPU-s) | 278.4600 | 275.3000 | +1.13% | — |
     | Q9 | 4.0735 | 3.7680 | +7.50% | 4.0835 → 3.7950 (+7.07%) |
     | Q28 | 3.2845 | 3.0600 | +6.84% | 3.2790 → 3.0445 (+7.15%) |
     | Q36 | 0.4075 | 0.3885 | +4.66% | 0.4095 → 0.3825 (+6.59%) |
     | Q44 | 1.2250 | 1.1920 | +2.69% | 1.2245 → 1.1850 (+3.23%) |
     | Q75 | 1.0900 | 1.0450 | +4.13% | 1.0565 → 1.0525 (+0.38%) |
     | Q79 | 0.7425 | 0.7090 | +4.51% | 0.7045 → 0.6780 (+3.76%) |
     | Q88 | 2.8360 | 2.9265 | -3.19% | 2.8245 → 2.8040 (+0.73%) |
     | Q6 | 0.1295 | 0.1515 | -16.99% | 0.1355 → 0.1530 (-12.92%) |
     | Q10 | 0.2150 | 0.2360 | -9.77% | 0.2305 → 0.2310 (-0.22%) |
     | Q23.1 | 4.7675 | 4.9135 | -3.06% | 4.8055 → 4.7605 (+0.94%) |
     | Q49 | 0.3025 | 0.3205 | -5.95% | 0.3295 → 0.3255 (+1.21%) |
     | Q54 | 0.1955 | 0.2295 | -17.39% | 0.2115 → 0.1940 (+8.27%) |
     | Q89 | 0.2280 | 0.2475 | -8.55% | 0.2380 → 0.2345 (+1.47%) |
     | Q90 | 0.1685 | 0.1905 | -13.06% | 0.1680 → 0.1835 (-9.23%) |
     | Q95 | 0.1865 | 0.2035 | -9.12% | 0.1875 → 0.1945 (-3.73%) |
     | Q99 | 0.2800 | 0.2960 | -5.71% | 0.2990 → 0.2920 (+2.34%) |
   
     50 queries got faster, 51 slower and two tied. The full pass ran the 
patched BE first. We reversed the order for 22 queries including all nine 
slowdowns of at least 100 ms or both 5% and 10 ms. Q6 and Q90 crossed the 
threshold in both passes. During the reverse pass their median latencies grew 
by 17.5 and 15.5 ms. FE planning grew by 10 and 15 ms. The median of per-run 
Total minus Plan was flat on Q6 and rose by 0.5 ms on Q90. These remain latency 
risks. The increases on Q23.1 and Q88 did not repeat.
   
   - **Applicability and cost:** Only fragmented, filtered batches with sparse 
NULLs become eligible. Small batches and batches with few runs retain the 
existing fallback. No new buffers or configuration are required. Fusion can add 
planning overhead for some filter patterns.
   
   ### Testing
   
   - On master, all 133 ASAN tests in `NativeNullableSelectionTest`, 
`NativeNestedSelectionTest` and `ParquetV2NativeDecoderTest` passed. The 
toolchain provides glibc compatibility, so the test build used 
`GLIBC_COMPATIBILITY=OFF`. The tests cover sparse isolated versus clustered 
NULLs, filter offsets, an existing output prefix, logical NULL placement and 
physical ranges.
   - Measured two 4.2 RELEASE AVX2 builds based on `ddecccd2a6c` with the same 
pre-existing sparse dictionary change. Only this selection policy differed. 
Both used one 4-vCPU BE, four pipeline tasks, an 8 GiB query limit, SQL cache 
off, file cache on, the same FE, 24 pinned table snapshots and 103 unmodified 
queries.
   - 102 EXPLAIN outputs were byte-identical. Only runtime filter numbering and 
order differed on Q95. Q97 had slightly different raw scan counts. Excluding 
both yields 0.64% savings. Results matched allowing permutations within ties on 
Q65, Q71 and Q79 and absolute or relative tolerance of 1e-9 on two 
floating-point columns for Q39 and Q39.1.
   
   ### Release note
   
   Filtered Parquet scans can use less CPU on nullable columns with scattered 
NULLs.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: No
   - Pre-submission status: Partially verified: performance was 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]

Reply via email to