Skip to content

perf minor and evaluate review #4244

@Basedfloppa

Description

@Basedfloppa

1 — HashMap.keys().collect() in subscribe — evaluate BTreeMap

Location: crates/core/src/operations/subscribe.rs:212

Code: 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, BTreeMap maintains 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 join

Location: crates/core/src/operations/connect.rs:1608

Code: 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-networkingArea: Networking, ring protocol, peer discoveryE-easyExperience needed to fix/implement: Easy / not muchT-enhancementType: Improvement to existing functionality

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions