feat: Add Push::size_hint, VecPush terminal operator, use in dfir codegen [ci-bench]#2678
Merged
MingweiSamuel merged 1 commit intomainfrom Mar 24, 2026
Merged
feat: Add Push::size_hint, VecPush terminal operator, use in dfir codegen [ci-bench]#2678MingweiSamuel merged 1 commit intomainfrom
Push::size_hint, VecPush terminal operator, use in dfir codegen [ci-bench]#2678MingweiSamuel merged 1 commit intomainfrom
Conversation
Contributor
📊 Benchmark Results✅ Benchmark completed! You can download the results from the links below. Run History:
Last updated: 2026-03-24T18:48:16.229Z |
7f97a50 to
ec19b6e
Compare
Push::size_hint, VecPush terminal operator, use in dfir codegen [ci-bench]
Member
Author
|
Shows some small performance improvements. A few performance decreases within noise. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds push-side size hints and a new Vec-collecting terminal push operator to enable downstream pre-allocation, and updates DFIR codegen/runtime plumbing to take advantage of the new bulk-push path.
Changes:
- Add
Push::size_hintand propagate it through push combinators/sinks, plus new alloc-gatedVecPush/push::vec_push. - Update DFIR runtime
Handoff/SendCtxAPIs to expose a “borrow mutable inner for giving” path used by codegen. - Update macros/tests and various pulls to account for the new size-hint requirements and type changes.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| dfir_rs/tests/compile-fail-stable/surface_demuxenum_wrongfields_2.stderr | Update expected diagnostics due to new VecPush type appearing in trait impl lists. |
| dfir_rs/tests/compile-fail-stable/surface_demuxenum_wrongfields_1.stderr | Same: refresh compile-fail expectations after push API expansion. |
| dfir_rs/tests/compile-fail-stable/surface_demuxenum_wrongenum.stderr | Same: refresh stderr golden output for changed trait impl candidates. |
| dfir_rs/src/util/demux_enum.rs | Extend DemuxEnumPush with a size_hint hook for derived demux pushes. |
| dfir_rs/src/scheduled/port.rs | Add SendCtx::borrow_mut_give() to support bulk writes into handoffs. |
| dfir_rs/src/scheduled/handoff/vector.rs | Implement borrow_mut_give for VecHandoff by borrowing the input buffer mutably. |
| dfir_rs/src/scheduled/handoff/tee.rs | Add borrow_mut_give stub for TeeingHandoff (currently todo!()). |
| dfir_rs/src/scheduled/handoff/mod.rs | Add borrow_mut_give requirement to the Handoff trait. |
| dfir_rs/src/compiled/push/demux_enum.rs | Forward Push::size_hint into DemuxEnumPush::size_hint. |
| dfir_rs/src/compiled/pull/lattice_bimorphism.rs | Implement required Pull::size_hint (returns (0, None) due to UDF dependence). |
| dfir_pipes/src/push/vec_push.rs | New alloc-gated VecPush terminal operator collecting into Vec and reserving via size_hint. |
| dfir_pipes/src/push/unzip.rs | Propagate size_hint to both downstream pushes. |
| dfir_pipes/src/push/test_utils.rs | Record size_hint calls in TestPush history for testing/validation. |
| dfir_pipes/src/push/sink.rs | Add no-op size_hint implementation for Sink. |
| dfir_pipes/src/push/resolve_futures.rs | Forward size_hint downstream (1 future → 1 output). |
| dfir_pipes/src/push/persist.rs | Reserve internal buffer and forward size_hint downstream. |
| dfir_pipes/src/push/mod.rs | Add Push::size_hint; export alloc-gated VecPush + push::vec_push constructor. |
| dfir_pipes/src/push/map.rs | Forward size_hint unchanged. |
| dfir_pipes/src/push/inspect.rs | Forward size_hint unchanged. |
| dfir_pipes/src/push/for_each.rs | Add no-op size_hint (terminal side-effecting push). |
| dfir_pipes/src/push/flatten.rs | Conservative size_hint propagation (forces (0, None)). |
| dfir_pipes/src/push/flat_map.rs | Conservative size_hint propagation (forces (0, None)). |
| dfir_pipes/src/push/filter_map.rs | Adjust size_hint lower bound to 0 and forward upper bound. |
| dfir_pipes/src/push/filter.rs | Adjust size_hint lower bound to 0 and forward upper bound. |
| dfir_pipes/src/push/fanout.rs | Propagate size_hint to both downstream pushes. |
| dfir_pipes/src/push/demux_var.rs | Add size_hint to variadic demux and propagate recursively. |
| dfir_pipes/src/pull/symmetric_hash_join.rs | Refactor new-tick path to pull::iter and add size_hint impls returning (0, None) (TODO for estimates). |
| dfir_pipes/src/pull/poll_fn.rs | Implement required Pull::size_hint (UDF-dependent, returns (0, None)). |
| dfir_pipes/src/pull/mod.rs | Make Pull::size_hint required (remove default impl) to prevent accidental omission. |
| dfir_pipes/src/pull/from_fn.rs | Implement required Pull::size_hint (UDF-dependent, returns (0, None)). |
| dfir_pipes/src/pull/cross_singleton.rs | Implement size_hint with singleton-state-aware lower-bound adjustment. |
| dfir_macro/src/lib.rs | Update demux enum derive output to use Pin::as_mut and generate size_hint plumbing. |
| dfir_lang/src/graph/meta_graph.rs | Switch send-port codegen from per-item give(Some(v)) to borrowing the inner vec and using vec_push. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b94af2c to
0b77c7b
Compare
Member
Author
|
Looks good |
shadaj
approved these changes
Mar 24, 2026
Added `size_hint(self: Pin<&mut Self>, hint: (usize, Option<usize>))` to the `Push` trait as the push-side analog of `Pull::size_hint`. This allows producers to announce how many items they're about to send, enabling downstream operators and sinks to pre-allocate. Trait changes: - `Push::size_hint`: default no-op implementation - `&mut P` blanket impl: forwards to inner - `PushVariadic::size_hint`: new required method Propagation through combinators: - Map, Inspect: pass through unchanged (1:1 mapping) - Filter, FilterMap: lower bound set to 0, upper preserved - FlatMap, Flatten: hint becomes (0, None) — output count unknown - Fanout, Unzip: forward to both branches - Persist: reserves on internal Vec buffer, then forwards - DemuxVar: forwards to all downstream pushes via PushVariadic - ForEach, SinkPush, ResolveFutures: use default no-op New terminal operator: - `VecPush<Buf>`: pushes items into a `Vec`, uses `size_hint` to call `Vec::reserve(hint.0)` for pre-allocation. Gated on `alloc` feature. - Constructor: `push::vec_push(buf)` creates a VecPush from a `&mut Vec<T>`. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
0b77c7b to
d7f7828
Compare
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.
Added
size_hint(self: Pin<&mut Self>, hint: (usize, Option<usize>))to thePushtrait as the push-side analog ofPull::size_hint. This allows producers to announce how many items they're about to send, enabling downstream operators and sinks to pre-allocate.New terminal operator:
VecPush<Buf>: pushes items into aVec, usessize_hintto callVec::reserve(hint.0)for pre-allocation. Gated onallocfeature.push::vec_push(buf)creates a VecPush from a&mut Vec<T>.BREAKING CHANGE: Updates the
Handofftrait to allow pushing to&mut Vec<T>directly instead of one-by-one, and allows pre-allocating.