Skip to content
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

download all artifacts with concurrent tasks #288

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions src/Rootfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ function expand_cxxstring_abis(platform::AbstractPlatform; skip=Sys.isbsd)
p["cxxstring_abi"] = "cxx11" #Clang only seems to generate cxx11 abi
return [p]
end

# Otherwise, generate new versions!
map(["cxx03", "cxx11"]) do abi
p = deepcopy(platform)
Expand Down Expand Up @@ -1014,20 +1014,39 @@ function preferred_cxxstring_abi(platform::AbstractPlatform, shard::CompilerShar
end

"""
download_all_artifacts(; verbose::Bool=false)
download_all_artifacts(; verbose::Bool=false, concurrency=1)

Helper function to download all shards/helper binaries so that no matter what
happens, you don't need an internet connection to build your precious, precious
binaries.
"""
function download_all_artifacts(; verbose::Bool = false)
function download_all_artifacts(; verbose::Bool = false, concurrency=1)
artifacts_toml = joinpath(dirname(@__DIR__), "Artifacts.toml")
ensure_all_artifacts_installed(
artifacts_toml;
include_lazy=true,
verbose=verbose,
platform=default_host_platform,
)
artifacts = select_downloadable_artifacts(artifacts_toml; platform=default_host_platform, include_lazy=true)
if concurrency == 1
for name in keys(artifacts)
ensure_artifact_installed(name, artifacts[name], artifacts_toml; verbose=verbose)
end
return nothing
end
taskpool = Channel{Task}(concurrency) do ch
for name in keys(artifacts)
t = @task ensure_artifact_installed(name, artifacts[name], artifacts_toml; verbose=false)
put!(ch, t)
end
end
verbose && @info "launch $concurrency concurrent downloading tasks"
wait(taskpool)
@sync for _ in 1:concurrency
@async begin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For new code I recommend against the use of @async and strongly prefer Threads.@spawn.

while !isempty(taskpool)
t = take!(taskpool)
schedule(t)
wait(t)
end
end
end
return nothing
end

const _sudo_cmd = Ref{Union{Cmd,Nothing}}(nothing)
Expand Down