ChainSafe / js-libp2p-yamux

Typescript implementation of Yamux
Other
10 stars 8 forks source link

fix: remove abortable iterator from muxer #63

Closed achingbrain closed 7 months ago

achingbrain commented 7 months ago

We use an abortable source for every connection - this introduces a lot of latency.

This PR removes abortable iterator to just listen on the abort event on the shutdown controller's abort signal and cause the connection's iterator to return.

This is the same thing that abortable source does except we don't Promise.race every .next() from the source.

I've added a simple benchmark - in my testing it increases throughput by 30% or so, this seems to translate to 10-15% in "real world" performance using the @libp2p/perf testing protocol.

codecov-commenter commented 7 months ago

Codecov Report

Attention: 40 lines in your changes are missing coverage. Please review.

Files Coverage Δ
src/encode.ts 100.00% <100.00%> (ø)
test/codec.spec.ts 100.00% <100.00%> (ø)
test/compliance.spec.ts 100.00% <100.00%> (ø)
test/decode.spec.ts 96.01% <100.00%> (-0.02%) :arrow_down:
test/muxer.spec.ts 100.00% <100.00%> (ø)
test/stream.spec.ts 100.00% <100.00%> (+0.90%) :arrow_up:
test/util.ts 100.00% <100.00%> (ø)
src/decode.ts 97.22% <88.88%> (+2.08%) :arrow_up:
src/stream.ts 98.01% <99.08%> (+2.52%) :arrow_up:
test/codec.util.ts 94.28% <66.66%> (ø)
... and 2 more

:loudspeaker: Thoughts on this report? Let us know!

github-actions[bot] commented 7 months ago

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

The release is available on:

Your semantic-release bot :package::rocket: