Skip to content

Scan every stream after an ACK only when one may be blocked on window - #316

Open
tfpauly wants to merge 2 commits into
mainfrom
tfp/stream-blocked-flag
Open

tfpauly wants to merge 2 commits into
mainfrom
tfp/stream-blocked-flag

Conversation

@tfpauly

@tfpauly tfpauly commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Performance improvement to avoid unnecessary stream scanning

@tfpauly
tfpauly requested review from josephnoir, kkuk24 and rnro November 6, 2026 19:16
@tfpauly tfpauly added the 🔨 semver/patch No public API change. label Nov 6, 2026

// Try to send more data on all streams due to a received MAX_DATA or ACK
if applicationPendingItems.triggerAllStreamsUnblocked {
// The scan puts back every stream that can send now; one that still cannot is noted again.

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.

Can we improve the wording of this comment to be more explicit?

static let triggerAllStreamsUnblocked = Flags(rawValue: 1 << 1)
/// A stream with data to send was left off the list of streams to service for lack of
/// flow-control window, and nothing has put it back yet.
static let streamsMayBeBlocked = Flags(rawValue: 1 << 2)

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.

Should we distinguish between blocked by CC and blocked by FC? If the stream is blocked by FC, an ACK will not help.

@tfpauly
tfpauly force-pushed the tfp/stream-blocked-flag branch from 9a23325 to 974b6b9 Compare November 7, 2026 18:39
Comment on lines +2423 to +2424
/// Whether some stream holds data that it cannot send for lack of window, and so is not on the
/// list of streams to service. An ACK has to look for streams to put back only when this is set.

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.

This comment makes it sound like it isn't streams may be blocked but that one or more streams are blocked?

/// Records that a stream the list of streams to service declined has data it is waiting on window
/// to send, which is the only reason a stream with data is declined.
@inline(always)
private mutating func noteIfBlocked(_ stream: borrowing QUICStreamInstance) {

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.

is this "note if blocked" or "note interface blocked"? If it's the latter can we spell it out in full?

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.

Looking at the code it looks like the former. An unfortunate naming collision.

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.

Maybe we could work around this?

extension QUICStreamInstance {
    var sendDataBlocked: Bool {
        !self.send.state.dataHasAlreadyBeenSent && self.hasMoreSendDataToService
    }
}

private mutating func noteBlockageState(_ streamIsBlocked: Bool) {
    if streamIsBlocked { streamsMayBeBlocked = true }
}

// ...

noteBlockageState(newStream.sendDataBlocked)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants