mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-15 07:01:22 +00:00
Two allocation classes the Rust port introduced over the old Python class: - start_inner/stop_inner (run on every context switch) and __enter__/__exit__ cloned the context-name String up front, though it is only needed in the misuse-error branches and the opt-in debug traces. Materialise it in those branches instead, and guard __enter__'s debug trace with log_enabled! as __exit__ already did, keeping the switch fast path allocation-free. - name/server_name were stored as Rust Strings, so every Python read built a fresh str — and LoggingContextFilter reads server_name plus str(context) on every log record process-wide. Store them (and the sentinel's counterparts) as Py<PyString> so getters and __str__ return the stored object INCREF-only, matching the old Python class. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JFbRtswu7rsHrttJFauUUb