Skip to content

fix(dfir_pipes): forward size_hint from pull to push in SendPush pivot [ci-bench]#2881

Open
MingweiSamuel wants to merge 1 commit into
mainfrom
mingwei/sizehint
Open

fix(dfir_pipes): forward size_hint from pull to push in SendPush pivot [ci-bench]#2881
MingweiSamuel wants to merge 1 commit into
mainfrom
mingwei/sizehint

Conversation

@MingweiSamuel
Copy link
Copy Markdown
Member

Before starting the pull loop, forward the pull's size_hint to the push
side so terminal operators like VecPush can pre-allocate capacity via
Vec::reserve. This avoids repeated doubling reallocations when the input
size is known (e.g., draining a handoff buffer with known length).

The hint is forwarded once per SendPush future (guarded by a bool flag)
to avoid redundant reserve calls on subsequent polls.

Vec::reserve is when allocation actually happens (not Vec::new), so this might hurt performance
if it messes up re-allocation order for growing vecs somehow, but probably ok.

Co-authored-by: Infinity 🤖 infinity@hydro.run

…ot [ci-bench]

Before starting the pull loop, forward the pull's `size_hint` to the push
side so terminal operators like `VecPush` can pre-allocate capacity via
`Vec::reserve`. This avoids repeated doubling reallocations when the input
size is known (e.g., draining a handoff buffer with known length).

The hint is forwarded once per `SendPush` future (guarded by a bool flag)
to avoid redundant reserve calls on subsequent polls.

`Vec::reserve` is when allocation actually happens (not `Vec::new`), so this might hurt performance
if it messes up re-allocation order for growing vecs somehow, but probably ok.

Co-authored-by: Infinity 🤖 <infinity@hydro.run>
PR: #2881
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 20, 2026

Deploying hydro with  Cloudflare Pages  Cloudflare Pages

Latest commit: 38687f4
Status: ✅  Deploy successful!
Preview URL: https://1e4edbb7.hydroflow.pages.dev
Branch Preview URL: https://mingwei-sizehint.hydroflow.pages.dev

View logs

@MingweiSamuel MingweiSamuel changed the title fix(dfir_rs): forward size_hint from pull to push in SendPush pivot [ci-bench] fix(dfir_pipes): forward size_hint from pull to push in SendPush pivot [ci-bench] May 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 2026

📊 Benchmark Results

✅ Benchmark completed! You can download the results from the links below.

Run History:

Last updated: 2026-05-20T23:44:40.286Z

@MingweiSamuel MingweiSamuel marked this pull request as ready for review May 20, 2026 23:27
@MingweiSamuel MingweiSamuel requested review from a team and Copilot May 20, 2026 23:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves dfir_pipes pull→push bridging by forwarding the upstream Pull::size_hint() into the downstream Push::size_hint() once per SendPush future, enabling terminal pushes (e.g., VecPush) to pre-reserve capacity and reduce reallocations.

Changes:

  • Added a size_hinted flag to SendPush to ensure the hint is forwarded at most once.
  • Forwarded Pull::size_hint() to the push side before entering the pull loop in SendPush::poll.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +52 to +57
// Forward size hint from pull to push once, so the push side
// can pre-allocate capacity (e.g., Vec::reserve).
if !core::mem::replace(this.size_hinted, true) {
let hint = Pull::size_hint(&*this.pull);
this.push.as_mut().size_hint(hint);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants