fix(wpt): absorb parallel fixture connection bursts

The inherited listen backlog of five makes concurrent browser connections
wait for TCP retries before fixture handlers run. Match wptserve's backlog
of 2000 for every IPv4/IPv6 origin without changing test timeouts.

Add real socket tests that queue a complete 50-worker burst before the
accept loop starts. Both address families time out before this change and
connect successfully afterward.

With the same frozen release binary, Worker error stress changes from
86/100 passes to 150/150 after changing only the backlog. Script-order
and worker XHR timing cases each pass all 30 additional trials.

Validation: 81 Python tests across connection backlog, fixture resources,
fixture responses and runner orchestration; git diff --check.
This commit is contained in:
ldm0
2026-10-17 23:45:19 +08:00
parent c39b830c61
commit fc9e84a099
2 changed files with 44 additions and 0 deletions
@@ -1847,6 +1847,11 @@ def _wpt_cookie_websocket_set_cookie(query: str) -> str | None:
class _FixtureThreadingHTTPServer(ThreadingHTTPServer):
# Match wptserve: parallel browsers open bursts of subresource connections.
# The stdlib backlog of five makes them wait for TCP retransmissions before
# their requests reach a handler, changing the timing the cases measure.
request_queue_size = 2000
def handle_error(self, request: object, client_address: object) -> None:
# Disposing a case BrowserContext intentionally cancels any auxiliary
# requests that outlive the harness result. The stdlib server prints a
@@ -0,0 +1,39 @@
from __future__ import annotations
import socket
import unittest
from contextlib import ExitStack, closing
from http.server import BaseHTTPRequestHandler
from moli_benchmark.wpt_cross.server import (
_FixtureThreadingHTTPServer,
_Ipv6ThreadingHTTPServer,
)
class FixtureConnectionBacklogTests(unittest.TestCase):
def assert_worker_burst_can_connect(
self,
server_class: type[_FixtureThreadingHTTPServer],
address: tuple[str, int],
) -> None:
# Hold the accept loop so all connections coexist in the listen queue.
# This isolates queue capacity from handler speed and TCP retry timing.
with server_class(address, BaseHTTPRequestHandler) as server:
host, port = server.server_address[:2]
with ExitStack() as connections:
for _ in range(50):
connections.enter_context(closing(socket.create_connection(
(host, port), timeout=1,
)))
def test_loopback_listener_accepts_a_full_worker_burst(self) -> None:
self.assert_worker_burst_can_connect(
_FixtureThreadingHTTPServer, ("127.0.0.1", 0),
)
@unittest.skipUnless(socket.has_ipv6, "IPv6 is unavailable")
def test_ipv6_listener_accepts_a_full_worker_burst(self) -> None:
self.assert_worker_burst_can_connect(
_Ipv6ThreadingHTTPServer, ("::1", 0),
)