Skip to content

Fix BBR MinRtt validity checks#6118

Merged
guhetier merged 2 commits into
microsoft:mainfrom
Wizmann:fix-bbr-minrtt-validity
Jul 6, 2026
Merged

Fix BBR MinRtt validity checks#6118
guhetier merged 2 commits into
microsoft:mainfrom
Wizmann:fix-bbr-minrtt-validity

Conversation

@Wizmann

@Wizmann Wizmann commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix BBR's invalid MinRtt handling to consistently use the existing MinRttTimestampValid state instead of relying on an incorrect sentinel comparison.

Motivation

BBR's model depends on two independent path estimates:

  • bottleneck bandwidth (BtlBw)
  • round-trip propagation time (RTprop, represented here by MinRtt)

The BBR paper describes RTprop as a windowed minimum RTT estimate. BBR should only use that estimate after a valid RTT sample has established it. Until then, calculations based on BDP (BtlBw * RTprop) should use startup-safe fallback behavior instead of consuming an uninitialized sentinel value.

In this implementation, MinRtt is initialized to UINT64_MAX, while validity is separately tracked by MinRttTimestampValid. However, some code paths checked MinRtt == UINT32_MAX to decide whether the estimate was unavailable. Since UINT64_MAX != UINT32_MAX, those paths could incorrectly treat an invalid MinRtt as valid.

This matters because an invalid RTprop estimate can affect:

  • target cwnd calculation
  • paced send allowance fallback
  • ProbeRTT entry decisions

ProbeRTT is meant to refresh an existing RTprop estimate after it expires. If no valid MinRtt sample has ever existed, entering ProbeRTT is not useful; BBR should remain in startup/model-building behavior until a valid RTT sample exists.

Change

This change replaces invalid MinRtt checks with !Bbr->MinRttTimestampValid.

That makes the code match the actual state model:

  • MinRttTimestampValid == FALSE: no valid MinRtt/RTprop sample exists yet
  • MinRttTimestampValid == TRUE: MinRtt can safely participate in BDP, pacing, and ProbeRTT decisions

Specifically, the change ensures:

  • target cwnd falls back safely when no MinRtt sample exists
  • send allowance does not use paced calculations before MinRtt is valid
  • BBR does not enter ProbeRTT before it has a valid MinRtt estimate to refresh

Tests

Updated and added BBR unit coverage:

  • verifies send allowance falls back to available congestion window before a valid MinRtt sample exists
  • verifies target cwnd falls back to the initial congestion window when bandwidth exists but MinRtt is still invalid
  • verifies BBR remains in STARTUP instead of entering ProbeRTT when no valid MinRtt sample exists

@Wizmann
Wizmann requested a review from a team as a code owner June 26, 2026 04:18
@Wizmann

Wizmann commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

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 fixes BBR’s handling of an “invalid/uninitialized MinRtt” by removing an incorrect sentinel comparison (MinRtt == UINT32_MAX) and consistently using the existing validity flag (MinRttTimestampValid). This aligns BBR’s control logic with its internal state model so BDP- and pacing-based computations don’t consume MinRtt before any valid RTT sample exists.

Changes:

  • Replace incorrect MinRtt == UINT32_MAX checks with !MinRttTimestampValid in target cwnd and send allowance calculations.
  • Prevent transitions to BBR_STATE_PROBE_RTT unless a valid MinRtt sample has been established.
  • Update/add BBR unit tests to validate safe fallback behavior when MinRtt is invalid (including ensuring BBR stays in STARTUP instead of entering PROBE_RTT).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/core/bbr.c Uses MinRttTimestampValid to gate target cwnd, pacing send allowance, and ProbeRTT entry to avoid consuming an invalid MinRtt sentinel.
src/core/unittest/BbrTest.cpp Updates the send allowance test expectation and adds coverage verifying target cwnd fallback + no premature ProbeRTT when MinRtt is invalid.

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.55%. Comparing base (51d449b) to head (1c4d205).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6118      +/-   ##
==========================================
- Coverage   86.15%   85.55%   -0.61%     
==========================================
  Files          60       60              
  Lines       18857    18911      +54     
==========================================
- Hits        16247    16179      -68     
- Misses       2610     2732     +122     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@guhetier guhetier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR! LGTM, minor nitpick to clarify a comment.

Comment thread src/core/unittest/BbrTest.cpp Outdated
Co-authored-by: Guillaume Hetier <hetier.guillaume@gmail.com>
@guhetier
guhetier enabled auto-merge (squash) July 1, 2026 17:07
@Wizmann

Wizmann commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Suggestion patched. Ready to merge :)

@guhetier
guhetier merged commit 881bb5d into microsoft:main Jul 6, 2026
553 of 555 checks passed
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