Skip to content

branch-4.0: [improvement](topn) Add option to skip file cache writes in topn lazy materialization - #66172

Open
bobhan1 wants to merge 1 commit into
apache:branch-4.0from
bobhan1:backport/4.0/pr-65021-topn-lazy-file-cache
Open

branch-4.0: [improvement](topn) Add option to skip file cache writes in topn lazy materialization#66172
bobhan1 wants to merge 1 commit into
apache:branch-4.0from
bobhan1:backport/4.0/pr-65021-topn-lazy-file-cache

Conversation

@bobhan1

@bobhan1 bobhan1 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: N/A

Related PR: #65021

Problem Summary:

Backport #65021 to branch-4.0.

This adds the enable_topn_lazy_mat_phase2_no_write_file_cache session variable. When enabled, remote cache misses during the second phase of TopN lazy materialization are read without writing the fetched data into file cache, while existing cache hits continue to be read locally. The backport keeps the branch-4.0 pipeline/segment layout, block type, and file-cache statistics interfaces.

Validation:

  • ./build.sh --be --fe --cloud -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' -j40 (9 tests passed)
  • ./run-regression-test.sh --run -d cloud_p0/cache -s test_topn_lazy_mat_phase2_no_write_file_cache -g docker -runMode=cloud -dockerSuiteParallel 1 -image baohan-doris-regression:pr65021-4.0 (1 suite passed)
  • build-support/clang-format.sh
  • git diff --check

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • 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
  • Behavior changed:

    • No.
    • Yes. Adds an opt-in session variable for skipping file-cache writes during TopN lazy-materialization phase 2.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

… materialization (apache#65021)

This PR adds an opt-in session variable for TopN lazy materialization
phase-2 file-cache miss handling.

- add `enable_topn_lazy_mat_phase2_no_write_file_cache`
- keep the option disabled by default, so existing behavior is unchanged
- when the option is enabled, phase-2 lazy materialization uses
already-downloaded file-cache blocks for full local hits and reads
remote data directly on cache miss without writing the file cache
- expose aggregate and per-BE phase-2 rows, segments, and file-cache
counters in the `MaterializeNode` profile
- accumulate per-BE stats across multiple phase-2 fetch calls
- cover both row-store and column-store fetch paths

- `./build.sh --be --fe --cloud -j100`
- before packaging, verified no `output/fe/conf/fe_custom.conf`, no
`output/be/conf/be_custom.conf`, empty `output/fe/doris-meta`, and empty
`output/be/storage`
- for docker regression image, verified FE/BE debug-point config and BE
Java support config:
  - `output/fe/conf/fe.conf`: `enable_debug_points=true`
- `output/be/conf/be.conf`: `enable_debug_points=true`,
`enable_java_support=false`
- `docker 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 1`
  - `All suites success`
  - `Test 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
-j100`
  - `PASSED 9 tests`

(cherry picked from commit f45888f)
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@bobhan1 bobhan1 changed the title [branch-4.0][improvement](topn) Add option to skip file cache writes in topn lazy materialization branch-4.0: [improvement](topn) Add option to skip file cache writes in topn lazy materialization Jul 28, 2026
@bobhan1
bobhan1 marked this pull request as ready for review July 28, 2026 11:24
@bobhan1
bobhan1 requested a review from morningman as a code owner July 28, 2026 11:24
@bobhan1

bobhan1 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 78.60% (1858/2364)
Line Coverage 65.34% (33269/50918)
Region Coverage 65.76% (16434/24989)
Branch Coverage 56.40% (8774/15558)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 100.00% (2/2) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 87.22% (355/407) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.61% (25653/35825)
Line Coverage 54.54% (272545/499733)
Region Coverage 52.03% (225659/433670)
Branch Coverage 53.49% (97190/181690)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants