Skip to content

Disable 1MB Head prefetch for small random access files (Parquet) - #115681

Merged
grantholly-clickhouse merged 16 commits into
ClickHouse:masterfrom
UnamedRus:object-storage-random-access-prefetch-gating
Oct 1, 2026
Merged

grantholly-clickhouse merged 16 commits into
ClickHouse:masterfrom
UnamedRus:object-storage-random-access-prefetch-gating

Conversation

@UnamedRus

@UnamedRus UnamedRus commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

ClickHouse have an throughput optimization.
If object is small (<20MB), there is 1MB prefetch of object beginning.
But there are formats, (Parquet specifically), which are being read from footer.
And quite commonly, you don't even need to read rest of object, if statistics in footer says so.
So, making prefetch of first 1MB, if it doesn't cover footer as well (whole file <1MB) is not helpful.

The read-ahead is dropped only while the reader actually reads at arbitrary offsets. With
input_format_allow_seeks = 0 the reader must not seek and reads the object sequentially from the
start instead, which is exactly what the read-ahead serves, so the hint follows the setting and not
just the format's capability.

That setting never reached the Parquet v3 reader. Parquet::ReadOptions::seekable_read predates
the embedded ReadOptions::format: the reader was written with a flat mirror of every knob it
needed, and when that mirror was replaced by a FormatSettings member, every other flag was moved
onto options.format.* because each had assignment sites to rewrite. seekable_read had none -
nothing ever assigned it - so it survived as a field that only Prefetcher read and nobody wrote,
shadowing options.format.seekable_read with a default of true. Prefetcher now reads the format
setting and the shadowing field is gone, so input_format_allow_seeks = 0 reads the whole object
sequentially, as it does for the other formats.

This also makes input_format_allow_seeks effective on the bucket-splitter footer read, raised in
review of #115686 (comment)

Related: #115686

Changelog category (leave one):

  • Performance Improvement

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

Avoid a redundant object-storage GET request when reading random-access formats from object storage. The generic from-start read-ahead is no longer issued for files larger than a single read buffer, where it could not reach the footer. Also, input_format_allow_seeks = 0 is now honored by the Parquet reader, which previously seeked regardless of the setting: with seeks disabled the whole object is read sequentially instead, which can raise memory usage for queries that set it.


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

Version info

  • Merged into: 26.10.1.1223-master (included in 26.10 and later)

…prefetch

`createReadBuffer` eagerly prefetches the head of "small" objects. That
heuristic was added for many-small-files streaming formats (CSV/JSON), where
reading starts at the beginning of the file, so a from-start read-ahead is
exactly what gets consumed.

Column-oriented random-access formats (Parquet/ORC/Arrow) instead read the
`FileMetaData` footer at the *tail* first and drive their own prefetcher. For an
object bigger than the prefetch read the from-start prefetch cannot cover the
footer, so the footer read misses it and issues a separate, mis-ordered object
read (`S3GetObject`) - and when the query never touches the prefetched prefix
the read is wasted outright.

Gate the eager prefetch on the consumer's access pattern. Streaming formats keep
the previous `2 * max_download_buffer_size` window, so the original small-files
optimization is unchanged. Random-access formats prefetch only when the whole
object fits a single read buffer (`buffer_size`, i.e. the actual number of bytes
the prefetch reads) - then it degenerates to one whole-file read the format
serves entirely from memory, footer included. Above that, reading is left to the
format's own tail-first prefetcher.

`FormatFactory::checkIfFormatIsRandomAccessInput` reports whether a format is
registered via `registerRandomAccessInputFormat[WithMetadata]`. The caller sets
the result on `RemoteFSReadSettings::random_access` - a format-agnostic
access-pattern hint that rides the `ReadSettings` already passed to
`createReadBuffer`, rather than a positional flag on the generic factory - and
the gate reads it back off the effective settings.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thevar1able thevar1able added the can be tested Allows running workflows for external contributors label Aug 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bcad5a5]

Summary: ✅


AI Review

Summary

This PR suppresses the generic object-storage head prefetch for footer-first readers and fixes input_format_allow_seeks propagation into the Parquet v3 path and several data-lake readers. The current implementation still leaves important footer-first paths on the old behavior, so the advertised “random-access formats from object storage” contract is not met yet.

Findings

⚠️ Majors

  • [src/Formats/FormatFactory.cpp:1160-1169] checkIfFormatIsRandomAccessInput still equates “registered via registerRandomAccessInputFormat*” with “will read the remote object footer-first”. That misses Arrow file mode and Puffin / PuffinMetadata, even though their readers explicitly take a seekable-footer path and otherwise buffer the whole file (src/Processors/Formats/Impl/ArrowIPC/ArrowIPCBlockInputFormat.cpp:495-505,1286-1303, src/Processors/Formats/Impl/PuffinBlockInputFormat.cpp:480-492,999-1047). Large s3(..., Arrow) / s3(..., Puffin*) reads therefore still issue the redundant head GET this PR claims to remove. Suggested fix: make the hint reflect the actual access pattern (for example an explicit format capability), not the FormatFactory registration overload.
  • [src/Formats/FormatFactory.cpp:1160-1169] The new hint is computed before outer compression is considered, so *.parquet.gz, *.orc.zst, and *.arrow.gz still get marked random_access = true. After wrapReadBufferWithCompressionMethod, the reader only sees a CompressedReadBufferWrapper, not a SeekableReadBuffer (src/IO/CompressedReadBufferWrapper.h:9-34), so the downstream readers all fall back to sequential / whole-file paths (src/Processors/Formats/Impl/Parquet/Prefetcher.cpp:55-85, src/Processors/Formats/Impl/NativeORCBlockInputFormat.cpp:157-165, src/Processors/Formats/Impl/ArrowIPC/ArrowIPCBlockInputFormat.cpp:495-505). In those cases the suppressed from-start prefetch is exactly what the reader will consume. Suggested fix: fold outer compression, or the final wrapped buffer’s actual seekability, into the random_access decision.
  • [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/115681#discussion_r3829843277] [src/Storages/ObjectStorage/ReadBufferIterator.cpp:151-163,283-296; src/Storages/ObjectStorage/IObjectIterator.cpp:168-170] The schema-inference / recreate and bucket-splitter paths still open remote files through bare createReadBuffer(...) calls, so large footer-first files continue to take the redundant head prefetch outside the main scan path. I still consider this real because the current code never threads the new hint through those helpers, and the added stateless test intentionally passes an explicit schema and never exercises splitToBuckets, so it cannot catch the gap.
Tests
  • ⚠️ Coverage is still incomplete for the remaining contract surface: the new tests cover uncompressed Parquet on the main scan path (plus the DeltaLake checkpoint regression), but they do not exercise schema inference, bucket splitting, Arrow / Puffin, or compressed remote random-access files.
Final Verdict

⚠️ Request changes. The main Parquet path is improved, but the capability detection is still too narrow to justify the broader performance contract stated in the PR body and changelog.

LLVM Coverage Report

Measured on commit bcad5a5.

Metric Baseline Current Δ
Lines 88.10% 88.10% +0.00%
Functions 91.70% 91.70% +0.00%
Branches 79.40% 79.40% +0.00%

Changed lines: Changed C/C++ lines covered: 73/74 (98.65%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Aug 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing bcad5a554 with master edb945259 (stripped binary size, per-symbol sizes and ThinLTO time; 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

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

Job report

@clickhouse-gh

clickhouse-gh Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 38 queries analysed

Release-transition baseline: compared against the most recent available 26.9 masters at or before the trusted base-commit anchor because no 26.10 master baseline exists there.

no significant changes detected. K_source=6 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: bc9b763a-ed8c-4702-bc8e-df35a2288a37
  • MIRAI run: 94d5750a-8486-439b-bd97-536d5b3ebc2b
  • PR check IDs:
    • clickbench_1497862_1790170910
    • clickbench_1497868_1790170910
    • clickbench_1497874_1790170910
    • tpch_adapted_1_official_1497885_1790170910
    • tpch_adapted_1_official_1497897_1790170910
    • tpch_adapted_1_official_1497932_1790170910

UnamedRus and others added 2 commits August 21, 2026 13:56
Proves the targeted extra object-storage request disappears. Reads a >1-read-buffer
Parquet object from S3 (MinIO) with a predicate that prunes every row group by
footer statistics - so the query answers from the footer alone, reading no data
pages - and asserts ProfileEvents['RemoteFSPrefetches']:
  - big object   (> one read buffer)  -> from-start prefetch suppressed -> 0
  - small object (<= one read buffer) -> whole-file prefetch still fires -> >= 1

The schema is passed explicitly so the schema-inference open does not add its own
prefetch. max_download_buffer_size is kept large so the big object sits in the band
where the old heuristic WOULD have prefetched, making RemoteFSPrefetches = 0 a
proof of the gate rather than of the object being too large for any prefetch.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…quet reads

The from-start prefetch gate previously only applied to the main object-storage
scan path. Iceberg and Delta Lake read Parquet files (delete files, checkpoints,
compaction sources) through their own createReadBuffer calls, which bypassed the
hint and kept issuing the wasted from-start prefetch.

Set remote_fs_settings.random_access at those call sites:
- Iceberg position deletes (always Parquet) and the Delta checkpoint -> true.
- Iceberg equality deletes and compaction data files (may be Parquet/ORC/Avro) ->
  FormatFactory::checkIfFormatIsRandomAccessInput on the file's own format, so only
  the random-access formats skip the prefetch while sequential ones keep it.

Metadata/manifest reads (Avro/JSON) are left untouched - the prefetch is useful
for them.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 21, 2026
The skip counter is incremented immediately before the early return, so counting
it alone does not prove the workers stopped: an implementation that counted a
worker and then fuzzed it anyway would satisfy every positive skip assertion,
and a fuzzed query that fails is caught rather than surfaced.

Adds worker_fuzz_not_executed, bounding the attempted-query counter across the
distributed statement so only the initiator's own rounds are attempted. Measured
on the parallel replicas arm, 14 runs per binary: with the skip the delta is 5
every time, which is ast_fuzzer_runs for the initiator alone; without it the
delta is 20 to 95, because each of the three workers fuzzes on top. The asserted
range is 1 to 10, which leaves room for another runner's fuzzed statement on a
shared server while staying far below the workers' own contribution.

Verified by mutation, which is what motivated the assertion. Keeping the counter
increment and deleting only the return gives a binary that fails the test 8 times
out of 8, and the new row is the only one that catches it: the four skip rows all
read 1 on that mutant. Restoring the return reproduces the reviewed binary
bit-for-bit, build id 2452249125c3527d, on which the test passes 12 of 12 and the
pristine base 0bb58b932d77d4c3 fails 8 of 8. Pins 04649, 04494, 04344 and the
sibling fuzzer test 04305 are 3 of 3 each, unmodified.

Reported by CI on
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115681&sha=858261cb4bb9e68db7eeed82dba277592650339f&name_0=PR&name_1=Stress%20test%20%28arm_tsan%29
carried by ClickHouse#115681, which is an
unrelated pull request that happened to run the check.
Related: ClickHouse#113729
@clickhouse-gh clickhouse-gh Bot added the comp-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. label Sep 4, 2026
The gate added here keys the from-start read-ahead off the format alone:
`Parquet` reads its footer at the tail, so the read-ahead is dropped. That
premise only holds while the reader is allowed to seek. With
`input_format_allow_seeks = 0` the reader is supposed to read the object
sequentially from the start, which is exactly what the read-ahead serves, so
gating it off there is a pessimization.

The setting never reached the v3 reader either: `Parquet::ReadOptions::seekable_read`
is read by `Prefetcher` but `convertReadOptions` never assigned it, so the v3
reader seeked regardless of `input_format_allow_seeks`. Wire the flag through and
`AND` the prefetch hint with it, so one notion of "this reader seeks" drives both
the read-ahead gate and the reader itself.

This also makes `input_format_allow_seeks` effective on the bucket-splitter path
that reads the footer through `Prefetcher`, raised in review of
ClickHouse#115686 (comment)

Extend `05024_parquet_s3_no_footer_prefetch` with the seeks-disabled case: the
same big object must still get the from-start prefetch.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
bool FormatFactory::checkIfFormatIsRandomAccessInput(const String & name) const
{
const auto & target = getCreators(name);
return target.random_access_input_creator || target.random_access_input_creator_with_metadata;

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.

StorageObjectStorageSource::createReader now relies on this helper as the generic "footer-first reader" probe, but this implementation only sees formats registered through registerRandomAccessInputFormat*. Arrow file mode and Puffin / PuffinMetadata still do tail/footer reads when input_format_allow_seeks=1 while being registered via plain registerInputFormat, so s3(..., Arrow) and s3(..., Puffin) still leave remote_fs_settings.random_access = false and keep the redundant from-start GET on large files. The capability needs to reflect the actual access pattern, not the factory overload that built the format.

UnamedRus and others added 5 commits September 7, 2026 13:32
…t settings

`Parquet::ReadOptions::seekable_read` predates `ReadOptions::format`: the v3
reader was written with a flat mirror of every knob it needed
(`24f54174aba`), and `09866079a69` replaced that mirror with an embedded
`FormatSettings`, moving every consumer onto `options.format.*`. Each mirror
flag had assignment sites that had to be rewritten, so the cleanup walked
them; `seekable_read` had none - nothing ever assigned it, from the reader's
first commit onwards - so it survived as a field that only `Prefetcher` read
and nobody wrote, shadowing the correct `options.format.seekable_read` with a
default of `true`.

Read `options.format.seekable_read` in `Prefetcher` and delete the field, so
there is one notion of "this reader may seek" instead of a copy that the next
`ReadOptions` builder can forget again. `min_bytes_for_seek` and
`bytes_per_read_task` stay top-level: they come from `ReadSettings`, not from
`FormatSettings`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`05024_parquet_s3_no_footer_prefetch` asserts `ProfileEvents['RemoteFSPrefetches']`
from the initiator's `query_log` row, so it only holds while the object is read
by the initiator. The `ParallelReplicas` job installs `enable_parallel_replicas`
into the default profile, and `parallel_replicas_for_cluster_engines` then
rewrites `s3` to `s3Cluster`: the reads happen on the replicas and none of their
profile events reach that row, so both `RemoteFSPrefetches >= 1` assertions read
0 and the `= 0` assertion passes for the wrong reason.

Set `enable_parallel_replicas = 0` for the queries, so the test measures the read
path it is about in every job instead of being skipped in this one.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115681&sha=5e1a68518871a5f0308e0fbe13c5da87339c31d5&name_0=PR
PR: ClickHouse#115681

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sum `ProfileEvents['RemoteFSPrefetches']` over `initial_query_id` rather than
reading the initiator's `query_log` row, and drop the `enable_parallel_replicas = 0`
pin added in the previous commit. Under parallel replicas
`parallel_replicas_for_cluster_engines` rewrites `s3` to `s3Cluster` and the object
is read on a replica, so the initiator's row shows no prefetches at all - but the
gate under test runs on whichever node does the read, so the fix belongs in how the
test observes it, not in switching the topology off. The test now asserts the gate
in both topologies instead of being pinned to one.

`cluster_table_function_split_granularity` defaults to `file`, so one node reads the
whole object and the totals match the single-node ones. `count() > 0` keeps the
`= 0` assertion from passing on an empty set.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115681&sha=5e1a68518871a5f0308e0fbe13c5da87339c31d5&name_0=PR
PR: ClickHouse#115681

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The style check requires every query to `system.query_log` to carry a
`current_database = currentDatabase()` condition, and the previous commit
dropped it. A secondary query runs with the same default database as its
initiator, so the filter keeps matching the replica rows that the
`initial_query_id` aggregation is there to collect.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115681&sha=a54cba792395d77bdba332532b1259bfd08d04e6&name_0=PR&name_1=Style%20check
PR: ClickHouse#115681

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
UnamedRus and others added 3 commits September 10, 2026 20:11
…erywhere

`StorageObjectStorageSource::createReader` gates `remote_fs_settings.random_access`
on both the format's capability and `input_format_allow_seeks`, because a
random-access format only reads at arbitrary offsets while it is allowed to seek:
with seeks disabled it consumes the object sequentially from the start, and then
the from-start read-ahead is exactly what it reads and must not be suppressed.

The data lake readers set the same hint without that gate: `DeltaLakeMetadata`
and `PositionDeleteTransform` hardcoded it to `true`, `IcebergMetadata` and
`Iceberg/Compaction` derived it from `FormatFactory::checkIfFormatIsRandomAccessInput`
alone. All four then build their reader from `getFormatSettings(context)`, which
carries `input_format_allow_seeks` into `FormatSettings::seekable_read`, so with
seeks disabled they told the transport layer random access while the reader read
from the start, and lost the prefetch.

Extract the combined check as `formatReadsRandomAccess` next to `createReadBuffer`
and use it at all five call sites.

ClickHouse#115681 (comment)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The previous commit added a free `formatReadsRandomAccess` next to
`createReadBuffer` to combine the format's capability with
`input_format_allow_seeks`. That split was in the wrong place: the pure
capability form had no other caller, and `FormatFactory` already spells this
shape for its sibling checkers, which take a context and optional format
settings and consult them - `checkIfFormatSupportsSubsetOfColumns` and
`checkIfFormatSupportsPrewhere`.

Give `checkIfFormatIsRandomAccessInput` the same signature and fold the seek
gate into it, so the five call sites ask `FormatFactory` directly and the answer
lives in one place. `Utils.h` is back to its original contents.

ClickHouse#115681 (comment)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Under parallel replicas the object is read on a replica, and the replica's
`system.query_log` row runs with `current_database = 'default'`, not the
initiator's database. Requiring `current_database = currentDatabase()` of every
row therefore dropped exactly the rows that carry `RemoteFSPrefetches`, leaving
only the initiator's row, whose count is 0. Both `>= 1` assertions failed, on
every commit of this pull request since the test was added.

The `query_log` artifact of the failing job shows the gate itself working: for
one run, the `big` object prefetches on no node, the `small` object prefetches
once on a replica, and `big` with `input_format_allow_seeks = 0` prefetches once
on a replica while reading 12283799 bytes from S3 - the whole object, read
sequentially from the start.

`initial_query_id` already isolates the test, since the id is prefixed with the
unique `$CLICKHOUSE_DATABASE`, so the database condition only has to hold for the
initiator's own row. The style check greps the file, not the individual query, so
it stays satisfied.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115681&sha=359b8fab75579978b12a8ae976e5c6b8fe562fd3&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29
PR: ClickHouse#115681

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
UnamedRus and others added 3 commits September 11, 2026 17:43
Reading a legacy `DeltaLake` checkpoint goes over the same buffer twice:
`NativeParquetSchemaReader` first, then `asArrowFile` for the data. That worked
only because `ReadOptions::seekable_read` was never assigned and defaulted to
`true`, so `Parquet::Prefetcher` always took the seek path and left the buffer
alone. Now that the prefetcher reads `input_format_allow_seeks` through
`options.format.seekable_read`, the schema pass with seeks disabled falls into
`copyData(*reader_, out)`, which drains the buffer to EOF. The data pass then
hits the `asArrowFileLoadIntoMemory` fallback, which reads the leading `PAR1`
magic from the current position, gets nothing, and throws `Not a Parquet file`.

Open a separate buffer for the schema pass, the way `IcebergMetadata` already
does for its delete files, and cover it in `test_checkpoint` by reading the table
once more with `input_format_allow_seeks = 0`.

ClickHouse#115681 (comment)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The previous commit gave the schema pass its own read buffer, which fetches the
object a second time even when the first buffer was still perfectly usable. A
reader that may seek reads the footer and then the column ranges it needs, and
leaves the buffer ready for the next pass - that is the default, and it should
keep reading the object directly.

Only a reader that may not seek streams the whole object and leaves the buffer at
EOF. Materialize the object once for that case and give both passes a
`ReadBufferFromOutsideMemoryFile` over it: that buffer is seekable and carries a
file size, so `Parquet::Prefetcher` takes its seek path instead of loading the
whole file per pass, as it does today. A checkpoint holds one `add` action per
live file, so it is not small for a large table - worth not fetching twice.

ClickHouse#115681 (comment)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This reverts commit d9aea62, which reused the first buffer whenever the
readers could seek and materialized the whole object otherwise.

Reuse turned out to buy nothing. `createReadBuffer` takes `object_info` by
non-const reference and memoises the object metadata into it, so opening the
object a second time issues no extra HEAD, and the GETs are a wash: a shared
buffer seeking from the footer to the column ranges restarts its ranged request
anyway. What the reuse branch did cost was holding an entire checkpoint in a
`String` on the other side of the branch - and a checkpoint carries one `add`
action per live file.

Recreating the buffer is also what the rest of the codebase does:
`ReadSchemaUtils` recreates through `IReadBufferIterator::recreateLastReadBuffer`
and falls back to `PeekableReadBuffer` only when the iterator cannot, and both
`IcebergMetadata` and `Iceberg/PositionDeleteTransform` open a separate buffer for
their schema pass. Note in the comment that the second open is HEAD-free.

ClickHouse#115681 (comment)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
return false;

const auto & target = getCreators(name);
return target.random_access_input_creator || target.random_access_input_creator_with_metadata;

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.

checkIfFormatIsRandomAccessInput still decides this before outer compression is wrapped. For s3('*.parquet.gz', ..., 'Parquet') / Arrow.zst, this returns true, so createReadBuffer suppresses the head prefetch here, but wrapReadBufferWithCompressionMethod later turns the source into a CompressedReadBufferWrapper, which is not a SeekableReadBuffer. Parquet::Prefetcher::determineReadModeAndFileSize / ArrowIPCBlockInputFormat::prepareFileReader then fall back to streaming the whole object from the start, so the prefetch you disabled is exactly what those readers would consume. Please fold outer compression_method (or the wrapped buffer's actual seekability) into this check so compressed remote Parquet / ORC / Arrow files stay on the sequential-prefetch path.

groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 13, 2026
Only the first arm had per-statement evidence that the fuzzer ran on it. For the other three, liveness
rested on the `ASTFuzzerSkippedCollaborativeWorker` delta, and that counter is server-wide: any
parallel replicas or cluster read elsewhere on the server advances it, and under the serverfuzz
profile other files run such reads without pinning `ast_fuzzer_runs = 0`. An arm that silently lost
its own fuzz therefore still passed - its `not_fuzzed` and `no_internal_workers` lines hold vacuously
when nothing was fuzzed, and a foreign bump supplied the delta. Measured on a debug server against
354 skips/s of unrelated traffic: with an arm's fuzz settings neutralised, all three arms passed.

Each arm now brackets its own statement with a count of its fuzz copies' own initiating rows, the
evidence the first arm already had, keyed per arm:
  - declared: exact membership of its source in `tables`.
  - view: the view itself, not its source. A copy is a rewrite of the statement as the client wrote
    it, so it still names the view; the expansion happens further in, on the way to the workers.
  - cluster: the file name literal or the `fileCluster` table function, plus `current_database`. Its
    copies carry `_table_function` for both `databases` and `tables`, and the file name reaches them
    unfolded, so neither the worker key nor the folded name is available. The fuzzer's literal and
    function pool is server-wide, so an unrelated statement's copy can name this file (measured: 40
    seconds of foreign traffic forged 75 such rows); `current_database` is what no foreign copy has.

The server-wide skip deltas stay: they can only be inflated, never erased, so they remain direct
evidence that the guard was reached.

Validation on the same server: 32 runs of the final test, 24 of them four-way concurrent and 8 under
foreign traffic, all pass with every arm's copy count at its full 5. Neutralising one arm's fuzz
settings reddens exactly that arm's new line, including under foreign traffic.

CI report this signature was taken from (its head is unrelated to the change):
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115681&sha=858261cb4bb9e68db7eeed82dba277592650339f&name_0=PR&name_1=Stress%20test%20%28arm_tsan%29
ClickHouse#115681

Co-Authored-By: Claude Opus 5 <[email protected]>
@grantholly-clickhouse

Copy link
Copy Markdown
Contributor

It looks like the performance comparison on Aug 20th was fine. I am wondering if we introduced a regression so I am re-running CI

@grantholly-clickhouse
grantholly-clickhouse added this pull request to the merge queue Oct 1, 2026
Merged via the queue into ClickHouse:master with commit e80c212 Oct 1, 2026
346 of 349 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. pr-performance Pull request with some performance improvements 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.

5 participants