mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 19:57:45 +00:00
Port `MatrixFederationHttpClient._send_request` and `_handle_response` to Rust, over the phase 1 agent: destination validation and the whitelist, the retry limiter, `X-Matrix` signing per attempt, the long and short retry schedules with jitter, `wake_destination`, timeouts on the virtual clock, the trailing slash retry, and the mapping of each failure to the exception Python raises. The JSON parsers run on tokio without the GIL. Python's decoder is the fallback for the JSON serde_json refuses, such as lone surrogates. A custom `ByteParser` is fed under the GIL in 64 KiB chunks. The transaction manager's `json_data_callback` becomes a `rewrite_age_ts` option, so a retry needs no call into Python. The retry timings are read through a Rust mirror of `get_destination_retry_timings`. Writes go to a Python callable, which invalidates the cache across workers and reports a server coming back. Every GIL acquisition in the federation code goes through `with_gil`, which counts calls and hold time per call site. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R5b7Ruy4cgt27Mjq6Ptxbb