Issue
leaseState.expiry is atomic.Pointer[time.Time] (kv/lease_state.go). Every extend() allocates a new time.Time on the heap. Under heavy write load the per-Dispatch allocation rate is 1:1 with throughput — at 50k Dispatch/s, that is 50k allocs/s plus matching GC pressure. Performance reviewer flagged as HIGH on PR #549.
Fix
Store expiry as atomic.Int64 holding UnixNano(). valid() compares against time.Now().UnixNano(). Zero allocation, single 8-byte atomic.
Caveat
Loses Go's monotonic-clock comparison: time.Now().UnixNano() returns wall-clock nanoseconds. A backward NTP step could prematurely expire the lease (safe direction) or extend it (unsafe direction). Mitigation: pair with #issueX (CLOCK_MONOTONIC_RAW) or use runtime.nanotime() via //go:linkname.
Acceptance
BenchmarkLeaseStateExtend shows 0 allocs/op.
- All existing lease tests pass.
- Document the wall-clock dependency or close together with the monotonic-source decision.
References: PR #549 (deferred).
Issue
leaseState.expiryisatomic.Pointer[time.Time](kv/lease_state.go). Everyextend()allocates a newtime.Timeon the heap. Under heavy write load the per-Dispatch allocation rate is 1:1 with throughput — at 50k Dispatch/s, that is 50k allocs/s plus matching GC pressure. Performance reviewer flagged as HIGH on PR #549.Fix
Store
expiryasatomic.Int64holdingUnixNano().valid()compares againsttime.Now().UnixNano(). Zero allocation, single 8-byte atomic.Caveat
Loses Go's monotonic-clock comparison:
time.Now().UnixNano()returns wall-clock nanoseconds. A backward NTP step could prematurely expire the lease (safe direction) or extend it (unsafe direction). Mitigation: pair with #issueX (CLOCK_MONOTONIC_RAW) or useruntime.nanotime()via//go:linkname.Acceptance
BenchmarkLeaseStateExtendshows 0 allocs/op.References: PR #549 (deferred).