ENG-12735: reflex-bench wire suite (hydration, event and collection-delta payload sizes)
Linear: ENG-12735 (project P-ENG-487, Holistic Framework Benchmarks). Stacked on #7292 (memory suite); nothing merges until the whole stack is complete.
Description
Adds a wire suite to reflex-bench: the bytes a Reflex app puts on the websocket. The harness measured time, CPU and memory, but no payload sizes: not the hydration payload, not the bytes per event, and not the delta size of small changes to large collections.
All metrics are exact byte or frame counts (assume="exact", deterministic for a fixed app and version), so compare flags any change.
| Id | Metrics |
|---|---|
wire.hydrate | hydrate_sent_bytes, hydrate_received_bytes, hydrate_frames; extra: sent frames, largest frame, the initial delta's bytes per substate |
wire.event[shape=simple|complex|cross|background] | request_bytes, response_bytes, response_frames; extra: the reply frames and delta bytes per substate |
wire.delta[change=set_scalar|append_item|set_one_item|set_dict_key|update_row_field] | response_bytes for a one-item change to a 1000-int list, a 1000-key dict and 200 rows; set_scalar is the control |
Suites: wire.hydrate and wire.event[shape=simple] in pr and smoke; everything in daily.
How bytes are counted: WireSession wraps one websockets connection and counts every frame's payload (UTF-8 length for text, raw length for binary).
- Hydration runs from the engine.io open frame until the delta with
is_hydrated: true. The sent side is the namespace join +hydrate+on_load_internal(+ pongs). - An exchange is the request frame, then every frame received until the delta echoes the request's
seq. So 0.8.23's extrafinalupdate and any interleaved delta are counted. new_tokenis adopted and pings are answered; session-ending frames raiseProtocolError.- Each sample starts a fresh prod backend (memory manager, one granian worker) through the memory suite's
_Started+conclude, so a timed-out sample still stops it.
Fixtures: wire.hydrate and wire.event drive the playground (dims.fixture = playground). wire.delta writes a small generated app with the large collections into its cache directory (dims.fixture = wire_delta, with a content hash of the generated sources), so the playground and its hash stay unchanged. The generated app uses only rx. APIs (checked by an AST test).
Real numbers (HEAD, one run)
| Id | Bytes |
|---|---|
wire.delta[change=set_scalar] | 136 |
wire.delta[change=append_item] (1000-int list) | 4,027 |
wire.delta[change=set_one_item] | 4,023 |
wire.delta[change=set_dict_key] (1000-key dict) | 13,913 |
wire.delta[change=update_row_field] (200 rows) | 6,584 |
wire.event simple / complex / cross / background: request | 218 / 226 / 224 / 229 |
| same: response (1 frame each) | 116 / 275 / 203 / 116 |
wire.hydrate sent / received / frames | 414 / 2,203 / 4 |
A one-item change to a collection costs 30–100× a scalar change, because the whole collection is resent. This is now tracked, so a delta optimization will show up as a drop.
Checks
| Check | Result |
|---|---|
uv run pytest tests/units/reflex_bench -q | 675 passed, 7 skipped (27 new tests in suites/test_wire.py, all with fakes or a loopback echo server) |
| ruff check / format, pyright, pre-commit | pass |
reflex-bench run --suite daily 'wire.*' --runs 1 (real, HEAD) | all 10 instances ok, ~1.8 s each, no leftover processes |
Changes to lower PRs
None. wire.py imports _Started and START_TIMEOUT_S from suites/memory.py (#7292).