Skip to content

[Nexthop][bugfix] Assert ECMP balance as share of fair share in prune tests - #1744

Open
raghavv-nexthop wants to merge 2 commits into
meta:mainfrom
nexthop-ai:assert-ecmp-balance-as-share-of-fair
Open

raghavv-nexthop wants to merge 2 commits into
meta:mainfrom
nexthop-ai:assert-ecmp-balance-as-share-of-fair

Conversation

@raghavv-nexthop

@raghavv-nexthop raghavv-nexthop commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Pre-submission checklist

  • I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running pip install -r requirements-dev.txt && pre-commit install
  • pre-commit run

Summary

Based on #1595.

Issue:

AgentAdjFrrRouteTests and AgentFlowletSwitchingTests assert load balance as a min/max spread, (highest - lowest) / lowest. The cap is 25% (kMaxLoadBalanceDeviationPct), raised to 125% (kPrunedLoadBalanceDeviationPct) when the ingress port is a group member and gets pruned. hashSpreadBoundPct() also applies 125% to any group whose width is not a multiple of four.

Pruning concentrates traffic on purpose, so no single spread cap works for both pruned and unpruned phases. Same test, same boot, one phase apart:

Backup with primary next-hop ingress ... lowest increment: 211310, highest increment: 214625, deviation: 1.56879%
Backup with backup next-hop ingress  ... lowest increment: 170170, highest increment: 428230, deviation: 151.648%

The group is healthy (1.6% spread unpruned). Pruning moves the pruned member's share onto one survivor, which pushes the spread past even the relaxed 125% cap. This is deterministic to within about 1% across cold and warm boot, so it is expected behavior, not a regression.

The width % 4 relaxation keys off the wrong variable. A width-6 group is even when unpruned (lowest 2592, highest 2920, i.e. 95–107% of fair share) and skews only when pruned (highest 5600). The same 125% cap also lets a width-6 group pass with one member at 50% of fair share. As a result, sourcePortGetsPruned, sourcePortPruneWithEmptyPrimary, frrPruneFiveBackupsNoLoss, frrPruneSixBackupsNoLoss and VerifyDlbSecondaryPruneSixMembersNoLoss fail intermittently or consistently on Tomahawk5.

Fix:

Apply the participation check from #1595 to these suites. Each member must carry between a floor and a ceiling percentage of the fair share (total / numMembers):

  • Unpruned phases: [80, 125]. Any group within a 25% spread already lies inside this band, so it is at least as strict as the old cap, and stricter than the old % 4 relaxation.
  • Pruned phases: [25, 200] (the MemberShareBounds default). Measured pruned skew is 51–171% of fair share.

Changes:

  • LoadBalancerTestUtils.{h,cpp}: add isWithinMemberShareBounds(), for callers that hold one counter per member rather than a PortStats map. It reuses MemberShareBounds.
  • AgentAdjFrrRouteTests.cpp, AgentFlowletSwitchingTests.cpp: replace the spread constants with share bounds, and remove hashSpreadBoundPct() and its call sites.
  • Members that forwarded nothing are excluded before the bounds check, so they don't drag the fair share down. A missing member is still caught by the existing member-count and active-port assertions.

Notes:

  • Pruned spray skews in both directions (the lowest survivor gets 51% of fair share). No WCMP weights are programmed, so this most likely comes from hardware member selection. It is not investigated here.
  • Sprayed pruned phases in AgentAdjFrrRouteTests remain unasserted, as before.

Test Plan

Ran on Wedge800BACT with source-port pruning enabled:

./run_test.py sai_agent --config ./hw_test_configs/wedge800bact.agent.materialized_JSON --skip-known-bad-tests brcm/13.3.0.0_odp/13.3.0.0_odp/tomahawk5 --enable-production-features tomahawk5 --agent-run-mode=multi_switch --filter_file=filter.conf
[ PASSED ] cold_boot.AgentAdjFrrRoutePruneEnabledTest.frrPruneFiveBackupsNoLoss (24863 ms)
[ PASSED ] warm_boot.AgentAdjFrrRoutePruneEnabledTest.frrPruneFiveBackupsNoLoss (27439 ms)
[ PASSED ] cold_boot.AgentAdjFrrRoutePruneEnabledTest.frrPruneSixBackupsNoLoss (24912 ms)
[ PASSED ] warm_boot.AgentAdjFrrRoutePruneEnabledTest.frrPruneSixBackupsNoLoss (26648 ms)
[ PASSED ] cold_boot.AgentAdjFrrRoutePruneEnabledTest.sourcePortGetsPruned (11836 ms)
[ PASSED ] warm_boot.AgentAdjFrrRoutePruneEnabledTest.sourcePortGetsPruned (12951 ms)
[ PASSED ] cold_boot.AgentAdjFrrRoutePruneEnabledTest.sourcePortPruneWithEmptyPrimary (7725 ms)
[ PASSED ] warm_boot.AgentAdjFrrRoutePruneEnabledTest.sourcePortPruneWithEmptyPrimary (9001 ms)
[ PASSED ] cold_boot.AgentFlowletArsSourcePortPruneEnabledTest.VerifyDlbSecondaryPruneSixMembersNoLoss (18950 ms)
[ PASSED ] warm_boot.AgentFlowletArsSourcePortPruneEnabledTest.VerifyDlbSecondaryPruneSixMembersNoLoss (20141 ms)
Summary:
   PASSED : 10
   FAILED : 0
   SKIPPED : 0
   TIMEOUT : 0

@meta-cla meta-cla Bot added the CLA Signed label Oct 9, 2026
@raghavv-nexthop
raghavv-nexthop marked this pull request as ready for review October 14, 2026 00:51
@raghavv-nexthop
raghavv-nexthop requested a review from a team as a code owner October 14, 2026 00:51
@raghavv-nexthop raghavv-nexthop changed the title [Nexthop] Assert ECMP balance as share of fair share in prune tests [Nexthop][bugfix] Assert ECMP balance as share of fair share in prune tests Nov 2, 2026
@github-actions github-actions Bot added nexthop project:bugfix FBOSS project: bugfix labels Nov 2, 2026
@raghavv-nexthop

Copy link
Copy Markdown
Contributor Author

/autorebase

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant