Skip to content

perf(transport): Optimize protocol name construction on substream open#607

Open
dimartiro wants to merge 1 commit into
paritytech:masterfrom
dimartiro:perf/substream-protocol-construction
Open

perf(transport): Optimize protocol name construction on substream open#607
dimartiro wants to merge 1 commit into
paritytech:masterfrom
dimartiro:perf/substream-protocol-construction

Conversation

@dimartiro
Copy link
Copy Markdown
Contributor

Summary

Protocol negotiation lists were rebuilt on every substream open even though they are static after handler initialization. Precompute them once and share via Arc:

  • TransportService precomputes Arc<[ProtocolName]> for outbound protocols; ProtocolSet exposes Arc<HashMap<...>> for the keep-alive map.
  • ProtocolCommand::OpenSubstream carries the shared Arc instead of the duplicated (protocol, fallback_names) pair.
  • TCP/QUIC/WebSocket negotiate_protocol is generic over IntoIterator and iterates the Arc'd lists directly.
  • WebRtcDialerState stores Arc<[ProtocolName]> + cursor; webrtc_listener_negotiate accepts IntoIterator<Item = &ProtocolName>.

Closes #346

@dimartiro dimartiro force-pushed the perf/substream-protocol-construction branch from 13645bf to 22ba4c9 Compare June 1, 2026 11:53
@lexnv
Copy link
Copy Markdown
Collaborator

lexnv commented Jun 1, 2026

@dimartiro Thanks a lot for contributing!

This conflcts pending webrtc work, we'll dedicate a separate review once we stabilize the transport layer

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.

transport: Optimize protocol name construction on every every substream open

2 participants