Skip to content

Implement readBigAt in fs cache read buffer to allow parallelized read (for remote table engines/functions) - #71781

Merged
kssenii merged 62 commits into
masterfrom
support-read-big-at-for-cached-read-buffer
Feb 17, 2026
Merged

kssenii merged 62 commits into
masterfrom
support-read-big-at-for-cached-read-buffer

Conversation

@kssenii

@kssenii kssenii commented Nov 11, 2024 •

Copy link
Copy Markdown
Member

Linked issues

Changelog category (leave one):

  • Improvement

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

Implement readBigAt in fs cache read buffer to allow parallelized read (for remote table engines/functions).

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/

CI Settings (Only check the boxes if you know what you are doing):

  • Allow: All Required Checks
  • Allow: Stateless tests
  • Allow: Stateful tests
  • Allow: Integration Tests
  • Allow: Performance tests
  • Allow: All Builds
  • Allow: batch 1, 2 for multi-batch jobs
  • Allow: batch 3, 4, 5, 6 for multi-batch jobs

  • Exclude: Style check
  • Exclude: Fast test
  • Exclude: All with ASAN
  • Exclude: All with TSAN, MSAN, UBSAN, Coverage
  • Exclude: All with aarch64, release, debug

  • Run only fuzzers related jobs (libFuzzer fuzzers, AST fuzzers, etc.)
  • Exclude: AST fuzzers

  • Do not test
  • Woolen Wolfdog
  • Upload binaries for special builds
  • Disable merge-commit
  • Disable CI cache

Version info

  • Merged into: 26.2.1.844

@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-improvement Pull request with some product improvements label Nov 11, 2024
@robot-clickhouse-ci-1

This comment was marked as outdated.

@antonio2368 antonio2368 self-assigned this Nov 12, 2024
@clickhouse-gh

clickhouse-gh Bot commented Feb 4, 2025

Copy link
Copy Markdown
Contributor

Dear @kssenii, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

@clickhouse-gh

clickhouse-gh Bot commented Mar 11, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e2e87ca]

@kssenii
kssenii force-pushed the support-read-big-at-for-cached-read-buffer branch from 3eae663 to e2e87ca Compare May 1, 2025 10:28
@clickhouse-gh

clickhouse-gh Bot commented Jul 1, 2025

Copy link
Copy Markdown
Contributor

Dear @kssenii, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

1 similar comment
@clickhouse-gh

clickhouse-gh Bot commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

Dear @kssenii, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

@clickhouse-gh

clickhouse-gh Bot commented Nov 24, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [03c1801]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_tsan, 3/6) failure
test_refreshable_mv/test.py::test_refresh_vs_shutdown_smoke FAIL cidb, issue ISSUE EXISTS
test_refreshable_mv/test.py::test_pause FAIL cidb, issue ISSUE EXISTS
Integration tests (amd_msan, 3/6) failure
test_refreshable_mv/test.py::test_refresh_vs_shutdown_smoke FAIL cidb, issue ISSUE EXISTS
test_refreshable_mv/test.py::test_pause FAIL cidb, issue ISSUE EXISTS
test_refreshable_mv/test.py::test_adding_replica FAIL cidb IGNORED
test_refreshable_mv/test.py::test_replicated_db_startup_race FAIL cidb IGNORED
BuzzHouse (arm_asan) failure
Segmentation fault (STID: 1717-4a03) FAIL cidb, issue ISSUE EXISTS
Stateless tests (arm_asan, targeted) error IGNORED

@kssenii
kssenii requested a review from Copilot November 25, 2025 13:31

Copilot AI 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.

Pull request overview

This PR implements the readBigAt method in the filesystem cache read buffer to enable parallelized reads for remote table engines and functions. The implementation allows reading data from arbitrary offsets without affecting the sequential read state.

