Skip to content

simplify ReceiveStream.Read implementation#5500

Merged
marten-seemann merged 3 commits into
masterfrom
simplify-receive-stream-read-logic
Dec 26, 2025
Merged

simplify ReceiveStream.Read implementation#5500
marten-seemann merged 3 commits into
masterfrom
simplify-receive-stream-read-logic

Conversation

@marten-seemann

Copy link
Copy Markdown
Member
  1. Simplify check for stream cancellations
  2. Don't arm the deadline timer if there's data to read

No functional change expected.

@macroscopeapp

macroscopeapp Bot commented Dec 26, 2025

Copy link
Copy Markdown

Simplify ReceiveStream.readImpl in receive_stream.go to centralize remote cancellation checks via ReceiveStream.isRemoteCancellationEffective, adjust deadline evaluation, and always call ReceiveStream.dequeueNextFrame after waits

Introduce ReceiveStream.isRemoteCancellationEffective and replace inline checks; move deadline timer setup to the blocking branch with an immediate deadline check using !deadline.IsZero() and !monotime.Now().Before(deadline); after re-lock, unconditionally call ReceiveStream.dequeueNextFrame.

📍Where to Start

Start with ReceiveStream.readImpl in receive_stream.go, then review the helper ReceiveStream.isRemoteCancellationEffective used within the read path.


Macroscope summarized 9bcc959.

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.

Pull request overview

This PR refactors the ReceiveStream.Read implementation to improve code clarity and performance without changing functional behavior. The changes simplify stream cancellation checks and optimize deadline timer usage.

Key changes:

  • Introduced a helper method isRemoteCancellationEffective() to consolidate repeated cancellation logic
  • Optimized deadline timer creation to only arm the timer when actually waiting for data, rather than pre-emptively when data is already available
  • Removed redundant conditional check before calling dequeueNextFrame() after waiting

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

@marten-seemann marten-seemann merged commit 221373f into master Dec 26, 2025
54 checks passed
@marten-seemann marten-seemann deleted the simplify-receive-stream-read-logic branch December 29, 2025 14:34
wwqgtxx pushed a commit to MetaCubeX/quic-go that referenced this pull request Jan 3, 2026
* simplify check for stream cancellations

* only arm deadline timer if there’s no data to read

* remove redundant nil check
wwqgtxx pushed a commit to MetaCubeX/quic-go that referenced this pull request Jan 11, 2026
* simplify check for stream cancellations

* only arm deadline timer if there’s no data to read

* remove redundant nil check
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.

2 participants