ChainSafe / js-libp2p-yamux

Typescript implementation of Yamux
Other
10 stars 8 forks source link

feat!: yield uint8arraylists #65

Closed achingbrain closed 7 months ago

achingbrain commented 7 months ago

The general pattern of stream muxers is to yield protocol stream data framed by some additional metadata - stream id, flags, etc.

The frame data can be prepended/appended to the protocol stream data by using a Uint8ArrayList instead of a Uint8Array, this removes the need to copy the protocol data into a new Uint8Array for every frame.

The new @libp2p/interface version allows muxers to emit Uint8ArrayLists as well as Uint8Arrays so we can send protocol stream data to a transport in a no-copy operation.

In particular yielding a single Uint8ArrayList with the frame header plus the data buffer gets us close to that target 200ms connection establishment time:

image

BREAKING CHANGE: requires js-libp2p@1.0.0

achingbrain commented 7 months ago

N.b depends on "next" versions of @libp2p/interface and friends, they'll need to be released before this is merged.

codecov-commenter commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (f2492e9) 95.60% compared to head (9a48fd3) 95.60%. Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #65 +/- ## ========================================== - Coverage 95.60% 95.60% -0.01% ========================================== Files 14 14 Lines 2207 2206 -1 Branches 329 329 ========================================== - Hits 2110 2109 -1 Misses 97 97 ``` | [Flag](https://app.codecov.io/gh/ChainSafe/js-libp2p-yamux/pull/65/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ChainSafe) | Coverage Δ | | |---|---|---| | [node](https://app.codecov.io/gh/ChainSafe/js-libp2p-yamux/pull/65/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ChainSafe) | `95.60% <100.00%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ChainSafe#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 7 months ago

:tada: This PR is included in version 6.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: