[0.5.2] - 2026-04-17
Performance Gains
v0.5.2 represents a massive leap in raw throughput and memory efficiency. By eliminating heap allocations and consolidating the serialization/fragmentation pipeline, Webshocket now hits staggering numbers:
- RPC: ~45,000 RPCs/s at 1.1 ms latency (asyncio, 50 concurrent clients)
- Streaming: 289 MB/s on asyncio, 421 MB/s with winloop
Measured on AMD Ryzen 5 5600G, 14 GB RAM, Windows, Python 3.13. Results vary by hardware.
Changed
- Zero-Allocation Serialization: Replaced
msgspec.encode()withencode_into()using a pre-allocatedbytearrayper connection, eliminating heap allocations on every send. - Unified
_send_rpc_responseFast Path: Merged_send_rpc_responseand_send_rpc_packetinto a single method that encodes directly into the per-connection buffer. - Extracted
_writePrimitive: Consolidated all fragmentation logic intoClientConnection._write(). All send paths delegate to it. - Broadcast & Publish Serialize-Once: Serialize the
Packetonce per wire format, then fan out pre-encoded bytes to all recipients. - Wire Format Reduction: Enabled
omit_defaults=TrueonPacket, reducing typical RPC payload size by ~20-35%. - Client Frame Queue Hardening: Increased client
_frame_queuecapacity to 8192 for burst tolerance. Added gracefulQueueFullhandling (log + drop) to prevent process crashes at the sync/async boundary. - Python 3.10 Support: Replaced
typing.Selfwith a string literal return annotation. Loweredrequires-pythonto>=3.10. Added 3.10 to CI matrix.
Added
RateLimitError,ClientType,RPCErrorCodeexported fromwebshockettop-level.DEFAULT_ENCODE_BUFFER_SIZEconstant (512 bytes) inconstant.py.- Benchmark Suite:
benchmark/benchmark.pywith 2×2 grid (RPC throughput, RPC latency, stream throughput, stream depth) andbenchmark/README.mdwith event loop selection guidance.
Fixed
- ReadTheDocs Build:
.readthedocs.yamlnow installs the package itself (method: pip, path: .), fixing empty API docs on the hosted site.