perf: migrate from simple-peer to polite-peer
See original GitHub issuePlease consider migrating from simple-peer
to polite-peer
: https://github.com/jimmywarting/jimmy.warting.se/blob/master/packages/peer/perfect-negotiation.js [there isn’t an NPM package for this but I could make one]
Why this matters:
simple-peer
relies on stream
which in turn relies on buffer
, and process
which relies on setTimeout
. This is an important issue because those require to be polyfilled, and those polyfills are VERY slow. Since WebTorrent was mentioned, from my testing more than half of the app’s CPU time was consumed by node’s stream and buffer or actually it’s polyfills. Another massive issue is the reliance on the slow process
polyfill of most bundlers which uses setTimeouts for delying tasks instead of promises or microtask.
Problems:
polite-peer
is a much simper package than simple-peer
[oh the irony] and as such doesn’t expose that many wrappers so it might require extra work. Another issue might be the immaturity of the package as very little people actually used it [not to be confused with it wasn’t used a lot, because it was used in public projects a lot] so unexpected issues might arise.
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:20 (19 by maintainers)
Top GitHub Comments
🥳 @gfodor with these changes pako, stream we went from 156.9kB/46.9kB to 39.6kB/12.5kB
I’ll pretend like I understood what you said, nod twice and hope you manage to pull some black magic and drop
simple-peer
sometime soon, I can’t wait to be able to use this in my electron projects which can’t do signaling via the web push api, which is the hack I used up until now to get signaling for free :p