Skip to content

Commit af2d12b

Browse files
committed
docs(sqs/throttle): refresh stale comments on idle-evict constants
Round-3 Claude review on PR #679 caught two stale comments left over from the runSweepLoop refactor: throttleIdleEvictAfter said "no goroutine; lookups call sweep() opportunistically" -- both clauses are now false (runSweepLoop is the goroutine, hot-path charge() never calls sweep()). throttleEvictSweepEvery said "bounds how often the sweep runs from the hot path" -- the hot path no longer runs sweep at all; this constant is now just the background ticker interval. Both updated to describe the post-runSweepLoop design and to reinforce that the sweep cost is amortised across the goroutine ticker rather than concentrated on whichever request was unlucky enough to trigger it (which was the old behaviour Gemini high flagged in PR #679 round 1).
1 parent c6d3a68 commit af2d12b

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

adapter/sqs_throttle.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,18 @@ const throttleHardCeilingPerSecond = 100_000.0
7373
const throttleMinBatchCapacity = float64(sqsBatchMaxEntries)
7474

7575
// throttleIdleEvictAfter is the idle window after which a quiet bucket
76-
// is dropped from the in-memory store. The evictor fires lazily — there
77-
// is no goroutine; lookups call sweep() opportunistically. A queue that
78-
// resumes activity rebuilds its bucket from the meta record at full
79-
// capacity, matching the failover semantics documented in §3.1.
76+
// is dropped from the in-memory store. A background goroutine
77+
// (runSweepLoop) fires the eviction sweep on each
78+
// throttleEvictSweepEvery tick; the hot path never calls sweep().
79+
// A queue that resumes activity rebuilds its bucket from the meta
80+
// record at full capacity, matching the failover semantics
81+
// documented in §3.1.
8082
const throttleIdleEvictAfter = time.Hour
8183

82-
// throttleEvictSweepEvery bounds how often the sweep runs from the hot
83-
// path so a flood of misses on a many-queue cluster cannot turn the
84-
// idle-evict cost into a per-request hot path.
84+
// throttleEvictSweepEvery is the interval at which runSweepLoop fires
85+
// the idle-evict sweep in its background goroutine. The hot-path
86+
// charge() never calls into the sweep so a many-queue cluster pays
87+
// the O(N) cost only on the goroutine's tick, never on a request.
8588
const throttleEvictSweepEvery = time.Minute
8689

8790
// bucketKey is the in-memory map key.

0 commit comments

Comments
 (0)