feat(monitor): dynamic coordinator→edge sampling coupling (coordinator half) - #368
Merged
Merged
Conversation
…r half) Wires the coordinator side: it tracks each edge's reported per-window rate, computes a per-edge update-sampling probability p_i that minimizes total edge update work at a target accuracy, and ships it in each edge's SlackGrant.sample_p — orthogonal to the slack countdown (sampling is an additive grant field). Proto: SlackGrant.sample_p (field 6) + MonitorReport.rate (field 8); prost regenerates the bindings at build. - sampling_alloc.rs (new): Rust port of the Go AllocateSampleRates — p_i = clamp(sqrt(λ)·sqrt(f_i/rate_i), 0, 1] with λ tuned by bisection so the merged sampling-variance Σ f_i(1−p_i)/p_i ≤ var_budget binds; uniform_sample_rate; and epsilon_sample_floor (p ≥ 1/(1+ε²·rate)) — the ε_cdm ≳ ε_s coupling rule made pointwise. Edge cases mirror the Go impl (rate≤0/freq≤0 ⇒ p=1). - coordinator.rs: EdgeView.rate tracked from MonitorReport.rate via on_report; Action::Grant carries sample_p; allocate_p() builds the per-edge rate vector, calls allocate_sample_rates, clamps each p_i up to the ε-floor; rebroadcast grants p_i only with ≥2 edges (single-edge/unknown ⇒ p=1). Slack/alert logic untouched. - server.rs: apply_report/handle_msg thread rep.rate → on_report; dispatch sets SlackGrant.sample_p from Action::Grant. - var_budget = (ε·τ)²: the CDM tolerance on the monitored value, in quantities the coordinator already holds (ε, τ from MonitorConfig) — the design doc's ε_cdm ≳ ε_s coupling. The per-edge floor enforces it pointwise too. Tests: allocation (skewed fleet beats uniform-p at equal variance; flat fleet no win; floor/edge cases); coordinator (single edge ⇒ p=1; skewed rates ⇒ differentiated sample_p, hot<quiet, both ≥ ε-floor, slack untouched). Plus the cross-language wire gate (crates/asap_otel_proto/tests/coupling_wire_compat.rs): Go-encoded SlackGrant.sample_p + MonitorReport.rate decode field-exact here. cargo build -p data_plane clean; monitor + full --lib suite green. Pairs with the edge half in ASAPCollector. See docs/distributed-nitrosketch-coordinated-sampling.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
zzylol
added a commit
that referenced
this pull request
Jun 11, 2026
…ield test(monitor): fix monitor_grpc integration-test compile (rate field from #368)
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.
Coordinator half of the dynamic coordinator↔sampling coupling
Completes the loop: the coordinator tracks each edge's reported per-window
rate, computes a per-edge update-sampling probabilityp_ithat minimizes total edge update work at a target accuracy, and ships it in each edge'sSlackGrant.sample_p— orthogonal to the slack countdown (sampling is an additive grant field; alert logic untouched).sampling_alloc.rs(new — port of the GoAllocateSampleRates)p_i = clamp(√λ·√(f_i/rate_i), 0, 1], λ tuned by bisection so the merged sampling-varianceΣ f_i(1−p_i)/p_i ≤ var_budgetbinds.epsilon_sample_floor:p ≥ 1/(1 + ε²·rate)— theε_cdm ≳ ε_scoupling rule made pointwise, so sampling noise can't exceed the CDM tolerance.rate≤0/freq≤0 ⇒ p=1).Coordinator wiring
EdgeView.ratetracked fromMonitorReport.rate(on_report).allocate_p()builds the per-edge rate vector, calls the allocator, clamps eachp_iup to the ε-floor;rebroadcastgrantsp_ionly with ≥2 edges (single-edge/unknown ⇒p=1).server.rsthreadsratethrough and setsSlackGrant.sample_pfromAction::Grant.var_budget = (ε·τ)²— the CDM tolerance on the monitored value, in quantities the coordinator already holds (ε,τfromMonitorConfig).Tests
Allocation (skewed fleet beats uniform-
pat equal variance; flat fleet no win; floor/edge cases); coordinator (single edge ⇒p=1; skewed rates ⇒ differentiatedsample_p, hot < quiet, both ≥ ε-floor, slack untouched); plus the cross-language wire gate (crates/asap_otel_proto/tests/coupling_wire_compat.rs): Go-encodedSlackGrant.sample_p+MonitorReport.ratedecode field-exact here.cargo build -p data_planeclean; monitor (22) + full--libsuite green.Pairs with the edge half in ASAPCollector (reports
rate; applies the grantedsample_pviaWithSamplePat the epoch boundary, family-gated to CMS/Count-Sketch/DDSketch). Validated end-to-end across the wire, both directions.🤖 Generated with Claude Code