Repository navigation
v3.4.0
-
feat: add PROTO.Cached<V> serializer 615cf12
function Cached<V>(s: PROTO.Serializable<V>, depth?: number): PROTO.Serializable<V>
Adds an LRU‑based caching wrapper for existing serializers.
The cache stores serialized output for up to N distinct values and evicts the least‑recently‑used entry when the limit is exceeded.
This reduces redundant serialization work and improves performance on repeated inputs.const cached = PROTO.Cached(PROTO.String, 32);
In a benchmark repeatedly serializing
"Hello World!", the cached serializer was 2x faster than the uncached serializer.
This performance benefit increases with larger data sizes.✓ tests/ipc.bench.ts > cached-benchmark 2202ms name hz min max mean p75 p99 p995 p999 rme samples · uncached 1,451,366.84 0.0003 35.7325 0.0007 0.0005 0.0010 0.0014 0.0035 ±15.68% 725684 · cached 2,910,978.18 0.0001 57.4089 0.0003 0.0003 0.0012 0.0015 0.0046 ±23.85% 1455492
Full Changelog: v3.3.1...v3.4.0