-
-
Notifications
You must be signed in to change notification settings - Fork 136
perf minor and evaluate review #4244
Copy link
Copy link
Open
Labels
A-networkingArea: Networking, ring protocol, peer discoveryArea: Networking, ring protocol, peer discoveryE-easyExperience needed to fix/implement: Easy / not muchExperience needed to fix/implement: Easy / not muchT-enhancementType: Improvement to existing functionalityType: Improvement to existing functionality
Metadata
Metadata
Assignees
Labels
A-networkingArea: Networking, ring protocol, peer discoveryArea: Networking, ring protocol, peer discoveryE-easyExperience needed to fix/implement: Easy / not muchExperience needed to fix/implement: Easy / not muchT-enhancementType: Improvement to existing functionalityType: Improvement to existing functionality
Type
Fields
Give feedbackNo fields configured for issues without a type.
1 —
HashMap.keys().collect()in subscribe — evaluateBTreeMapLocation:
crates/core/src/operations/subscribe.rs:212Code:
let mut sorted_keys: Vec<_> = connections.keys().collect(); sorted_keys.sort();Problem: Allocates Vec + sorts keys. If connection set is large (100+) and changes infrequently,
BTreeMapmaintains sorted order (O(log n) insert) and eliminates per-query sort (O(n log n)).Action: Measure subscribe connection set size and churn. If <50 entries, close without action.
2 —
gateways.to_vec()in initial joinLocation:
crates/core/src/operations/connect.rs:1608Code:
let gateways = gateways.to_vec();Problem: Copies gateway slice (1–10 entries). Use
&[InitPeerNode]if borrow checker allows.Action: Check callers. Fix if ownership not required.