Skip to content

stageJoiner optimizations#60

Merged
mhagger merged 2 commits into
stage-joinerfrom
znull/stage-joiner
Jun 15, 2026
Merged

stageJoiner optimizations#60
mhagger merged 2 commits into
stage-joinerfrom
znull/stage-joiner

Conversation

@znull

@znull znull commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Two suggestions found while reviewing #59, both oriented around allocating less where possible.

/cc @mhagger

znull added 2 commits June 15, 2026 15:25
needFilePipe() and validate() each call Stage.Requirements() for the
adjacent stages, so a stage's requirements can be computed/allocated
twice during startup. Caching the result on the joiner lets us call
Requirements() only once.
Reorder Start() to run stageJoiner.validate() before createPipe(), and
make validate() decide whether a stream is "connected" from the pipeline
topology (the presence of an adjacent stage or an already-set
input/output stream).

This lets us reject an invalid pipeline without allocating any io.Pipe()
objects, and in the case of os.Pipe(), doing the system calls to create
OS-level file descriptors.
@znull znull self-assigned this Jun 15, 2026
@znull znull changed the title Znull/stage joiner stageJoiner optimizations Jun 15, 2026
@znull znull marked this pull request as ready for review June 15, 2026 13:36
@znull znull requested a review from a team as a code owner June 15, 2026 13:36
Copilot AI review requested due to automatic review settings June 15, 2026 13:36

Copilot AI left a comment

Copy link
Copy Markdown

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 optimizes pipeline stage-joining by caching each stage’s Requirements() and validating stream compatibility earlier, reducing repeated computation and avoiding unnecessary pipe allocation when stages are incompatible.

Changes:

  • Cache Stage.Requirements() in stageJoiner (prevStageReq / nextStageReq) and reuse it for pipe selection and validation.
  • Update stageJoiner.validate() to reason about whether streams are logically connected (via adjacent stages or pre-supplied stdin/stdout) rather than only checking already-created pipes.
  • Reorder Pipeline.Start() to validate joiners before creating inner pipes.
Show a summary per file
File Description
pipe/stage_joiner.go Adds cached requirements fields and updates validation/pipe-selection to use them.
pipe/pipeline.go Stores cached requirements into joiners and validates joiners before allocating inner pipes.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@mhagger mhagger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@mhagger mhagger merged commit 7072f01 into stage-joiner Jun 15, 2026
3 checks passed
@mhagger mhagger deleted the znull/stage-joiner branch June 15, 2026 16:06
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