Created
June 13, 2023 15:11
-
-
Save staticfloat/47d2d3cbf0f17e4487862ade7bbb13a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DepotCompactor, Pkg | |
# Calculate the depot path for one of our agents | |
function agent_depot_path(agent_idx) | |
"/data/agent-cache/yggy-amdci7.$(agent_idx)/julia-buildkite-plugin/depots/e2fd9734-29d8-45cd-b0eb-59f7104f3131" | |
end | |
all_agent_depot_paths = [agent_depot_path(idx) for idx in 0:11] | |
# Our "shared" depot that we compact into | |
shared_depot_path = "/data/agent-cache/yggy-shared/depot" | |
compact_depots(shared_depot_path, all_agent_depot_paths; ref_depots=all_agent_depot_paths) | |
# Helper functions for calling `GC` on all depots in turn, | |
# although in practice we mostly expect the shared depot to | |
# have much to be GC'ed, as the other depots will be naturally | |
# GC'ed by `Pkg.add()` operations and such. | |
function with_depot_path(f::Function, depots) | |
old_depot_path = copy(Base.DEPOT_PATH) | |
empty!(Base.DEPOT_PATH) | |
append!(Base.DEPOT_PATH, depots) | |
f() | |
empty!(Base.DEPOT_PATH) | |
append!(Base.DEPOT_PATH, old_depot_path) | |
end | |
function roundrobin_gc(depots) | |
for depot in depots | |
with_depot_path([depot, depots...]) do | |
Pkg.gc(;verbose=true) | |
end | |
end | |
end | |
roundrobin_gc([shared_depot_path; all_agent_depot_paths...]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment