Skip to content

Fix WebTransportImpl session flow control granting too frequently#613

Open
afrind wants to merge 1 commit intofacebook:mainfrom
afrind:fix/wt-too-much-fc
Open

Fix WebTransportImpl session flow control granting too frequently#613
afrind wants to merge 1 commit intofacebook:mainfrom
afrind:fix/wt-too-much-fc

Conversation

@afrind
Copy link
Copy Markdown
Contributor

@afrind afrind commented Apr 20, 2026

shouldGrantFlowControl() was checking (getCurrentOffset() - bytesRead_) i.e. bytes buffered but not yet consumed by the app. After every read this drops to ~0, satisfying the < window/2 condition unconditionally and sending WT_MAX_DATA after every tiny read regardless of how much window the peer actually had remaining.

Fix: check (getMaxOffset() - bytesRead_) < window/2 instead — only grant when the app has consumed enough that the peer is within half a window of their limit. Also guard sendWTMaxData on the return value of recvFlowController_.grant() to avoid sending capsules when the flow controller is initialized to kMaxVarInt (no configured FC).

shouldGrantFlowControl() was checking (getCurrentOffset() - bytesRead_)
i.e. bytes buffered but not yet consumed by the app. After every read
this drops to ~0, satisfying the < window/2 condition unconditionally
and sending WT_MAX_DATA after every tiny read regardless of how much
window the peer actually had remaining.

Fix: check (getMaxOffset() - bytesRead_) < window/2 instead — only
grant when the app has consumed enough that the peer is within half a
window of their limit. Also guard sendWTMaxData on the return value of
recvFlowController_.grant() to avoid sending capsules when the flow
controller is initialized to kMaxVarInt (no configured FC).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@afrind afrind requested a review from joanna-jo April 20, 2026 17:48
@meta-cla meta-cla Bot added the CLA Signed label Apr 20, 2026
@afrind afrind requested a review from hanidamlaj April 20, 2026 17:48
.WillRepeatedly(Return(folly::unit));
}

TEST_F(HTTPTransactionWebTransportTest, FrequentFlowControlGrants) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

redundant test? i think this is already tested above?

@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Apr 21, 2026

@joanna-jo has imported this pull request. If you are a Meta employee, you can view this in D101809433.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants