Add WAGED rebalance build/solve latency split and partial movement counter#207
Open
sjainit wants to merge 1 commit into
Open
Add WAGED rebalance build/solve latency split and partial movement counter#207sjainit wants to merge 1 commit into
sjainit wants to merge 1 commit into
Conversation
sjainit
requested review from
LZD-PratyushBhatt,
PranaviAncha,
arkmish,
kabragaurav,
laxman-ch,
ngngwr and
thestreak101
as code owners
July 2, 2026 07:57
sjainit
force-pushed
the
sjainit/waged-rebalance-observability
branch
from
July 2, 2026 08:06
f66f6df to
77d32a1
Compare
…unter Improve WAGED rebalancer observability on the global (baseline) and partial (best possible) paths: - Split the existing per-phase latency into a model-build span and an algorithm-solve span for each path, via four new latency gauges (GlobalBaselineCalcBuild/SolveLatencyGauge and PartialRebalanceBuild/SolveLatencyGauge). This lets a slow rebalance be attributed to cluster-model construction versus constraint solving. The existing overall latency gauges are retained for backward compatibility. - Count replica placements in the new best possible assignment that changed relative to the previous best possible assignment (PartialRebalanceReplicaMovementCounter) using a new ResourceUsageCalculator.countReplicaMovements helper. The best possible assignment is what actually drives state transitions, so this surfaces the churn / state-transition blast radius of each partial rebalance at intent-time (before throttling), attributable to the partial phase -- complementing the existing downstream Pending*RebalanceReplica gauges. Add a unit test for countReplicaMovements and extend TestWagedRebalancerMetrics to assert the new latency gauges and movement counter are populated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sjainit
force-pushed
the
sjainit/waged-rebalance-observability
branch
from
July 2, 2026 08:26
77d32a1 to
6669be8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issues
No dedicated GitHub issue was filed; this is a self-contained observability enhancement for the WAGED rebalancer. Happy to open a tracking issue if maintainers prefer.
Description
What: Add two kinds of observability to the WAGED global (baseline) and partial (best possible) rebalance paths:
Build vs. solve latency split. The existing
GlobalBaselineCalcLatencyGauge/PartialRebalanceLatencyGaugeeach wrap two very different phases — building the cluster model (generateClusterModelFor*) and solving it (WagedRebalanceUtil.calculateAssignment). This PR times those phases separately with four new latency gauges:GlobalBaselineCalcBuildLatencyGauge,GlobalBaselineCalcSolveLatencyGauge,PartialRebalanceBuildLatencyGauge, andPartialRebalanceSolveLatencyGauge. The original overall gauges are retained.Partial replica-movement counter. There was no metric for how much the served assignment changes between rebalances. This PR adds
PartialRebalanceReplicaMovementCounter, incremented by a newResourceUsageCalculator.countReplicaMovements(old, new)helper that counts replica placements in the newly computed best possible assignment that are new or changed relative to the previous one. The best possible assignment is what actually drives state transitions, so this measures churn at the point it matters. It is deliberately scoped to the partial (best possible) path rather than the baseline, since the baseline is the steady-state target and does not itself drive transitions.Why: Today a slow or churny WAGED rebalance is hard to diagnose. A single latency number can't tell an operator whether model construction or constraint solving is the bottleneck, and no metric quantifies the churn (state-transition blast radius) a rebalance introduces — a "fast" rebalance that moves thousands of replicas is far more impactful than its latency suggests. The movement counter captures this churn at intent-time (in the computed assignment, before throttling / IntermediateStateCalc cap it), attributed to the rebalancer phase — a leading indicator that complements the existing downstream, per-resource
PendingRecovery/LoadRebalanceReplicaGaugeandDifferenceWithIdealStateGaugesignals rather than duplicating them.How: Both runners already own a
MetricCollector. The build and solve calls are wrapped instartMeasuringLatency()/endMeasuringLatency()spans (usingtry/finallyso the build span is recorded even when model construction fails). After solving, the partial runner increments its movement counter withcountReplicaMovements(previousBestPossibleAssignment, newAssignment), guarded byisBestPossibleChangedso the diff pass is skipped when nothing changed. The new helper walks the assignment map fields and counts each(partition, instance)placement whose state is absent or different in the previous assignment; dropped replicas are intentionally not counted, matching the "work introduced by the new assignment" framing. All additions follow the existing enum +createMetrics()+getMetric(...)pattern inWagedRebalancerMetricCollector.Tests
The following tests are written for this issue:
TestResourceUsageCalculator#testCountReplicaMovements— covers identical assignments (0), empty new (0), empty previous (all replicas counted), a mixed case (relocation + state change + unchanged + dropped-not-counted), and a resource absent from the previous assignment.TestWagedRebalancerMetrics#testWagedRebalanceMetrics— extended to assert the four new build/solve latency gauges are measured and the partial replica-movement counter is positive after a from-scratch rebalance.Local code review completed
The following is the result of the "mvn test" command on the appropriate module:
Maven is not available in my local environment, so
mvn testwas not run locally; relying on the project CI to execute thehelix-coretest suite. The change is confined tohelix-coreand is covered by the unit tests listed above.Changes that Break Backward Compatibility (Optional)
None. All changes are additive: new metric enum values, new gauges/counter, and a new static helper. The existing overall latency gauges and all current metrics are unchanged, and no public API or rebalancing behavior is modified.
Documentation (Optional)
Not applicable — internal observability improvement with no new user-facing functionality.
Commits
Code Quality
🤖 Generated with GitHub Copilot CLI