Files
Erik JohnstonandClaude Opus 5 3b70d7c70a Add a clock to the Rust crate
Rust code increasingly needs the current time somewhere it cannot cheaply
ask Python for it: on a Tokio worker without the GIL, or deep inside a data
structure where reaching back out to a `synapse.util.clock.Clock` would mean
threading a `Py<PyAny>` through everything. Up to now there was no clock at
all in `rust/src` — the rendezvous handlers each held a `Py<PyAny>` and
called `time_msec()` on it per request.

Add `synapse::clock`, a wall clock matching `Clock.time_msec()` so times mean
the same thing on both sides of the boundary. It reads `SystemTime::now()`,
which on Linux is a vDSO call rather than a syscall.

Synapse's tests run against a virtual reactor clock, and it is important that
time in tests only moves when a test says so. The test reactor therefore pins
this clock to its own time; `tests.unittest.TestCase` unpins it afterwards so
it cannot leak between tests.

Port both rendezvous handlers over, which removes a Python round-trip per
rendezvous request and exercises the virtualisation against the existing
tests that drive session eviction by advancing the reactor.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HyuiV3m44ZbK9o24EnMMES
2026-07-27 10:53:27 +00:00
..
2026-07-27 10:53:27 +00:00