Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: yield uint8arraylists #65

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

achingbrain
Copy link
Collaborator

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 achingbrain force-pushed the feat/support-yielding-uint8arraylists branch from 1459675 to 8495ae3 Compare November 25, 2023 15:19
@achingbrain
Copy link
Collaborator Author

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

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

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
@@            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 Coverage Δ
node 95.60% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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
`Uint8ArrayList`s as well as `Uint8Array`s so we can send protocol
stream data to a transport in a no-copy operation.
@achingbrain achingbrain force-pushed the feat/support-yielding-uint8arraylists branch from 8495ae3 to 9a48fd3 Compare November 29, 2023 14:30
@achingbrain achingbrain marked this pull request as ready for review November 29, 2023 14:38
@achingbrain achingbrain requested a review from a team as a code owner November 29, 2023 14:38
@wemeetagain wemeetagain merged commit 9ffc44d into master Nov 29, 2023
19 checks passed
@wemeetagain wemeetagain deleted the feat/support-yielding-uint8arraylists branch November 29, 2023 14:47
github-actions bot pushed a commit that referenced this pull request Nov 29, 2023
## [6.0.0](v5.0.4...v6.0.0) (2023-11-29)

### ⚠ BREAKING CHANGES

* yield uint8arraylists (#65)

### Features

* yield uint8arraylists ([#65](#65)) ([9ffc44d](9ffc44d))
Copy link

🎉 This PR is included in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants