matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.83k stars 2.13k forks source link

Support reactor timing on more reactors. #16532

Closed clokep closed 12 months ago

clokep commented 1 year ago

Supports timing reactor ticks on select and poll reactors, as well as epoll (which we previously supported). Also supports reactor timings when using the asyncio reactor (when used with an underlying select, poll, epoll, /dev/poll, or kqueue event loop).

DMRobertson commented 1 year ago

This seems unhappy on Linux (GHA runners, anyway):

  File "/home/runner/work/synapse/synapse/synapse/metrics/__init__.py", line 47, in <module>
    import synapse.metrics._reactor_metrics  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/synapse/synapse/synapse/metrics/_reactor_metrics.py", line 122, in <module>
    wrapper = reactor._poller.poll = CallWrapper(reactor._poller.poll)
              ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'select.epoll' object attribute 'poll' is read-only
clokep commented 1 year ago

This seems unhappy on Linux (GHA runners, anyway):

I was unable to fully test on Linux locally, was waiting for builds to run.

DMRobertson commented 1 year ago

Roger. Shout if you want a test minion to try anything out!

clokep commented 1 year ago

🤦 I fixed the epoll issue for asyncio, but not Twisted. Anyway...I think the current version will work?

erikjohnston commented 1 year ago

It seems to work happily on jki.re FWIW

clokep commented 1 year ago

It seems to work happily on jki.re FWIW

With asyncio or just in general?

erikjohnston commented 1 year ago

Sorry, that is using asyncio

clokep commented 12 months ago

I think this is a bit safer now and gives decent warnings like:

Skipping configuring ReactorLastSeenMetric: unexpected asyncio loop selector: <selectors.KqueueSelector object at 0x10de4ea50> via <_UnixSelectorEventLoop running=False closed=False debug=False>

or

Configuring ReactorLastSeenMetric failed: AttributeError("'select.kqueue' object attribute 'control' is read-only")

(the second one was by me introducing a bug intro the code)