Re: Optimizing SABnzbd
Posted: May 29th, 2019, 8:12 am
I've done some experimentation on the impacts of sleeping in the downloader loop in Windows.
First, the granularity of sleep using a loop that runs 1 sec and tests how many times it runs with various sleep lengths:
time.sleep(0.0001): 516
time.sleep(0.001): 516
time.sleep(0.002): 343
time.sleep(0.005): 173
time.sleep(0.01): 95
time.sleep(0.1): 10
So there is no point in sleeping shorter than 0.001, which in reality averages to 0.002. This is an OS limitation so I think it will be fairly consistent no matter what the cpu speed is.
I also printed how long each sleep lasts, and almost all of them last about 0.00195 seconds.
The receive buffer for SSL is 16 KB. When I tested this by setting the delay to 0.2 seconds and tried various number of connections, this seems to be what limits the speed:
5c = 350KB/s
10c = 700KB/s
20c = 1600KB/s
At 500 iterations/second (with 0.001 sleep each iteration) this should result in a little under 8 MB/s/connection.
TLDR: Even with sleep and SSL it is theoretically possible to fill a 1 gigabit line using 15 connections on Windows.
First, the granularity of sleep using a loop that runs 1 sec and tests how many times it runs with various sleep lengths:
time.sleep(0.0001): 516
time.sleep(0.001): 516
time.sleep(0.002): 343
time.sleep(0.005): 173
time.sleep(0.01): 95
time.sleep(0.1): 10
So there is no point in sleeping shorter than 0.001, which in reality averages to 0.002. This is an OS limitation so I think it will be fairly consistent no matter what the cpu speed is.
I also printed how long each sleep lasts, and almost all of them last about 0.00195 seconds.
The receive buffer for SSL is 16 KB. When I tested this by setting the delay to 0.2 seconds and tried various number of connections, this seems to be what limits the speed:
5c = 350KB/s
10c = 700KB/s
20c = 1600KB/s
At 500 iterations/second (with 0.001 sleep each iteration) this should result in a little under 8 MB/s/connection.
TLDR: Even with sleep and SSL it is theoretically possible to fill a 1 gigabit line using 15 connections on Windows.