Expand description
The coarse clock expiry compares against.
04 section 5 is explicit about this: there is no global clock read on the
data path. The shard reads the clock once per turn of the loop and every
command in that batch of 64 compares against the same number. A clock read
is a vDSO call, so it is not a syscall, but it is still tens of nanoseconds
against a budget of a hundred and fifty for the whole command, and paying it
per command would mean paying it 64 times for one answer that did not change.
TIME and EXPIRETIME read the fine clock instead, because their contract
is to report the time and not to compare against it. That is what
Clock::fine_now_ms is for and it is the only thing that should call it.
A fixed clock is not a testing convenience bolted on the side. Expiry is the one part of a database whose behaviour is a function of the wall clock, and a test that sleeps to move time forward is a test that is slow and flaky at the same time. Every expiry test in this crate drives a fixed clock instead.
Structsยง
- Clock
- A millisecond clock that only moves when it is told to.