twitter / pelikan

Pelikan is Twitter's unified cache backend
Apache License 2.0
1.94k stars 176 forks source link

core/server: fix how latencies are calculated #450

Closed brayniac closed 2 years ago

brayniac commented 2 years ago

Previously, we used Instant::recent() to get a cached view of the monotonic clock and used that to set the timestamp for the sessions. This could result in incorrect latency reporting if the cached value is sufficiently stale or if another thread refreshes the cached value while a thread is processing many events.

This change corrects how the latency is being measured by using Instant::now() when poll returns as the timestamp for all events being processed in that loop iteration.