mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 22:07:34 +00:00
Phase 0 of the event persistence plan, apart from the write transaction helper: - `experimental_features.rust_event_persistence`, one ordered level (off, shadow, prepare, transaction, full). Nothing uses the levels yet beyond building the persister. - `RustHandlers.persister`: built on the events writer when the level is not off and the main database uses the native driver. It holds the pool, the shared caches and the events, backfill and cache stream trackers. - `PersistEffects`, the Python cache updates a Rust transaction will ask for in place of `txn.call_after`, applied in one call by `DataStore._apply_rust_persist_effects`. A test persists batches through Python and checks that applying the matching effects updates the same caches. The chunk's stream IDs come back unfinished and are finished last, as Python's `get_next_mult` does after the transaction's callbacks, so the current token never passes an event the stream change caches don't know about. - `PersistContext`, read from an `EventContext` once per event. - `Event::to_persistence_value` and `EventInternalMetadata::to_persistence_value`: the `event_json` columns built without the GIL. - Rust-side persistence counters, added to the Python metrics by a pre-collect hook. A homeserver can now register more than one such hook. The persisted position is reported only when it moved, so it can't pull back the gauge the Python path sets. - `SYNAPSE_TEST_RUST_PERSIST` for trial and `RUST_PERSIST` for Complement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UHKYPSc37kWqGACn9aKxKL