[improve][broker] Reduce topic watcher update overhead for large topic lists
Search before reporting
- [x] I searched the existing issues and did not find one tracking this specific optimization.
Motivation
When a matching topic is added or removed, TopicListWatcher computes a hash of its updated matching topic set. The current TopicList.calculateHash implementation copies and sorts the full collection before hashing it, even when the update changes only one topic.
For pattern subscriptions matching a large number of topics, frequent topic creation or deletion may make this repeated work significant. It would be useful to understand how the cost grows with topic count and update rate.
Possible improvement
Explore whether repeated work in this path can be reduced while keeping the existing topic-list hash semantics and client/broker reconciliation behavior compatible.
The choice of data structures or computation strategy is open for discussion.
Code references
Anyone interested is welcome to propose an approach and submit a PR for this improvement. The implementation details are open for discussion.