Skip to content

Simplify the cache-provider fill-coordination API - #116092

Merged
CheSema merged 5 commits into
masterfrom
simplify-cache-provider-api
Sep 7, 2026
Merged

CheSema merged 5 commits into
masterfrom
simplify-cache-provider-api

Conversation

@CheSema

@CheSema CheSema commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

Extracts the ICacheProvider / CacheWriter API changes from #115816 (the ReadPlan slice) into a standalone refactor, so that pull request carries only the read-plan logic. The experimental use_reader_executor read path (default off) is the only consumer.

  • CacheWriter::committed returns the committed-prefix end as a size_t instead of an IntervalSet (a segment fills append-only, so what is committed is always one contiguous prefix). The disk writer reads the segment's live frontier directly and drops its committed_ranges / committed_mutex bookkeeping.
  • claimLeadRole loses its ByteRange argument and returns just the Claim; the Lead struct is removed. The caller reads the committed prefix via committed.
  • Add CacheWriter::fillsWholeSegment, the writer-level mirror of the existing ICacheProvider::fillsWholeSegment. It has no caller yet on master — Add a maintained ReadPlan to the experimental ReaderExecutor #115816 is its consumer — but it mirrors the provider-level flag, which is likewise not yet consumed.
  • Remove ICacheProvider::populatesOnMiss. A tier that does not populate now emits a writer-less miss from resolve, which the executor already treats as read-from-source-only.

No behavior change.

Related: #115816

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...


Workflow [PR]
Sync PR [sync-upstream/pr/116092]

Version info

  • Merged into: 26.9.1.888 (included in 26.9 and later)

Reshape the CacheWriter / ICacheProvider interface so the read executor
drives fills through a smaller, clearer contract. No behavior change; the
experimental ReaderExecutor read path is the only consumer.

- CacheWriter::committed returns the end of the committed prefix as a
  size_t instead of an IntervalSet. A segment fills append-only, so what
  is committed is always one contiguous prefix; a scalar frontier
  captures it. The disk writer reads the segment's live frontier
  directly, dropping its committed_ranges / committed_mutex bookkeeping.
- claimLeadRole drops its ByteRange argument and returns just the Claim
  (the Lead struct is removed). The caller reads the committed prefix via
  committed and derives the tail itself.
- Add CacheWriter::fillsWholeSegment, the writer-level mirror of the
  existing ICacheProvider::fillsWholeSegment, so a fill target can report
  whether it stores each segment whole or appends incrementally.
- Remove ICacheProvider::populatesOnMiss. A tier that does not populate
  now emits a writer-less miss from resolve instead of carrying a runtime
  flag; the executor already treats a writer-less miss as
  read-from-source-only.
@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9fb1f87]

Summary: ❌

job_name test_name status info comment
Stress test (arm_release) FAIL
Logical error: Unexpected return type from A. Expected B. Got C (STID: 3262-3de5) FAIL cidb

AI Review

Summary

This PR simplifies the ICacheProvider / CacheWriter fill-coordination contract used by the experimental ReaderExecutor read path by collapsing committed state to a single prefix end, renaming the held write token to FillRole, and representing non-populating tiers as writer-less misses. I checked the current ReaderExecutor, DiskCacheProvider, PageCacheProvider, the touched unit tests, and the existing PR discussion, and I did not find a correctness, concurrency, or coverage issue that warrants a review comment.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit 9fb1f87.

Metric Baseline Current Δ
Lines 88.70% 88.70% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 81.10% 81.10% +0.00%

Changed lines: Changed C/C++ lines covered: 145/172 (84.30%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Aug 24, 2026
Defer the whole-segment vs incremental detail to the provider-level
ICacheProvider::fillsWholeSegment doc it mirrors.
@clickhouse-gh

clickhouse-gh Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 9fb1f87cd with master da918ab89 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 35a0d6f0c; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

48 translation units recompiled, 351 s compile time in total, 48 of them have a recent master baseline.

Job report

committed() is always in [range().offset, range().end()]: range().offset
when nothing is committed, range().end() when complete. Make the invariant
explicit in the contract.
Comment thread src/IO/DiskCacheProvider.cpp Resolved
Comment thread src/IO/DiskCacheProvider.cpp Resolved
Comment thread src/IO/ICacheProvider.h Resolved
Comment thread src/IO/PageCacheProvider.cpp Resolved
@kssenii kssenii self-assigned this Aug 31, 2026
…und it

`Claim` promised exclusivity that only the filesystem-cache tier provides. The page
cache elects no downloader: two readers of the same absent block both get a held
role, both fetch, and `PageCache::getOrSet` keeps the first write. Naming that a
claim invited the reader to assume otherwise.

The type answers one question - should this reader fetch the uncommitted part and
write it - and on a coordinating tier additionally carries the downloader role it
won. The docs now lead with that, and state that a non-coordinating tier holds the
role trivially and releases nothing. `claimLeadRole` becomes `takeFillRole`,
`makeClaim` becomes `makeFillRole`.

`committed()` is contractually within `[range().offset, range().end()]`, and both
implementations bound it - the page cache returns one end or the other, the disk
cache clamps - so `complete()` compared with `>=` against a value that cannot
overshoot. It now compares with `==`, stating the invariant instead of hedging
against it.

Two locals in `DiskCacheProvider` said less than they could. `frontier` becomes
`seg_committed_file_end`, naming both the helper's output and the space it is in;
`segmentCommittedEnd` is not the segment's write offset, since it reports
`range().right + 1` for a `DOWNLOADED` segment. `seg_file_hi` becomes `seg_file_end`,
and the `seg_file_lo` / `seg_file_hi` pair in `waitAndRead` becomes `seg_file_begin` /
`seg_file_end`, so an exclusive bound is called `end` throughout, as `ByteRange::end`
already is.

No behaviour change.

Addresses review comments from kssenii on
#116092.
CheSema added a commit that referenced this pull request Aug 31, 2026
Mirrors #116092, whose API changes this
branch carries its own copy of. `Claim` promised exclusivity that only the
filesystem-cache tier provides: the page cache elects no downloader, so two readers
of the same absent block both get a held role, both fetch, and `PageCache::getOrSet`
keeps the first write.

The type answers one question - should this reader fetch the uncommitted part and
write it - and on a coordinating tier additionally carries the downloader role it
won. `claimLeadRole` becomes `takeFillRole`, `makeClaim` becomes `makeFillRole`.

`complete()` compares with `==` rather than `>=`, since `committed()` is bounded by
`range().end()` in both implementations. Two locals in `DiskCacheProvider` gain names
that say the space they are in: `seg_committed_file_end`, and `seg_file_begin` /
`seg_file_end` for the pair in `waitAndRead`.

No behaviour change.
@clickhouse-gh clickhouse-gh Bot added the comp-filesystem-cache Filesystem cache for remote/object storage, page cache, and read caching infrastructure. label Sep 4, 2026
@CheSema
CheSema added this pull request to the merge queue Sep 7, 2026
Merged via the queue into master with commit 60f0a24 Sep 7, 2026
173 of 175 checks passed
@CheSema
CheSema deleted the simplify-cache-provider-api branch September 7, 2026 09:37
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-filesystem-cache Filesystem cache for remote/object storage, page cache, and read caching infrastructure. pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants