mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-09 08:04:45 +00:00
Two server bugs masking each other made a single giant REQ crawl and then wedge: LiveEventStore's historical-replay dedup used an immutable Set under an AtomicReference with copy-on-add — set + id copies the whole set per streamed event, so large replays were accidentally O(n²) (100k-event REQ: ~700 events/s, degrading as the response grew). Replaced with a spin-lock-guarded mutable HashSet (same threads, single contains/add per critical section). Fixing that unmasked WebSocketSessionPump's slow-client policy: a fast replay instantly overflowed the 8192-frame cap — which conflated 'slow client' with 'replay outruns the socket writer', normal for bulk — and the 'drop' only closed the internal queue, leaving the socket half-dead (no EOSE, no close frame, tail silently missing: the likely cause of the benchmark's 99,998/100,000). Producers are now paced against a full backlog (bounded blocking wait, consistent with the documented ingest fanout behavior) and only a client still behind after 30s is dropped, by actually cancelling the socket. GiantReqStreamTest guards the regression: 20k-event REQ pre-fix 8.4s (~2.4k events/s), post-fix 0.7s (~27k events/s), all events + EOSE delivered. 96 geode tests and the quartz relay/server suites pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018saXqYfAa3RvSJoDXK591R