Skip to content

geoprobe-agent: filter cached DZD measurements to avoid jittery measurements#3309

Open
ben-dz wants to merge 2 commits intomainfrom
bdz/doublezero-3219
Open

geoprobe-agent: filter cached DZD measurements to avoid jittery measurements#3309
ben-dz wants to merge 2 commits intomainfrom
bdz/doublezero-3219

Conversation

@ben-dz
Copy link
Contributor

@ben-dz ben-dz commented Mar 18, 2026

Resolves: #3219

Summary of Changes

  • Replace single-entry-per-sender offset cache with a two-slot (best + backup) strategy to prevent latency spikes when the best measurement expires
  • best slot holds the lowest RTT offset across the full validity window; backup holds the lowest RTT from the recent half-window, ensuring a smooth handoff when best expires
  • Higher-RTT offsets never overwrite a lower-RTT best; backup is refreshed when stale (older than half-maxAge) to guarantee remaining lifespan

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 1 +71 / -18 +53
Tests 1 +162 / -1 +161

Compact change — ~50 net lines of core logic, well-covered by 7 new test cases.

Key files (click to expand)
  • controlplane/telemetry/cmd/geoprobe-agent/main.go — new cachedSender struct with best/backup slots; rewritten Put() with RTT filtering and backup promotion, Get() with fallback to backup, GetBest() iterating both slots, Evict() checking both slots
  • controlplane/telemetry/cmd/geoprobe-agent/main_test.go — 7 new tests (PutKeepsBest, PutLowerRTTReplacesBest, BackupPromotion, BackupRefreshInHalfWindow, GetBestWithTwoSlots, EvictBothSlots) + updated PutReplaces expectation

Testing Verification

  • All 27 unit tests pass (go test -v -count=1 ./controlplane/telemetry/cmd/geoprobe-agent/...)
  • Backup promotion verified: best expires → backup takes over without spike
  • Half-window refresh verified: backup refreshed past half-maxAge so it has remaining lifespan when best expires
  • RTT filtering verified: worse measurements stored as backup, never overwrite best
  • Concurrent access test exercises all methods under contention

@ben-dz ben-dz added this to the Geo Location milestone Mar 18, 2026
@ben-dz ben-dz requested a review from nikw9944 March 18, 2026 20:42
@ben-dz ben-dz marked this pull request as ready for review March 18, 2026 20:43
@ben-dz ben-dz requested review from snormore and vihu March 18, 2026 21:07
@ben-dz ben-dz enabled auto-merge (squash) March 23, 2026 21:43
@ben-dz ben-dz disabled auto-merge March 23, 2026 21:44
ben-dz added 2 commits March 23, 2026 17:44
Replace the single-entry-per-sender offset cache with a two-slot (best +
backup) structure. The best slot holds the lowest RTT seen in the full
maxAge window, while the backup slot holds the lowest RTT from the recent
half-maxAge interval. When the best expires, the backup is promoted,
preventing latency spikes from losing a good measurement.

Fixes #3219
@ben-dz ben-dz force-pushed the bdz/doublezero-3219 branch from 02b48e6 to 35c94fb Compare March 23, 2026 21:44
@ben-dz ben-dz enabled auto-merge (squash) March 23, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

geolocation: filter cached dzd measurements

2 participants