Skip to content

Parallelize copyFile in DiskObjectStorageTransaction - #105089

Merged
asya-ch merged 18 commits into
masterfrom
asya/copy_files
Jun 1, 2026
Merged

asya-ch merged 18 commits into
masterfrom
asya/copy_files

Conversation

@asya-ch

@asya-ch asya-ch commented May 15, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Performance Improvement

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

Parallelize blob copies in DiskObjectStorageTransaction::copyFile using a per-disk thread pool.

Version info

  • Merged into: 26.6.1.304

@clickhouse-gh

clickhouse-gh Bot commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [706f183]

Summary: ✅


AI Review

Summary

This PR parallelizes DiskObjectStorageTransaction blob copies with a per-disk ThreadPool. The main correctness path is much improved from earlier revisions, but two review concerns remain: the new runner still does not fail fast on the first worker exception, and the Performance Improvement claim still lacks before/after evidence.

Findings

⚠️ Majors

  • [src/Disks/DiskObjectStorage/DiskObjectStorageTransaction.cpp:511] copyFileImpl now promises a faster copy path without materially worsening failure behavior, but ThreadPoolCallbackRunnerLocal only rethrows from waitForAllToFinishAndRethrowFirstError after the enqueue loop has submitted every (location, blob) copy. Worker exceptions are stored in futures, so the pool does not surface them during later enqueueAndKeepTrack calls; even copy_object_thread_pool_size = 1 continues scheduling the remaining copies after the first failed remote copy. This regresses the previous sequential copyObjectToAnotherObjectStorage behavior, can perform a large amount of extra S3/Azure work, and can create many more destination blobs for undo to clean up. Bound tracked tasks to the pool size and poll completed futures while enqueueing, or use explicit batches that stop scheduling as soon as the first worker exception is observed.
Tests
  • ⚠️ The PR is categorized as Performance Improvement, but neither the PR description nor the added code includes before/after measurements for representative multi-blob copyFile workloads. A focused latency or throughput comparison would close this evidence gap.
  • ⚠️ I do not see a focused regression test for the worker-exception path that proves copyFileImpl stops scheduling promptly and rolls back copied blobs correctly. A small failpoint or mock-object-storage test around copyObjectToAnotherObjectStorage would cover the remaining failure-mode risk.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions: fix the fail-fast/backpressure behavior in copyFileImpl, add focused failure-path coverage, and attach benchmark evidence for the claimed performance improvement.

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label May 15, 2026
@Michicosun Michicosun self-assigned this May 16, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

This was fixed by #105146. Let's update the branch.

const auto locations_for_writing = cluster->getEnabledLocations();
const auto missing_locations = cluster->findComplement(locations_for_writing);
const auto source_local_location = source_cluster->getLocalLocation();
/// Dispatch `copyObjectToAnotherObjectStorage` calls in parallel onto the disk-level pool.

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.

This PR is marked as Performance Improvement, but I don’t see before/after evidence in the PR description or in added tests for this new parallel path.

Please attach a focused measurement (for example, copy latency/throughput for representative multi-blob files before vs after) to validate the claimed improvement.

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.

Re-checking current HEAD (ed61ba2c9c406901c4bf2854638a59577a91c57a), this is still missing concrete before/after data for the claimed Performance Improvement in DiskObjectStorageTransaction::copyFile.

Please attach at least one focused measurement (latency or throughput, representative multi-blob copy workload) comparing before vs after so the performance claim is verifiable.

@asya-ch
asya-ch enabled auto-merge May 20, 2026 18:48
}
}

runner.waitForAllToFinishAndRethrowFirstError();

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.

ThreadPoolCallbackRunnerLocal only rethrows in waitForAllToFinishAndRethrowFirstError after the enqueue loop has already submitted every (location, blob) copy. If the first worker hits a remote exception, copyFile still keeps scheduling and executing the remaining copies, so a failed copy can perform a large amount of extra S3/Azure work and create many more destination blobs that undo then has to clean up. This regresses the previous sequential behavior, which stopped at the first failed copyObjectToAnotherObjectStorage.

Please keep the number of tracked tasks bounded and poll completed tasks while enqueueing, for example with a TaskTracker-style loop or explicit batches no larger than the pool, so the first worker exception stops scheduling promptly and clears completed task handles.

@clickhouse-gh

clickhouse-gh Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.40% 84.50% +0.10%
Functions 91.40% 91.40% +0.00%
Branches 76.90% 77.00% +0.10%

Changed lines: Changed C/C++ lines covered by tests: 72/75 (96.00%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@asya-ch
asya-ch added this pull request to the merge queue Jun 1, 2026
Merged via the queue into master with commit 92c8eb8 Jun 1, 2026
166 checks passed
@asya-ch
asya-ch deleted the asya/copy_files branch June 1, 2026 15:05
@alesapin

alesapin commented Jun 1, 2026

Copy link
Copy Markdown
Member

Why it shows as it was merged by Asya? It was merged by me :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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