Files
synapse/tests
Erik JohnstonandClaude Fable 5.1 cac962a4a7 Keep the test reactor's pending calls sorted incrementally
`twisted.internet.task.Clock` re-sorts its whole list of pending calls on every
`callLater` and after every call it runs. A test homeserver has dozens of
pending calls and the threadless database pool schedules a `callLater(0, ...)`
per transaction, so this showed up as ~10% of a test's time in profiles.

Insert new calls in order with `bisect.insort` and only re-sort after a call
was rescheduled with `reset` or `delay`.

Together with the previous commit, `tests.rest.client.test_rooms` goes from
44.9s to 32.7s and `tests.handlers` from 146s to 114s single-process on
SQLite; a 147-test Postgres subset from 85.9s to 74.4s.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PVLsNh6akt4ifEizY4D1ta
2026-10-18 13:14:42 +00:00
..
2026-09-18 12:00:45 +01:00
2026-10-14 13:35:25 +00:00