currentTime, upTime, clocks, timers and the bugs nobody ta...
summary
Shows a real production bug where using System.currentTimeMillis bug for a rate limiter fails because wall clocks jump (team devices logged jumps of 2s, 5.5s and 28.5s). Replaces wall time with Android SystemClock.elapsedRealtime for intervals, builds a monotonic ticker, a Timestamp and Deadline API to avoid math, and an anchored clock to mix server timestamps with monotonic deltas. Covers testing, lint/CI enforcement and strategies to roll changes without breaking customer metrics.
AI-written summary · about
chapters (18)
- 0:00Introduction and speaker intro
- 1:04Spot the bug game
- 2:50Wall clock time issues
- 4:13Monotonic clocks overview
- 6:20Choosing clocks for rate limiter
- 7:01API design goals and challenges
- 8:26Clock library comparison
- 11:36Requirements for clock APIs
- 11:57Monotonic Ticker API design
- 14:05Epic Clock and Timestamp API
- 15:53Deadline class implementation
- 17:59Rate limiter refactor demo
- 18:42Anchored Clock use case
- 19:24Anchored Clock API details
- 20:50Preventing AI cargo culting
- 21:53Breaking changes and customer impact
- 23:17Key takeaways and best practices
- 24:42Sentry features and closing
