Skip to content

fix: key the subscriber filter cache by a digest of the topics - #1408

Merged
dunglas merged 4 commits into
mainfrom
fix/subscriber-list-key-bytes
Sep 24, 2026
Merged

dunglas merged 4 commits into
mainfrom
fix/subscriber-list-key-bytes

Conversation

@dunglas

@dunglas dunglas commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

The cache key was every topic of the update concatenated, up to about 1 MiB, and the cache is bounded by entry count: a publisher with a wildcard grant could make the hub retain about 1 MB per publish, up to about 100 GB.

Changes

  • The key is a SHA-256 digest of the topics.
  • The update's topics are passed to the filter test per call through the new skipfilter.MatchFunc, so no shared state is locked while subscribers are tested.

Requires skipfilter v1.2.0 (dunglas/skipfilter#11).

Cache misses on 10k subscribers: 243µs → 12.5µs with 15 concurrent dispatches, 1.24ms → 99µs serially, 50k → 12 allocations each.

The cache key was every topic of the update concatenated, up to about 1 MiB,
and the cache is bounded by entry count: a publisher with a wildcard grant
could make the hub retain about 1 MB per publish, up to about 100 GB.
The shared in-flight map cost a lock per tested subscriber, which made
concurrent cache misses 2.4x slower than before the digest key.
@dunglas
dunglas force-pushed the fix/subscriber-list-key-bytes branch from 97f6bc7 to a13a41c Compare September 24, 2026 13:03
@dunglas
dunglas merged commit 9d64330 into main Sep 24, 2026
46 checks passed
@dunglas
dunglas deleted the fix/subscriber-list-key-bytes branch September 24, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant