nathom / streamrip

A scriptable music downloader for Qobuz, Tidal, SoundCloud, and Deezer
GNU General Public License v3.0
2.35k stars 209 forks source link

Manually yield for better performance #648

Closed nathom closed 3 months ago

nathom commented 4 months ago

Attempt to fix #601

Profiling shows that kqueue.select is using most of the runtime. I suspect that it's because of all the async context switching happening in _download, which is triggering a select every time a chunk is received. This PR attempts a fix by using synchronous requests and manually yielding to the event loop.

yield_every and chunk_size may be tuned for better results.