Key Changes

  • Added readBigAt override method supporting parallel reads from arbitrary file offsets
  • Refactored internal state management by extracting ReadInfo and ReadFromFileSegmentState structs
  • Converted instance methods to static methods where possible to enable state-independent operations
  • Added NONE enum value to ReadType for uninitialized state tracking

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
src/Disks/IO/CachedOnDiskReadBufferFromFile.h Declares readBigAt method, introduces ReadInfo struct, and converts member variables to support independent read operations
src/Disks/IO/CachedOnDiskReadBufferFromFile.cpp Implements readBigAt with isolated state, refactors existing methods to use new state structures, and adds static helper methods
src/Interpreters/Cache/FileSegment.cpp Minor formatting change to improve readability of conditional expression

@kssenii

kssenii commented Jan 28, 2026

Copy link
Copy Markdown
Member Author

P.S.

Failure of test_storage_delta/test.py::test_partition_columns in targeted check is because of a known issue with delta package which happens in flaky/targeted check only:

File: /usr/local/lib/python3.10/dist-packages/deltalake/table.py:420 - in __init__
    self._table = RawDeltaTable(
E   OSError: Generic S3 error: Error after 10 retries in 4.068396089s, max_retries:10, retry_timeout:180s, source:error sending request for url (http://172.16.3.7:9001/root/test_partition_columnscpX0BvPfKz/_delta_log/00000000000000000058.json)

@kssenii
kssenii requested a review from antonio2368 January 28, 2026 14:37
@alexey-milovidov

Copy link
Copy Markdown
Member

Please merge ASAP.

context_->getFilesystemReadPrefetchesLog());

if (use_prefetch)
if (use_prefetch && !impl->supportsReadAt())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why don't we return early like for if (!use_async_buffer) in case impl->supportsReadAt() is true?
What's the point of async buffer if we don't do prefetches here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

See comment

/// FIXME: Use async buffer if use_cache,
/// because CachedOnDiskReadBufferFromFile does not work as an independent buffer currently.
bool use_async_buffer = use_prefetch || use_filesystem_cache || use_distributed_cache;

Actually CachedOnDiskReadBufferFromFile does work without async wrapper (it was removed before but moved back under async wrapper as a blind fix for logical error), but I can change this condition in a separate PR.

Co-authored-by: Antonio Andelic <[email protected]>
@kssenii
kssenii requested a review from antonio2368 February 17, 2026 14:08
@kssenii
kssenii enabled auto-merge February 17, 2026 15:29
@kssenii
kssenii added this pull request to the merge queue Feb 17, 2026
Merged via the queue into master with commit 5e32389 Feb 17, 2026
139 of 143 checks passed
@kssenii
kssenii deleted the support-read-big-at-for-cached-read-buffer branch February 17, 2026 15:47
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 17, 2026
@watson-ch

watson-ch Bot commented May 19, 2026

Copy link
Copy Markdown

Backport labels have been automatically added based on https://github.com/ClickHouse/clickhouse-core-incidents/issues/1711

Labels added:

  • v25.12-must-backport

These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels.

@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label May 19, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jun 10, 2026
pull Bot pushed a commit to erickirt/ClickHouse that referenced this pull request Jul 2, 2026
…ions

The s3()/object-storage table-function read path skipped the small-object
initial prefetch whenever the read buffer supported readBigAt, because the
prefetch was gated on `!impl->supportsReadAt()`. After ClickHouse#71781 added readBigAt
to the fs-cache buffer, reads of many tiny files became synchronous and
latency-bound (e.g. low-concurrency s3() ingestion of lots of small files).

readBigAt/parallel reading only helps large objects; `use_prefetch` already
implies the object is small, so restore the prefetch for that case.

Adds a stateless regression test.
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ions

The s3()/object-storage table-function read path skipped the small-object
initial prefetch whenever the read buffer supported readBigAt, because the
prefetch was gated on `!impl->supportsReadAt()`. After ClickHouse#71781 added readBigAt
to the fs-cache buffer, reads of many tiny files became synchronous and
latency-bound (e.g. low-concurrency s3() ingestion of lots of small files).

readBigAt/parallel reading only helps large objects; `use_prefetch` already
implies the object is small, so restore the prefetch for that case.

Adds a stateless regression test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-improvement Pull request with some product improvements pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v25.12-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants