statement-store: index subscriptions by topic for efficient statement matching#3281
Open
AndreiEres wants to merge 2 commits into
Open
statement-store: index subscriptions by topic for efficient statement matching#3281AndreiEres wants to merge 2 commits into
AndreiEres wants to merge 2 commits into
Conversation
alexggh
reviewed
Jun 9, 2026
| self.wildcard.insert(id.clone()); | ||
| } | ||
| // An empty `MatchAll` filter matches every statement. | ||
| TopicFilter::MatchAll(topics) if topics.is_empty() => { |
Contributor
There was a problem hiding this comment.
I wonder if we should just reject this one.
Contributor
There was a problem hiding this comment.
because, feels like an unintended usage of the API, I'm fine with keep it as it is.
alexggh
approved these changes
Jun 9, 2026
dmitry-markin
approved these changes
Jun 19, 2026
| for id in &candidates { | ||
| let sub = subscriptions | ||
| .get_mut(*id) | ||
| .expect("by_topic/wildcard only reference live subscriptions; qed"); |
Collaborator
There was a problem hiding this comment.
nit:
Suggested change
| .expect("by_topic/wildcard only reference live subscriptions; qed"); | |
| .expect("`candidates` is a subset of `subscriptions`; qed"); |
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3144
Closes #3147
Statements from the network were matched against every active subscription, giving
O(n_statements × n_subscriptions × topic_factors)complexity — a node re-scanned all subscriptions even for statements no one filtered on.Add a reverse
topic -> subscriptionsindex (plus awildcardset forAnyand emptyMatchAll, which match everything). For each statement, matching now considers only the wildcard subscriptions and those sharing one of its topics, then applies the exact per-subscription filter and dedup viaaccept. Filter semantics are unchanged; the index only narrows the candidate set.