mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-09 08:04:45 +00:00
Audit follow-up on the timeout work. - fetchAllPages matched each event with `for ((i, f) in activeFilters)`. That destructuring form allocates an Iterator on every event, on the relay's reader thread, for the whole download -- millions of short-lived objects in a bulk walk. Switched to an indexed loop, which is why quartz uses the fast* operators elsewhere in hot event paths (those only cover Array, so a List needs the index form). - count() and fetchFirst() drain their channels in an inner loop that only suspends when the channel is empty, so a backlog was consumed with no cancellation check: neither the idle window expiring nor the caller giving up could interrupt it mid-drain. Added an explicit ensureActive(), matching the check fetchAllPages already does per page. - count() could also lose a result that arrived after the last window closed but before unsubscribe, understating the returned map. Added the post-loop tryReceive drain that fetchAllWithHooks and fetchFirst have. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KZe1Pq2ejoHehdufhPDRgb