Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up100% CPU use for 20+ seconds on startup #903
Comments
This comment has been minimized.
This comment has been minimized.
|
Yep, this is exactly what I'm seeing. @feross I recorded the seed-start progress using devtools and attached the dump here for inspection: CPU-20161009T155508.cpuprofile.zip That was seeding 18 torrents all at once. Each file ranges from 5 - 100 MB. By the way, when |
This comment has been minimized.
This comment has been minimized.
|
More info: I'm noticing that even after the initial crazy cpu spike, it stays idling near 40%. When I record timeline/profile, it doesn't actually show anything unusual (very little is happening, virtually idle). But the cpu is still being used by something in that process. Edit: I have discovered that rolling out the seeds 15 seconds apart one at a time drastically reduces the cpu usage. It never spikes now, and stays "okayish". Any shorter interval than that and the cpu usage would compound. When I removed all of the trackers (and just left my one in there) the cpu usage reduced even further. This makes me think it's more likely to be something to do with trackers - that is websockets not web rtc. Anyway, the good news is with this workaround ferment is usable again |
This comment has been minimized.
This comment has been minimized.
|
I think the WebRTC crypto required to set up an RTCPeerConnection object is pretty heavy weight. Will think on ways to improve this. |
This comment has been minimized.
This comment has been minimized.
|
@feross Any news on this? We tracked it down to https://github.com/feross/simple-peer/blob/master/index.js#L263 causing high cpu and taking 2-3secs to close the connections... per peer platform windows 10 as well Mac OSX |
This comment has been minimized.
This comment has been minimized.
|
Just to clarify this issue happens if you have more than 10 torrents running with WebTorrent and connecting to multiple peers with webRTC. CPu usage is high initially when adding the torrents and also on every 10 minites refresh from the trackers. So everything locks up every minutes - very annouying. We had to switch off wrts just like @mmckegg to have our app running. Without WebRTC everything is a breeze... So not sure if this is a bug in the Chrome code or in Webtorrent as it happens to us at RTCPeerConnection.close @feross could you please investigate as this renders the "web" part of the webtorrent project completely unusable ... have you ran test cases with more than 10 torrent files? |
This comment has been minimized.
This comment has been minimized.
|
@gpetrov Thanks for the sleuthing. I think we need to vastly lower the number of webrtc connections we attempt. We should also file a bug with the various browser vendors. Which browser did you experience the 2-3 second close times in? Also, how did you measure that? |
This comment has been minimized.
This comment has been minimized.
|
@feross we were using the latest chrome from the nwjs project (version 18.6 that is Chrome 54) but due to the high CPU and instability we had to throw away the whole webRTC and are now doing torrents in the isolated node context only. That is running really fine. |
This comment has been minimized.
This comment has been minimized.
|
Yeah, this is such a bummer. I wish that webrtc connections weren't so heavyweight in the current webrtc implementations. I'll raise this issue with the chrome team. |
This comment has been minimized.
This comment has been minimized.
|
Has there been any activity on this? Any word from the Chrome team, or perhaps local optimizations here in We are planning to roll out an application using Appreciate any help you can provide in this matter, thank you. |
This comment has been minimized.
This comment has been minimized.
|
Steps to reproduce
wss://) trackersThe app becomes unresponsive for ~20+ seconds on startup, while most of the torrent progress bars are stuck at 0%. The whole OS becomes slow to respond. Opening Dev Tools takes ~5+ seconds.
Dev Tools shows that all the resource use is all in the webtorrent process (ie, not in the window or main processes).
Here's the Timeline view:

### Potential problems - Tons of time spent in `close()` - The top of the flame graph is always 'Timer fired'. Something inside `webtorrent.js` is probably creating zillions of setIntervals or setTimeouts - Two solid seconds spent in a single (?) call to RTCPeerConnection (probably the constructor?)