mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 13:28:04 +00:00
On the native Postgres driver, the Rust queues' `NativeHooks` read the device EDUs and record finished transactions through `FederationStore`, on tokio. A transaction then takes no trip to the reactor, unless it finishes a sticky event batch or a module wants to hear about delivered events. Catch-up and the sticky event backlog stay Python. SQLite and the Python Postgres driver keep the Python hooks. Python skips the device queries for destinations with nothing new by asking two stream change caches. Rust keeps a mirror of each, per destination, fed by a new `StreamChangeCache.add_listener`, so it hears of every change the caches do. The current stream positions live in Python's ID generators, and are read under the GIL (without a reactor trip) only when a destination has changed. The loops now count their transactions, EDUs and requests in Rust. `synapse.metrics.pre_collect_hooks` adds the counts to the Python metrics when they are collected. This removes a GIL crossing on every failed send, and from `_rust_complete`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R5b7Ruy4cgt27Mjq6Ptxbb