Skip to content

coord/cluster: latency-gradient tracker minRTT/curRTT (v0.12 phase 3) - #4

Merged
incognick merged 1 commit into
mainfrom
v0.12-gradient
Jun 29, 2026
Merged

coord/cluster: latency-gradient tracker minRTT/curRTT (v0.12 phase 3)#4
incognick merged 1 commit into
mainfrom
v0.12-gradient

Conversation

@incognick

Copy link
Copy Markdown
Contributor

v0.12 adaptive load shedding — Phase 3 of 5 (ADR-0039 part 2), on top of Phase 2's per-op latency.

Adds a loop-owned, deterministic RTT gradient tracker to the coordinator, one per op type (PUT/GET — different cost profiles):

  • minRTT — best-case service time, a re-probing two-window minimum that can rise when the genuine floor degrades (the signal Phase 5 watches; not a permanent all-time min).
  • curRTT — short-window EWMA of recent latency.
  • gradient = clamp(minRTT/curRTT, 0..1) — ≈1 healthy, →0 as queuing inflates curRTT; reads 1 (healthy) before a 5-sample warmup so a fresh node never looks overloaded.

Design:

  • Single timing source: observeLatency times once on the seam clock and feeds both the Phase-2 histogram and the tracker, so they can never diverge.
  • Decoupled: coordinator exposes Gradient/MinRTT/CurRTT accessors; internal/cluster reads them on the loop via a scrape collector — the coordinator still never imports internal/metrics.
  • Gauges hamster_s3_request_{gradient,min_rtt_seconds,cur_rtt_seconds}{method} — I aligned the prefix with the Phase-2 hamster_s3_request_duration_seconds so all four request-level signals group together.
  • Computes/exposes the signal only — no shedding yet (that's Phase 4).

Constants (ADR leaves these to implementation): minWindowSamples=200, curAlpha=0.2, gradientWarmup=5 — all commented.

Tests: pure unit (TestGradientWarmup, TestGradientFallsAsLatencyRises, TestMinRTTRisesAfterReprobe, TestEmptyTracker, TestCoordinatorAccessors) + sim (TestGradientTracksObservedLatency, asserting minRTT == min(observed) → single source). task check/build/test + -race on the tracker green. (One unrelated load-induced flake in the real-process cluster suite passed on re-run — CI's cluster job has the bounded retry for it.)

Adds a loop-owned, deterministic RTT gradient tracker to the coordinator
(ADR-0039 part 2), one per operation type since a PUT (k+m shards) and a GET (k
shards) have different cost profiles. Per op it maintains minRTT — the best-case
service time, a re-probing two-window minimum that can RISE again when the
genuine floor degrades (the signal part 5 watches) — and curRTT, a short-window
EWMA of recent latency; the gradient is clamp(minRTT/curRTT, 0..1), ~1 healthy
and ->0 as queuing inflates curRTT above the floor, reading 1 (healthy) before a
short warmup so a fresh node never looks overloaded.

It is fed from the same per-op sample observeLatency reports — timed once on the
seam clock, handed to both the histogram and the tracker — so the two never
diverge. Exposed as hamster_s3_request_{gradient,min_rtt_seconds,cur_rtt_seconds}
{method} via the coordinator-accessor + scrape-collector pattern the durability
gauges use, so the coordinator still never imports internal/metrics. Names share
the hamster_s3_request_ prefix with the duration histogram so the request-level
signals group together.

Computes and exposes the signal only; shedding comes in part 3/4.

Signed-off-by: Nicholas Phillips <nsphilli@gmail.com>
@incognick
incognick enabled auto-merge June 29, 2026 02:48
@incognick
incognick added this pull request to the merge queue Jun 29, 2026
Merged via the queue into main with commit ea5acf9 Jun 29, 2026
7 checks passed
@incognick
incognick deleted the v0.12-gradient branch June 29, 2026 02:57
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.

1 participant