[improvement](topn) Add option to skip file cache writes in topn lazy materialization - #65021
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
59e4e37 to
a7efbdf
Compare
|
run buildall |
FE UT Coverage ReportIncrement line coverage |
|
/review |
TPC-H: Total hot run time: 29469 ms |
TPC-DS: Total hot run time: 174136 ms |
ClickBench: Total hot run time: 25.73 s |
|
run buildall |
TPC-H: Total hot run time: 30137 ms |
TPC-DS: Total hot run time: 175443 ms |
ClickBench: Total hot run time: 29.21 s |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
4c09744 to
b50c00f
Compare
Issue Number: None
Related PR: None
Problem Summary: TopN lazy materialization phase 2 may populate file cache while fetching deferred columns. This can pollute cache when the requested ranges are cache misses. Add a cloud-only session switch for the new PMultiGetRequestV2 path so phase-2 reads use cached blocks only when the full range is already downloaded, and otherwise read remote data directly without writing file cache. The change also exposes phase-2 file-cache counters in the MaterializeNode profile and covers row-store and column-store fetch paths.
Added session variable `enable_topn_lazy_mat_phase2_no_write_file_cache` to avoid file-cache writes on TopN lazy materialization phase-2 cache misses.
- Test:
- Unit Test: ./run-be-ut.sh --run --filter=BlockFileCacheTest.get_downloaded_blocks_if_fully_covered_is_read_only:BlockFileCacheTest.cached_remote_file_reader_remote_only_on_miss -j20
- Build: ./build.sh --be --fe --cloud -j100
- Format: build-support/check-format.sh
- Regression test: env -u HTTP_PROXY -u HTTPS_PROXY -u http_proxy -u https_proxy -u ALL_PROXY -u all_proxy ./run-regression-test.sh --run -d cloud_p0/cache/topn_lazy_file_cache -s test_topn_lazy_mat_phase2_no_write_file_cache -g docker -runMode=cloud -dockerSuiteParallel 1
- Behavior changed: Yes. When the new session variable is enabled in cloud mode, TopN lazy materialization phase-2 cache misses read remote data without writing file cache.
- Does this need documentation: No
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: TopN lazy materialization phase 2 exposed only aggregated profile counters, which makes backend-level skew and IO differences hard to identify when phase-2 fetch fans out to multiple backends. Add aggregate rows/segments counters and per-backend rows, segments, and file-cache statistics for the new TopN lazy materialization V2 path. The per-backend values are accumulated in MaterializationSharedState so multiple phase-2 fetch calls in one query are reflected in the final profile.
### Release note
Added per-backend TopN lazy materialization phase-2 profile counters.
### Check List (For Author)
- Test:
- Build: ./build.sh --be --fe --cloud -j100
- Format: build-support/clang-format.sh; build-support/check-format.sh; git diff --check
- Regression test: env -u HTTP_PROXY -u HTTPS_PROXY -u http_proxy -u https_proxy -u ALL_PROXY -u all_proxy ./run-regression-test.sh --run -d cloud_p0/cache/topn_lazy_file_cache -s test_topn_lazy_mat_phase2_no_write_file_cache -g docker -runMode=cloud -dockerSuiteParallel 1
- Behavior changed: Yes. TopN lazy materialization phase-2 profiles now include aggregate row/segment counts and per-backend detail counters.
- Does this need documentation: No
There was a problem hiding this comment.
Automated review follow-up for PR 65021 at head e624b7f9fe98f7db843015f6f50fa71225b03b9b.
I reviewed the prompt-listed 27 changed files and the surrounding TopN lazy materialization, rowid fetch, file-cache, storage reader, session-variable, RPC, and regression-test paths. I found no new non-duplicate inline issue to submit.
Duplicate-suppressed issue: the external-table phase-2 rowid fetch path still not receiving file_cache_remote_only_on_miss is already covered by existing inline thread discussion_r3511078042, so I did not resubmit the same comment.
Critical checkpoint conclusions:
- Goal/test: the PR adds a cloud-only session option to avoid file-cache writes for TopN lazy materialization phase-2 cache misses, with OLAP row-store/non-row-store regression coverage and cache unit coverage. External-table coverage remains the already-commented gap.
- Scope/focus: the PR-scoped files are focused on FE session forwarding, optional RPC fields/stats, file-cache miss policy, rowid fetch propagation, profile counters, and tests.
- Concurrency/lifecycle: no new shared execution state beyond existing per-operator state; the new cache coverage lookup is read-only under the
BlockFileCachemutex and does not create empty cache blocks. - Compatibility: added Thrift/protobuf fields are optional and default false, preserving old behavior for mixed/default paths.
- Parallel paths: internal Doris-format row-store and column-store phase-2 paths pass the policy through
IOContext; the external-table path is the existing reviewed gap. - Testing/validation:
git diff --checkpassed for the prompt-listed files. Build/regression tests were not run becausethirdparty/installed/bin/protocandthirdparty/installedare missing in this runner.
User focus: no additional user-provided focus points.
Subagent conclusions: optimizer-rewrite found no distinct optimizer/rewrite candidate; tests-session-config reported only the duplicate external-table candidate above. Convergence round 1 ended with both subagents returning NO_NEW_VALUABLE_FINDINGS for the same ledger and empty final inline comment set.
|
run nonConcurrent |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
…in lazy materialization (#66414) ### What problem does this PR solve? Issue Number: N/A Related PR: #65021 Problem Summary: Backport #65021 to `branch-4.1`. This adds an option for TopN lazy materialization phase 2 to read remote cache misses without populating File Cache, and exposes the corresponding profile metrics. The cherry-pick conflicts were adapted to the `branch-4.1` layouts: - Keep the existing adjacent-file batching and compile checks in `RowIDFetcher`, while propagating `file_cache_miss_policy` to Doris-format reads. - Keep the single-row `Segment` API and preserve the copied `IOContext` when setting reader type, stats, and cache-miss policy. - Use the `branch-4.1` `VariableMgr.VarAttr` annotation for the new session variable. ### Release note Add `enable_topn_lazy_mat_phase2_no_write_file_cache` to skip File Cache population for remote misses during TopN lazy materialization phase 2. ### Check List (For Author) - Test - [x] Regression test - [x] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason Validation: - `./build.sh --fe -j100` - `./build.sh --be --clean -j100` - `./run-be-ut.sh --run --filter='MaterializationSharedStateTest.*:BlockFileCacheTest.get_downloaded_blocks_if_fully_covered_is_read_only:BlockFileCacheTest.cached_remote_file_reader_remote_only_on_miss:BlockFileCacheTest.fd_cache_remove:BlockFileCacheTest.fd_cache_evict' -j100` (9 tests passed) - `./run-regression-test.sh --run -d cloud_p0/cache/topn_lazy_file_cache -s test_topn_lazy_mat_phase2_no_write_file_cache -g docker -runMode=cloud -dockerSuiteParallel 1` (1 suite passed) - Behavior changed: - [ ] No. - [x] Yes. When enabled, TopN lazy materialization phase 2 serves remote misses without writing the fetched data into File Cache. - Does this need documentation? - [x] No. - [ ] Yes. ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label
## Versions - [x] dev - [x] 4.x - [ ] 3.x - [ ] 2.1 or older (not covered by version/language sync gate) ## Languages - [x] Chinese - [x] English - [ ] Japanese candidate translation needed ## Docs Checklist - [x] Checked by AI - [ ] Test Cases Built - [x] Updated required version and language counterparts, or explained why not - [x] If only one language changed, confirmed whether source/translation counterparts need sync ## Summary - document the `enable_topn_lazy_mat_phase2_no_write_file_cache` session variable in the TOPN optimization guide - explain full local hits versus remote-only cache-miss behavior - clarify that the option applies only to TOPN lazy-materialization phase 2 for Doris internal tables in storage-compute separation mode - add a runnable SQL example, aggregate and per-BE Profile metrics, verification guidance, caveats, and tuning recommendations ## Related changes - apache/doris#65021 - apache/doris#66172 ## Scope Synchronize the current and 4.x TOPN optimization guides in Chinese, English, and Japanese. Versions 3.x and 2.1 are intentionally out of scope because the corresponding code change is available on master and branch-4.0. ## Validation - `git diff --check` - `python3 scripts/check_md_links_single.py <file> --no-external` for all six synchronized pages - front matter JSON, Markdown fence, admonition balance, and cross-version consistency checks
Summary
This PR adds an opt-in session variable for TopN lazy materialization phase-2 file-cache miss handling.
enable_topn_lazy_mat_phase2_no_write_file_cacheMaterializeNodeprofileValidation
./build.sh --be --fe --cloud -j100output/fe/conf/fe_custom.conf, nooutput/be/conf/be_custom.conf, emptyoutput/fe/doris-meta, and emptyoutput/be/storageoutput/fe/conf/fe.conf:enable_debug_points=trueoutput/be/conf/be.conf:enable_debug_points=true,enable_java_support=falsedocker build -f docker/runtime/doris-compose/Dockerfile -t bh-cluster-2 .env -u HTTP_PROXY -u HTTPS_PROXY -u http_proxy -u https_proxy -u ALL_PROXY -u all_proxy ./run-regression-test.sh --run -d cloud_p0/cache/topn_lazy_file_cache -s test_topn_lazy_mat_phase2_no_write_file_cache -g docker -runMode=cloud -dockerSuiteParallel 1All suites successTest 1 suites, failed 0 suites, fatal 0 scripts, skipped 0 scripts./run-be-ut.sh --run --filter=MaterializationSharedStateTest.*:BlockFileCacheTest.get_downloaded_blocks_if_fully_covered_is_read_only:BlockFileCacheTest.cached_remote_file_reader_remote_only_on_miss:BlockFileCacheTest.fd_cache_remove:BlockFileCacheTest.fd_cache_evict -j100PASSED 9 tests