Repository navigation
Conversation
|
Hi, I wrote the solution to the problem as it was written in the task description, but I ran into several problems while solving the problem
Because of these problems, I managed to speed up the solution only by about 2 times (provided that the hyperparameters are correctly selected, which will be discussed below) I also noticed that we cannot initially know exactly how many segments we want to check in parallel (otherwise, queries will not become completely parallel there), so this is a hyperparameter that has to be iterated from query to query, as well as the constant 0.9 (which is not optimal for all queries) please help me decide what to do with these problems =) |
|
CI is not running due to incomplete description. You shall not delete |
|
Please, fix the PR's description, @scanhex12. It needs to run the CI. |
|
This is an automated comment for commit 8afa00a with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
|
Dear @CheSema, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
I admit that the idea is great. But I do not see that it is appropriate here. My vision here is the following. |
|
I tried to finish this pull request, but found several problems:
|
The previous commit parallelizes hierarchical globs by walking the '/' tree, but a single big flat directory still lists serially (S3 pagination within a prefix is sequential). Such directories are common when files are named by hash/UUID, e.g. `musicbrainz/mlhdplus-complete/<uuid>.txt.zst` (~600k files in one prefix). When a listed prefix is truncated but has no sub-directories, split it by keyspace: tile its remaining range into contiguous `(start_after, end]` sub-ranges and list them concurrently. Boundaries are derived from the byte alphabet observed in the listed page (so the split adapts to the actual keys, e.g. hex for UUIDs). Because the sub-ranges are contiguous they tile the interval with no gaps — a key whose byte is absent from the sampled alphabet still falls into the range that brackets it — so the split is complete regardless of the key distribution or character set. This avoids the fragility of the earlier attempt #66504, which used fixed split points assuming a uniform distribution and a fixed character set. Measured on `musicbrainz/mlhdplus-complete` (594415 flat files, real S3, ~75ms/list-request): listing drops from 37.6s to 3.7s (~10x) with identical results (same count, no duplicates, identical path checksum). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Listing files for the `s3` table function with a glob was a single serial stream of `ListObjectsV2` requests paginated by a continuation token, bound by the per-request latency of S3 (~0.1-0.3s). This dominates queries over buckets with many objects (issue ClickHouse#65572; an earlier attempt was ClickHouse#66504). List the matching files in parallel by walking the "directory" tree formed by the `/` delimiter: worker threads list different common prefixes concurrently, and subtrees that cannot contain a matching key are pruned during the walk, so for hierarchically partitioned layouts fewer objects are fetched, not merely listed in parallel. Controlled by the new setting `s3_list_object_parallelism` (default `1`, the previous serial behavior). Recursive globs (`**`) keep serial listing. Correctness is guaranteed by the existing per-file `RE2::FullMatch`, so the directory pruning only needs to be conservative. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The previous commit parallelizes hierarchical globs by walking the '/' tree, but a single big flat directory still lists serially (S3 pagination within a prefix is sequential). Such directories are common when files are named by hash/UUID, e.g. `musicbrainz/mlhdplus-complete/<uuid>.txt.zst` (~600k files in one prefix). When a listed prefix is truncated but has no sub-directories, split it by keyspace: tile its remaining range into contiguous `(start_after, end]` sub-ranges and list them concurrently. Boundaries are derived from the byte alphabet observed in the listed page (so the split adapts to the actual keys, e.g. hex for UUIDs). Because the sub-ranges are contiguous they tile the interval with no gaps — a key whose byte is absent from the sampled alphabet still falls into the range that brackets it — so the split is complete regardless of the key distribution or character set. This avoids the fragility of the earlier attempt ClickHouse#66504, which used fixed split points assuming a uniform distribution and a fixed character set. Measured on `musicbrainz/mlhdplus-complete` (594415 flat files, real S3, ~75ms/list-request): listing drops from 37.6s to 3.7s (~10x) with identical results (same count, no duplicates, identical path checksum). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Speed-up listing files in S3. This closes #65572.
Documentation entry for user-facing changes
CI Settings (Only check the boxes if you know what you are doing):