Skip to content

perf(pdu)!: avoid copying input events in FastPathInput - #1975

Open
uchouT (uchouT) wants to merge 2 commits into
Devolutions:masterfrom
uchouT:pdu-perf
Open

uchouT (uchouT) wants to merge 2 commits into
Devolutions:masterfrom
uchouT:pdu-perf

Conversation

@uchouT

@uchouT uchouT (uchouT) commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

FastPathInput held Vec<FastPathInputEvent>, forcing ActiveStage::process_fastpath_input to copy each chunk before encoding (the // PERF: unnecessary copy there). It now holds Cow<'a, [FastPathInputEvent]> and new() takes impl Into<Cow<..>>, matching FormatDataResponse::new_data.

Found this PERF comment when I was looking through the relevant code and resolved it while I was at it. Haven't observed the exact benefit.

`FastPathInput` now holds `Cow<'a, [FastPathInputEvent]>`.

BREAKING CHANGE: `FastPathInput` now has a lifetime parameter.

Signed-off-by: uchouT <i@uchout.moe>
Copilot AI balanced review requested due to automatic review settings September 17, 2026 20:06

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added breaking-change Includes a breaking change, and requires special scrutiny at the boundaries kind/protocol Affects RDP or related protocol behavior risk/high Substantial core public API impact, or fail-closed triage; needs maintainer-level scrutiny scope/core Touches the core architectural tier size/S Size: up to 199 counted lines and 5 files; exceeds XS in either measure labels Sep 17, 2026

@github-actions github-actions Bot left a comment

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.

PR #1975 makes FastPathInput a borrowing PDU (Cow<'a, [FastPathInputEvent]> plus an OwnedFastPathInput alias) and drops the per-chunk to_vec() in ActiveStage::process_fastpath_input. Independently verified: wire format unchanged; the 1..=255 event-count invariant holds in new/single/Arbitrary and is preserved by into_owned; the free decode lifetime is sound because decoding always yields Cow::Owned; the borrowed chunk is encoded synchronously so no borrow escapes. The only broken consumer (tuple construction in workspace-excluded ironrdp-client-glutin) predates this PR under a FIXME exclusion; the breaking change is explicit (!). protocol and skeptical found no defects; the single valid code-compressor style finding is confirmed and accepted.

Comment thread crates/ironrdp-pdu/src/input/fast_path.rs Outdated
@github-actions github-actions Bot added the ai-reviewed/1 One automated review completed label Sep 17, 2026
Signed-off-by: uchouT <i@uchout.moe>

@github-actions github-actions Bot left a comment

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.

Ownership refactor of FastPathInput from Vec to Cow<'a, [..]> with impl_pdu_borrowing!/IntoOwned, a free-lifetime Decode, and an Into<Cow>-based new(); ActiveStage now encodes the borrowed chunk without the prior to_vec() copy. Independently verified: the wire format, 1..=255 event-count invariant (new/single/into_owned/Arbitrary), 255-event chunking, and encode/decode symmetry are preserved; all in-workspace call sites (server, session, testsuite) use the new signatures correctly and the macro-generated DecodeOwned works with the free-lifetime Decode. No protocol or correctness defect found. Published one low-severity advisory (refined) on the semver-breaking public API change whose motivating perf win is small and unmeasured, corroborated by the tuple-construction call site in the workspace-excluded glutin client that no longer compiles.

  1. [skeptical] Breaking public API change whose motivating perf win is small and unmeasured — low 🟡 — crates/ironrdp-pdu/src/input/fast_path.rs
    FastPathInput gains a lifetime parameter, a Cow<'a, [FastPathInputEvent]> field, an Into<Cow>-based new(), and an OwnedFastPathInput alias — a semver-breaking public API change (acknowledged by '!'). The benefit is removal of one to_vec() allocation per <=255-event chunk in ActiveStage::process_fastpath_input, while the client batcher typically produces 1-2 event batches and no benchmark accompanies the change. The break is concrete: the workspace-excluded glutin client constructs FastPathInput(fastpath_events) tuple-style with a Vec and no longer compiles, though no in-workspace consumer breaks. Counterweights: the design mirrors the established borrowing-PDU convention (impl_pdu_borrowing! + IntoOwned, as in FormatDataResponse), and correctness/invariant handling checks out. Low severity: advisory API-cost/benefit tradeoff, no correctness or protocol impact.

@github-actions github-actions Bot added ai-reviewed/2 Final automated review completed and removed ai-reviewed/1 One automated review completed labels Sep 17, 2026
@uchouT uchouT (uchouT) changed the title perf(pdu)!: avoid copying input events in FastPathInput refactor(pdu)!: avoid copying input events in FastPathInput Sep 18, 2026
@uchouT uchouT (uchouT) changed the title refactor(pdu)!: avoid copying input events in FastPathInput perf(pdu)!: avoid copying input events in FastPathInput Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-reviewed/2 Final automated review completed breaking-change Includes a breaking change, and requires special scrutiny at the boundaries kind/protocol Affects RDP or related protocol behavior risk/high Substantial core public API impact, or fail-closed triage; needs maintainer-level scrutiny scope/core Touches the core architectural tier size/S Size: up to 199 counted lines and 5 files; exceeds XS in either measure

Development

Successfully merging this pull request may close these issues.

2 participants