fix: bound component operation concurrency and pre-allocate future buffers#81
Merged
bashandbone merged 2 commits intoMar 13, 2026
Conversation
… pre-allocate Vec capacity Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
recoco-docs | 8ee551b | Commit Preview URL Branch Preview URL |
Mar 13 2026, 03:36 AM |
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Copilot
AI
changed the title
[WIP] [1069384] Optimize component upsert to execute asynchronously
fix: bound component operation concurrency and pre-allocate future buffers
Mar 13, 2026
86fd98e
into
optimize-component-upserts-10693844638826288617
4 checks passed
Contributor
There was a problem hiding this comment.
Pull request overview
This PR bounds concurrency for component delete/upsert operations and reduces allocation churn when applying many component changes.
Changes:
- Replace unbounded
try_join_allwithbuffer_unordered(COMPONENT_CONCURRENCY_LIMIT)to cap in-flight operations. - Introduce
COMPONENT_CONCURRENCY_LIMITconstant (16) with documentation. - Pre-allocate the futures vectors using upfront totals to avoid repeated reallocations.
Comments suppressed due to low confidence (1)
crates/recoco-core/src/setup/components.rs:1
buffer_unorderedbounds execution, but this still eagerly allocates and builds aVeccontaining all delete/upsert futures up front, and thentry_collect::<Vec<_>>()allocates a secondVecof results that is immediately discarded. For large change sets, this can be a significant memory spike and delays starting IO until the vectors are fully built. Consider switching to a lazy stream +try_for_each_concurrent(COMPONENT_CONCURRENCY_LIMIT, ...)(and ideally avoid the intermediateVecentirely by streaming over keys/states directly) so work starts immediately and no result vector is allocated.
// Recoco is a Rust-only fork of CocoIndex, by [CocoIndex](https://CocoIndex)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bashandbone
added a commit
that referenced
this pull request
Mar 13, 2026
…all (#79) * Optimize component upsert to execute asynchronously using try_join_all Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> * Optimize component upsert to execute asynchronously using try_join_all Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> * fix: bound component operation concurrency and pre-allocate future buffers (#81) * Initial plan * fix: replace unbounded try_join_all with bounded buffer_unordered and pre-allocate Vec capacity Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The previous
try_join_allapproach launched all delete/upsert futures simultaneously — unbounded concurrency that can saturate a DB connection pool at scale, with no protection against partial application on error.Changes
try_join_allwithbuffer_unordered(COMPONENT_CONCURRENCY_LIMIT)+try_collect, capping simultaneous in-flight DB/network ops at 16COMPONENT_CONCURRENCY_LIMIT: usize = 16with doc comment — visible and tunable relative to connection pool sizeVec::with_capacitysized from upfront sum of all change counts, eliminating incremental reallocations💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.