Skip to content

[fix](filecache) skip redundant ttl scans for non-TTL tablets#65429

Open
freemandealer wants to merge 1 commit into
apache:branch-4.1from
freemandealer:task-branch-4-1-ttl-mgr-update-cpu
Open

[fix](filecache) skip redundant ttl scans for non-TTL tablets#65429
freemandealer wants to merge 1 commit into
apache:branch-4.1from
freemandealer:task-branch-4-1-ttl-mgr-update-cpu

Conversation

@freemandealer

@freemandealer freemandealer commented Jul 9, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary:

The file cache TTL manager keeps registered tablet ids in _tablet_id_set. For ordinary non-TTL tablets, the old ttl_seconds <= 0 path always set need_convert_from_ttl = true, so every update round scanned cached blocks even when the tablet had never been recorded in _ttl_info_map.

This PR reduces the repeated CPU work for registered non-TTL tablets:

  • If a tablet was previously tracked as TTL, it is still converted back to NORMAL immediately when TTL is disabled.
  • If a tablet has no prior TTL info, the manager skips the per-round cached block scan.
  • A low-frequency reconciliation scan is kept every 20 update rounds, so cleanup behavior is preserved while avoiding scans on every round.

With the default file_cache_background_ttl_info_update_interval_ms = 180000, ordinary non-TTL tablets avoid the repeated per-round block scan that previously ran every 3 minutes.

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

Unit test:

DORIS_TOOLCHAIN=clang DISABLE_BE_JAVA_EXTENSIONS=ON ENABLE_INJECTION_POINT=ON ENABLE_CACHE_LOCK_DEBUG=0 ENABLE_PCH=0 sh run-be-ut.sh --run --filter='BlockFileCacheTtlMgrTest.*'

Result: 5 tests passed.

  • Behavior changed:

    • No.
    • Yes. Registered ordinary non-TTL tablets no longer scan cached blocks in every TTL manager update round.
  • 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

@freemandealer freemandealer requested a review from yiguolei as a code owner July 9, 2026 14:02
@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?

@freemandealer

Copy link
Copy Markdown
Member Author

run buildall

@freemandealer

Copy link
Copy Markdown
Member Author

/review

@freemandealer freemandealer changed the title [fix](file cache) skip redundant ttl scans for non-TTL tablets [fix](filecache) skip redundant ttl scans for non-TTL tablets Jul 9, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for one file-cache TTL correctness issue.

Critical checkpoints:

  • Changed files reviewed: be/src/io/cache/block_file_cache_ttl_mgr.cpp and be/test/io/cache/block_file_cache_ttl_mgr_test.cpp, plus relevant cache load and cache-type transition paths.
  • Existing review context: no existing inline review threads or replies were present, so this is not a duplicate.
  • User focus: no additional user-provided review focus.
  • Repo instructions: no AGENTS.md files were listed; a repo-local code-review SKILL.md was not present in the expected paths, so I followed the review prompt and ledger workflow.
  • Subagent conclusions: optimizer-rewrite produced no candidates and was dismissed with evidence; tests-session-config produced main-001, accepted as the inline comment below; convergence round 1 ended with both subagents replying NO_NEW_VALUABLE_FINDINGS for the same ledger/comment set.
  • Validation: static review only. The checkout is grafted and missing the base object for local diff checks, and thirdparty/installed plus thirdparty/installed/bin/protoc are absent, so I did not run BE unit tests.

Comment thread be/src/io/cache/block_file_cache_ttl_mgr.cpp Outdated
@freemandealer freemandealer force-pushed the task-branch-4-1-ttl-mgr-update-cpu branch from 35323a5 to 7ae7df1 Compare July 9, 2026 15:11
@freemandealer

Copy link
Copy Markdown
Member Author

/review

@freemandealer

Copy link
Copy Markdown
Member Author

run buildall

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review result: request changes.

Critical checkpoints:

  • Scope: live PR head 7ae7df1; GitHub reports two changed files: be/src/io/cache/block_file_cache_ttl_mgr.cpp and be/test/io/cache/block_file_cache_ttl_mgr_test.cpp.
  • Existing review context: I considered the existing restart/persisted-TTL thread. The inline comment below is a distinct current-patch follow-up because the new periodic reconcile addresses the old _ttl_info_map gate but still depends on missing tablet-id registration.
  • User focus: no additional user-provided review focus was supplied.
  • Validation: git show --format= --check HEAD -- be/src/io/cache/block_file_cache_ttl_mgr.cpp be/test/io/cache/block_file_cache_ttl_mgr_test.cpp passed. I did not run the BE unit test locally because this grafted checkout is missing thirdparty/installed and thirdparty/installed/bin/protoc; the PR body reports the author's BlockFileCacheTtlMgrTest run.

Subagent conclusions:

  • optimizer-rewrite proposed optimizer-rewrite-001, accepted as inline-001.
  • tests-session-config proposed tests-session-config-001, merged as duplicate/supporting evidence for inline-001 rather than a second comment.
  • Convergence round 1 ended with both live subagents reporting NO_NEW_VALUABLE_FINDINGS for the same final ledger/comment set.

Comment thread be/src/io/cache/block_file_cache_ttl_mgr.cpp
@freemandealer

Copy link
Copy Markdown
Member Author

run beut

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 100.00% (6/6) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 54.78% (20953/38252)
Line Coverage 38.21% (199977/523352)
Region Coverage 34.68% (156981/452697)
Branch Coverage 35.63% (68530/192361)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (6/6) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.81% (27587/37375)
Line Coverage 57.44% (299159/520851)
Region Coverage 55.03% (250798/455783)
Branch Coverage 56.39% (108632/192653)

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