Skip to content

Cherry pick #107414 to 26.4: Filesystem cache: avoid redundant opendir per key directory on load - #107496

Merged
robot-clickhouse-ci-1 merged 3 commits into
backport/26.4/107414from
cherrypick/26.4/107414
Jun 15, 2026
Merged

robot-clickhouse-ci-1 merged 3 commits into
backport/26.4/107414from
cherrypick/26.4/107414

Conversation

@robot-clickhouse-ci-1

Copy link
Copy Markdown
Contributor

Original pull-request #107414

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

alexey-milovidov and others added 3 commits June 13, 2026 19:08
`FileCache::loadMetadataForKey` opened each key directory twice during
startup metadata loading: once via `fs::is_empty` to check for emptiness,
and once more via `fs::directory_iterator` to scan the segment files.

Open the directory only once and reuse the iterator: an empty directory
is detected when the freshly-constructed iterator already equals the
end iterator. This halves the number of `opendir`/`readdir` syscalls at
the key-directory level, which matters for caches with many keys where
startup loading is dominated by filesystem metadata latency.

Pure refactor with identical behavior; covered by the existing
`test_parallel_cache_loading_on_startup` integration test.

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

Filesystem cache: avoid redundant opendir per key directory on load
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels Jun 15, 2026
@robot-clickhouse-ci-1
robot-clickhouse-ci-1 merged commit 34a2020 into backport/26.4/107414 Jun 15, 2026
@robot-clickhouse-ci-1
robot-clickhouse-ci-1 deleted the cherrypick/26.4/107414 branch June 15, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants