Skip to content

Commit

Permalink
parallelize artifact downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Jul 13, 2024
1 parent d58c6a7 commit 66f70d1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -826,16 +826,29 @@ function download_artifacts(env::EnvCache;
pkg_root === nothing || push!(pkg_roots, pkg_root)
end
push!(pkg_roots, dirname(env.project_file))
used_artifact_tomls = Set{String}()
download_jobs = Channel{Function}(Inf)
for pkg_root in pkg_roots
for (artifacts_toml, artifacts) in collect_artifacts(pkg_root; platform)
# For each Artifacts.toml, install each artifact we've collected from it
for name in keys(artifacts)
ensure_artifact_installed(name, artifacts[name], artifacts_toml;
# @info name
push!(download_jobs,
() -> ensure_artifact_installed(name, artifacts[name], artifacts_toml;
verbose, quiet_download=!(usable_io(io)), io=io)
)
end
write_env_usage(artifacts_toml, "artifact_usage.toml")
push!(used_artifact_tomls, artifacts_toml)
end
end
close(download_jobs)
@sync for f in download_jobs
Threads.@spawn f()
end

for f in used_artifact_tomls
write_env_usage(f, "artifact_usage.toml")
end
end

function check_artifacts_downloaded(pkg_root::String; platform::AbstractPlatform=HostPlatform())
Expand Down
2 changes: 1 addition & 1 deletion src/Pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export UpgradeLevel, UPLEVEL_MAJOR, UPLEVEL_MINOR, UPLEVEL_PATCH
export PreserveLevel, PRESERVE_TIERED_INSTALLED, PRESERVE_TIERED, PRESERVE_ALL_INSTALLED, PRESERVE_ALL, PRESERVE_DIRECT, PRESERVE_SEMVER, PRESERVE_NONE
export Registry, RegistrySpec

public activate, add, build, compat, develop, free, gc, generate, instantiate,
public activate, add, build, compat, develop, free, gc, generate, instantiate,
pin, precompile, redo, rm, resolve, status, test, undo, update, why

depots() = Base.DEPOT_PATH
Expand Down
2 changes: 1 addition & 1 deletion src/PlatformEngines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function download(
(total, now) -> nothing
end
try
Downloads.download(url, dest; headers, progress)
Downloads.download(url, dest; headers, progress, downloader=Downloads.Downloader(; grace=0))
finally
do_fancy && end_progress(io, bar)
end
Expand Down

0 comments on commit 66f70d1

Please sign in to comment.