[wpt-sync] Sync PR 54653 - [wptserve] Move the H2 server to an event loop
Categories
(Testing :: web-platform-tests, task, P4)
Tracking
(Not tracked)
People
(Reporter: wpt-sync, Unassigned)
References
()
Details
(Whiteboard: [wptsync downstream])
Sync web-platform-tests PR 54653 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/54653
Details from upstream follow.
Sam Sneddon <gsnedders@apple.com> wrote:
[wptserve] Move the H2 server to an event loop
Previously, we were seeing acquiring the H2ConnectionGuard lock being very expensive on Python 3.13 and later, as in Python 3.13
Lock.acquirebegan to release the GIL, and with the large numbers of threads we create for our H2 server we saw performance grind to a stand still. I believe this was the underlying cause of #51981.Using asyncio, and using worker threads (via a worker pool) only for calling the handler code, we see this bottleneck go away.
Notably:
H2ResponseWriternow has to deal with aStreamWriterowned by another thread (this is unavoidable as we need to use aStreamWriterto handle async access to SSL sockets); this does introduce IPC here, but as far as I can tell this is still a net win even on older Python versions.We no longer wrap the socket into an
SSLSocketinWebTestServerfor the http2 case, and we now store the context we create. We use this context only after the accept() call, which should provide no functional difference.Otherwise: this is mostly a fairly simple replacement of threads with tasks.
Description
•