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

   ### Background
   
   Doris estimates an initial scan batch size from per-column raw-byte 
statistics, then adapts it using observed blocks. V3 segments store column 
metadata outside the footer so readers can fetch individual columns lazily.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #62835 (introduced adaptive scan batch sizing)
   PR Type: Performance
   
   Problem Summary:
   
   With adaptive sizing enabled, Segment initialization visits every column's 
metadata before zone-map pruning, including columns that a query never reads. 
Reuse statistics from the column readers already required by the scan, and 
construct the predictor before its first prediction without an eager metadata 
traversal. Most of the diff adds reader-level I/O, first-batch and result 
checks, replacing map-only tests. Configuration defaults and query results 
remain unchanged.
   
   ### Details
   
   - **Change map:** 131 changed production lines (+55/-76) implement 
reader-owned hints, remove eager hint collection and move predictor 
initialization; 872 test/helper lines and 44 generated-output lines cover these 
paths. No documentation, protocol or storage-format changes.
   - **Why it was slow:** Once per Segment initialization, hint collection read 
the entire V3 external metadata region and parsed every column. Normal reader 
construction subsequently fetched the selected metadata again, without reusing 
those parsed objects.
   - **Optimization:** Retain an immutable 64-bit hint in each physical reader, 
including the outer VARIANT reader, and return it through normal iterator 
creation. Accumulate only the ReadSchema Block prefix, excluding 
delete-predicate suffixes and dynamic paths that would duplicate root 
statistics. Initialize the predictor after required readers exist, preserving 
the original row-limit cap and missing-hint fallback.
   - **Results:** A local x86_64 ASAN fixture with 1,024 serialized INT column 
metas, 100 simulated rows and a 14,080-byte external region measured logical 
reads:
   
     | Operation | Before | After |
     |---|---:|---:|
     | Metadata initialization | 1 read / 14,080 bytes | 0 reads / 0 bytes |
     | Subsequent selected-column metadata access | 1 read / 12 bytes | 1 read 
/ 12 bytes |
   
     These are metadata-I/O counts, not query-latency or remote-GET benchmarks. 
Real V3 file checks preserve first-batch sizing and all 8,192 rows across 
repeated and concurrent projections.
   - **Applicability and cost:** Collection requires 
`enable_adaptive_batch_size` (still enabled by default) and a nonzero byte 
budget. Each reader adds one `uint64_t`; the Segment-wide hint map is removed. 
V2 inline metadata remains supported. Footer UID indexing still exists. Cold 
full-column scans may lose the previous eager read's cache warming; Release 
A/B, actual object-storage GET/Range counts, throughput and peak memory remain 
unmeasured.
   
   ### Testing
   
   All runs below were local; the final committed source matches the validated 
files.
   
   - `BUILD_TYPE=ASAN ./build.sh --be --fe -j 32`: BE/FE build and integrated 
Checkstyle passed.
   - Targeted `BUILD_TYPE_UT=ASAN ./run-be-ut.sh --run`: 111 tests across 8 
suites passed, covering metadata reads, pruning, first-batch sizing, V2/V3, 
defaults, complex/VARIANT readers, UID boundaries and concurrent scans.
   - SQL suites `adaptive_segment_meta_v3`, `adaptive_batch_size`, 
`test_variant_external_meta_integration` and 
`test_query_sys_column_data_sizes_variant`: all passed, with no skipped suites.
   - The no-eager-read regression failed on the unchanged base and passes after 
this change. The new SQL output was runner-generated, compared again and 
independently checked for arithmetic and MD5 values.
   - GCC 11 syntax-only compatibility check and the UID-boundary red/green test 
passed; this is not a full GCC BE build.
   - clang-format 16, format checks, build hygiene and committed-diff 
whitespace checks passed.
   
   ### Notes for Reviewers
   
   Physical protobuf UIDs exclude the unsigned invalid sentinel explicitly. 
Defaults and synthetic single-version system values use zero hints; dynamic 
VARIANT paths do not count their root twice. Explicit full-metadata consumers 
and requested-column error propagation remain intact.
   
   ### Release note
   
   V3 scans no longer read unused column metadata solely to estimate the 
adaptive initial batch size.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: No
   - Pre-submission status: Partially verified: full GCC BE build, Release 
performance A/B and isolated object-storage cold-read validation have not run.
   
   ### AI Disclosure
   
   - Tool: Codex
   - Generated: Production changes, tests and this 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