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

Use a layered depot for the compilation cache. #236

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
32 changes: 19 additions & 13 deletions src/evaluate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,28 @@ function evaluate_test(config::Configuration, pkg::Package; use_cache::Bool=true
# we create our own workdir so that we can reuse it
workdir = mktempdir(prefix="pkgeval_$(pkg.name)_")

# caches are mutable, so they can get corrupted during a run. that's why it's possible
# to run without them (in case of a retry), and is also why we set them up here rather
# than in `sandboxed_julia` (because we know we've verified caches before entering here)
local_depot_path = joinpath(config.home, ".julia")
local_depot = joinpath(workdir, "depot")
mkdir(local_depot)
mounts[local_depot_path * ":rw"] = local_depot

# shared files are mounted using a layered depot
if use_cache
depot_dir = joinpath(config.home, ".julia")
shared_depot_path = "/usr/local/share/julia"

shared_compilecache = get_compilecache(config)
mounts[joinpath(depot_dir, "compiled")] = shared_compilecache
mounts[joinpath(shared_depot_path, "compiled") * ":ro"] = shared_compilecache

shared_packages = joinpath(storage_dir, "packages")
mounts[joinpath(depot_dir, "packages")] = shared_packages
mounts[joinpath(shared_depot_path, "packages") * ":ro"] = shared_packages

shared_artifacts = joinpath(storage_dir, "artifacts")
mounts[joinpath(depot_dir, "artifacts")] = shared_artifacts
mounts[joinpath(shared_depot_path, "artifacts") * ":ro"] = shared_artifacts

# XXX: we also need to append the bundled depot path (JuliaLang/julia#51448)
bundled_depot_path = joinpath(config.julia_install_dir, "share", "julia")
env["JULIA_DEPOT_PATH"] =
join([local_depot_path, shared_depot_path, bundled_depot_path], ":")
end

# structured output will be written to the /output directory. this is to avoid having to
Expand Down Expand Up @@ -487,10 +495,9 @@ function evaluate_test(config::Configuration, pkg::Package; use_cache::Bool=true

# (cache and) clean-up output created by this package
if use_cache
depot_dir = joinpath(workdir, "upper", "home", "pkgeval", ".julia")
local_compilecache = joinpath(depot_dir, "compiled")
local_packages = joinpath(depot_dir, "packages")
local_artifacts = joinpath(depot_dir, "artifacts")
local_compilecache = joinpath(local_depot, "compiled")
local_packages = joinpath(local_depot, "packages")
local_artifacts = joinpath(local_depot, "artifacts")

# verify local resources
registry_dir = get_registry(config)
Expand All @@ -507,8 +514,7 @@ function evaluate_test(config::Configuration, pkg::Package; use_cache::Bool=true
(local_artifacts, shared_artifacts),
(local_compilecache, shared_compilecache)]
if isdir(src)
# NOTE: removals (whiteouts) are represented as char devices
run(`$(rsync()) --no-specials --no-devices --archive --quiet $(src)/ $(dst)/`)
run(`$(rsync()) --archive --quiet $(src)/ $(dst)/`)
end
end
end
Expand Down