Repository navigation
Read a 64 KiB Parquet footer tail for local files - #124883
Conversation
Since ClickHouse#115686 the v3 reader reads clamp(file_size / 100, 128 KiB, 2 MiB) bytes from the end of every file when input_format_parquet_footer_read_size is 0. That saves a round trip on object storage, but for a local file a second read is cheap and the larger tail only costs bytes on every open. Resolve the default from the buffer being read: Prefetcher records ReadBufferFromFileBase::isRegularLocalFile, and readFileMetaData uses 64 KiB (the size before ClickHouse#115686) for a regular local file and the adaptive size otherwise. S3, Azure, HDFS and HTTP buffers and the cache wrappers do not override isRegularLocalFile, so their reads are unchanged, as is an explicit non-zero setting. The factory's is_remote_fs flag is not used: Hive over HDFS and Context::getInputFormat leave it at its false default. SELECT count() over ClickBench's 100 hits_N.parquet files now reads 6.55 MB of footer tails instead of 140.7 MB. clickhouse-local, 4 threads: warm q1 0.64x, cold q1 0.72x. Analysis by @ snelheidai in ClickHouse#124673. Related: ClickHouse#124673 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 findings) plus my own review (4 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20261009-102500 |
|
Workflow [PR], commit [dd9a6b1] Summary: ✅
AI ReviewSummaryThis PR changes the Parquet v3 footer-read default so path-based local files use a 64 KiB tail instead of the adaptive Findings
Final Verdict
|
The setting description now says the 64 KiB tail applies when the file is read directly from the local filesystem (the reader's buffer reports `isRegularLocalFile`). Reads through a file descriptor or a wrapping buffer keep the adaptive size, as on master. The 26.10 settings history reason no longer says that 0 keeps the adaptive behavior. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units29 translation units recompiled, 237 s compile time in total, 29 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.13 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
CI finish ledger - 6fbb4e7Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The changed test Session id: cron:our-pr-ci-monitor:20261009-163012 |
|
This makes a lot of sense for local reads. I'm taking a look now |
| if (auto * file_buf = dynamic_cast<ReadBufferFromFileBase *>(seekable)) | ||
| { | ||
| size_t view_offset = 0; | ||
| is_local_file = file_buf->isRegularLocalFile(&view_offset); |
There was a problem hiding this comment.
This seems like the key part of the PR. Now we take the ReadBuffer reader_, make it seekable with auto * seekable = dynamic_cast<SeekableReadBuffer *>(reader_); https://github.com/ClickHouse/ClickHouse/pull/124883/changes#diff-ff4e4f13a4e700303b228ac78bb907e5150adc20d96a533b499a20c6e6cb0edaR63 , and then we callisRegularLocalFile through ReadBufferFromFileBase which makes sense.
If we are using object storage, isRegularLocalFile should return false because the buffer isn't a file-based buffer, the cast returns nullptr, the block is skipped, and is_local_file stays at its default of false
There was a problem hiding this comment.
Thanks for the review. One detail on the object-storage path: there the cast usually succeeds, because s3() and the object-storage engines read through ReadPipeline::build(), which returns a ReadBufferFromFileBase (ReadBufferFromS3, AsynchronousBoundedReadBuffer, CachedOnDiskReadBufferFromFile all derive from it). is_local_file stays false because the base ReadBufferFromFileBase::isRegularLocalFile returns false and only the local-file buffers (ReadBufferFromFile, AsynchronousReadBufferFromFile, the mmap ones) override it. The cast returns nullptr only for buffers outside that hierarchy, such as url()'s ReadWriteBufferFromHTTP.
There was a problem hiding this comment.
Thanks for the clarification. That makes sense to me.
|
@groeneai can you look into the settings failure in CI https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=124883&sha=6fbb4e7e880b26cee0610fbf938698e940e43d7e&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 If we have a flaky test, could you open an issue for the flaky tests? |
|
I looked into it. The other failures on this commit are covered too: |
CI finish ledger - dd9a6b1Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The four Session id: cron:our-pr-ci-monitor:20261010-063008 |
4104287
…m master. The setting description of `input_format_parquet_footer_read_size` now says the 64 KiB tail applies when the file is read directly from the local filesystem (the reader's buffer reports `isRegularLocalFile`). Reads through a file descriptor or a wrapping buffer keep the adaptive size. The `SettingsChangesHistory` reason no longer says that `0` keeps the adaptive behavior. Cherry-picked from 6fbb4e7; on 26.8 the history reason is in `SettingsChangesHistory.cpp`, so it is changed there. ClickHouse#124883 Related: #2181
Related: #124673
Related: #115686
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Opening a local Parquet file reads a 64 KiB tail for its footer again instead of 1% of the file, so short queries over many local Parquet files are faster.
Description
Since #115686, the Parquet reader with
input_format_parquet_footer_read_size = 0(the default) readsclamp(file_size / 100, 128 KiB, 2 MiB)bytes from the end of every file. That saves a second round trip on object storage. For a local file a second read is cheap, so the larger tail only adds bytes to every open.SELECT count()over ClickBench's 100hits_N.parquetfiles (footers 23-57 KB) reads 140.7 MB of tails to parse 3.7 MB of footers.Prefetchernow recordsReadBufferFromFileBase::isRegularLocalFileof the buffer it reads, andreadFileMetaDatauses 64 KiB (the size before #115686) for a regular local file and the adaptive size otherwise. The decision uses the buffer, not the factory'sis_remote_fs, because Hive over HDFS andContext::getInputFormatleave that flag atfalse. S3, Azure, HDFS and HTTP buffers and the cache wrappers keepisRegularLocalFile() = false, so their reads do not change, and neither does an explicit non-zero setting.Category: #115686 is in no release yet (26.9 still reads 64 KiB), so nothing changes between releases.
Validation, Release build,
clickhouse local, 4 threads, paired runs, fix/base with 95% CI, identical results:count()over the 100 files: 140,741,630 -> 6,553,600. Aurl()read requests the same adaptive tail on both builds.count()with all row groups pruned 0.63 [0.60, 0.66], q41 0.82 [0.67, 0.99]. Controls q3, q21, q24 unchanged or faster.05025_parquet_footer_read_sizenow checks that the default reads 65536 bytes from a local file (131072 before).The footer prefetch proposed in #124673 is not included.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/124883]
Version info
26.10.1.2154-master(included in26.10and later)