-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Too much lock contention? #247
Comments
Can you figure out which locks have contention? |
I suspect it's not the download start lock but probably the IO locks. |
This is the most common lock from Downloads.jl/src/Curl/Multi.jl Lines 197 to 201 in 971840a
I've also moved to hosting a file locally on a http server and downloading from tha, to test theoretical limit because the conference and hotel wifi isn't great, and with that I see a lot fewer locks. one download per thread
many downloads per thread
I'm not sure whether a locally http server is a fair test of this.. but the speed is a lot faster. And if I set https://curl.se/libcurl/c/CURLOPT_BUFFERSIZE.html
we get a good speed up (both here with task local
Apparently the default buffersize is 16kB and the max is 10MB |
Take all the numbers here with a pinch of salt, I just tried default settings again and saw similar speeds to the latter results.. Note that the buffersize is increased in this example https://github.com/curl/curl/blob/3765d75ce47b66289f946382b649d0e99389dc77/docs/examples/http2-download.c#L168-L169 and curl itself uses 100kB https://github.com/curl/curl/blob/3765d75ce47b66289f946382b649d0e99389dc77/src/tool_operate.c#L271 Some comparisons: Downloads.jl - normal default settings from master
curl cli - 1 GB/s
wget cli - 2.6 GB/sAnd wget gives 2.6 GB/s
Thanks to @giordano for pointing some of this out. |
Using JuliaLang/julia#55120 it turns out the lock that is mainly hitting the slow lock is Downloads.jl/src/Curl/Multi.jl Line 144 in d363a02
and that's happening with One thing I'm noticing is that for
we never see lock conflicts. Nor for
But we do for
A small number can be attributed to this lock when generating the Downloaders (which could be more efficiently managed to be task-local in the Downloads.jl/src/Curl/Multi.jl Line 11 in d363a02
|
I think a few things we might want to consider doing are:
I'll benchmark the parameter space when on a strong internet connection. In the meantime I've spun up 4 local http servers on different ports from a ramdisk, and accessing them individually from each task, but I'm not sure it's a fair test. This is 4 sequential downloads on each of 4 concurrent tasks, 10 times
Added results from locally hosted servers here master...ib/increase_buffersize |
I think I'm reaching a conclusion here.
I'll close. |
I'd really like for the defaults to be fast and not require jumping through any hoops. We've put so much work into making this concurrent under the hood with a simple blocking API, seems lame to not make it actually fast. So I'd like to actually fix this and make the warning unnecessary. I have a few paths I'd like to explore. There's an option for multithreaded libcurl usage—there might be a way to make that work and avoid needing a lock. Another option would be to create a Downloader object per thread. The only way to observe that is the easy hook stuff which is an unofficial and not great API anyway, so we could reasonably do that. The other approach would be something with channels or other ways to avoid locks. |
Trying to investigate this at the JuliaCon hackathon. Opening for discussion.
Note
1801 lock conflicts
even on the task localDownloader
versionThe text was updated successfully, but these errors were encountered: