Repository navigation
Preallocate multipart_tags deque to reduce dynamic memory allocation … - #101799
alexey-milovidov merged 5 commits into
Conversation
|
Workflow [PR], commit [069f2ff] Summary: ✅ AI ReviewSummaryThis PR preallocates ClickHouse Rules
Final Verdict
|
|
The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix. |
|
Thanks @alexey-milovidov for merging the stress test fix commit, now most of the stress test passed but I see arm_msan stress test still failing , not only this pr but other PRs , Also on checking ci-cd logs for this step I don't find any reason of failure linked to changes in this pr, Do let me know if you feel this is failure due to my changes only , I will dig deeper and try to find out the root cause |
|
The MSan stress test failure (MemorySanitizer: use-of-uninitialized-value, STID 4179-5154 or 4148-3044) is a known pre-existing issue unrelated to this PR. Fix: #102158 |
|
@alexey-milovidov can you please help in closing it ,all stress test also passed, do let me know if anything required from my end |
We will need to rewrite the commits with your email from GitHub. Could you please do it? |
…overhead in S3 upload loop
c5dcf9b to
ff4a6a9
Compare
…-upload-allocation
|
@groeneai, fix the failure of |
|
@alexey-milovidov — investigated. The What's happeningThere are two distinct failure modes for this test:
Auto-generated flaky-test issues already filed for mode 2: #103819, #103820 (filed 2026-05-01, after my mode-1 fix landed). Cross-PR evidence (last 30d, mode 2 only)17 distinct PRs hit the empty-error assertion: The 51-failure spike on 2026-05-05 was almost entirely a single PR (#100185, 48/51) and not a real surge. Why mode 2 happens
The query should fail because
If steps 2 → 3 happen faster than the freezer fully suspends Fix directionI'm filing a follow-up PR to make the test gate the actual probe on a deterministic check that pause is effective: with cluster.pause_container("node1"):
# Verify pause is effective before the actual test — connecting to node1 must fail.
# Without this, the freezer can race the SELECT and let the query succeed.
deadline = time.time() + 30
while time.time() < deadline:
try:
node3.query(
"SELECT 1 FROM remote('node1:9000', system.one) "
"SETTINGS connect_timeout_with_failover_ms=200, "
"handshake_timeout_ms=200, connections_with_failover_max_tries=1",
timeout=2,
)
except QueryRuntimeException:
break
else:
pytest.fail("cluster.pause_container did not take effect within 30s")
# Now run the actual probe — pause is verified
...This makes the test deterministic and preserves the original intent (validate that I'll post the fix PR shortly and link here. — @groeneai (CI bot) |
…-upload-allocation
|
Follow-up fix posted: PR #104167 — gates the probe on a deterministic pause-effective check, so the actual |
… block If `multipart_tags.resize(num_parts)` threw (e.g. `std::bad_alloc`) while placed before the `try` block, the multipart upload already created by `createMultipartUpload` would be silently abandoned as an orphan in S3, because the `catch` block calling `abortMultipartUpload` would never be reached. Moving the resize to the first statement inside the `try` block ensures that any allocation failure is caught and `abortMultipartUpload` is always called to clean up the in-progress upload.
LLVM Coverage Report
Changed lines: 100.00% (7/7) · Uncovered code |
|
All of CI pipeline steps are successful, also have pushed all the commits with correct email address, also addressed one comment , should be good to merge now, if still anything else required from my end please do let me know |
|
Hello! Can a performance test be added? |
Problem Overview:
Preallocate
multipart_tagsdeque to reduce dynamic memory allocation overhead in S3 upload loop.Summary:
During S3 multipart file uploads, the previous implementation dynamically allocated storage for part tags element-by-element inside the main scheduling loop using push_back. Since the exact number of file chunks is calculated prior to the loop, this dynamic allocation created completely unnecessary memory overhead and locking contention interleaved with thread queuing. This PR optimizes the flow by pre-allocating the entire container upfront and replacing dynamic sizing with direct index assignment, eliminating repeated heap allocations during chunk queuing.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reduce memory allocation overhead during S3 multipart uploads by preallocating internal tracking containers.
Documentation entry for user-facing changes
Version info
26.5.1.419