-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Limit concurrent HTTP requests when downloading binary dependencies #4017
Conversation
See also: https://bugs.swift.org/browse/SR-15725 |
@swift-ci Please smoke test |
Sources/Workspace/Workspace.swift
Outdated
// finally download zip files, if any | ||
for artifact in (zipArtifacts.map{ $0 }) { | ||
semaphore.wait() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to how we handle group, we should should also defer a signal
on the semaphore and then another wait
after L2289, otherwise the continue
from L2284 may create problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe we should do group.enter()
and semaphore.wait()
only once after the guard
, when we're sure we're actually executing the asynchronous HTTP request? Probably I'm just missing some detail about the lines before the guard
though, not understanding the full picture why they also should be part of the DispatchGroup
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed 97ccc8d - which is what I meant with my earlier comment. If this is wrong for some reason that I don't see yet, please let me know and I'll revert it and make the change you suggested in your first comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this seems like a good change!
thanks @plu, couple of follow up questions |
Thank you for the quick review @tomerd. I made one change already, and had another question related to the code around the |
@swift-ci please smoke test |
@plu would you please also create a cherry-pick into the release/5.6 branch |
Is this something that Xcode is using directly, or should I file some radar for Xcode? I'm asking because we're also facing this issue when we do |
@plu this will be included in Xcode in the next release cycle |
Limit the concurrent HTTP requests for downloading binary dependencies to 8 concurrent requests.
Motivation:
We have a fairly large Package.swift with 50 binary dependencies. In total the size of these 50 zip files is 400 MB. On a slower internet connection (16 MBit) the
swift package resolve
command errors out with some HTTP timeouts. It seems the main problem is that all 50 HTTP requests are executed at the same time.Modifications:
Using some
DispatchSemaphore
to limit the concurrently downloaded binary dependencies to 8 concurrent requests.Result:
In our project with the 50 binary dependencies it successfully completes the
swift package resolve
command. It's still open for discussion if themax 8 concurrent downloads
is the right number. Also not sure if we should introduce another queue for this, reusingcallbackQueue
doesn't feel exactly right. However I found another TODO that's also just usingcallbackQueue
and wondering if there should be a separate queue.