Skip to content

Commit

Permalink
Make it possible to override MAX_NUM_PRECOMPILE_FILES using ENV.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Oct 9, 2020
1 parent 5f9098a commit 58605d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ function __init__()
init_load_path()
init_active_project()
append!(empty!(_sysimage_modules), keys(loaded_modules))
if haskey(ENV, "JULIA_MAX_NUM_PRECOMPILE_FILES")
MAX_NUM_PRECOMPILE_FILES[] = parse(Int, ENV["JULIA_MAX_NUM_PRECOMPILE_FILES"])
end
nothing
end

Expand Down
4 changes: 2 additions & 2 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ function compilecache(pkg::PkgId, cache::TOMLCache = TOMLCache(), show_errors::B
return compilecache(pkg, path, cache, show_errors)
end

const MAX_NUM_PRECOMPILE_FILES = 10
const MAX_NUM_PRECOMPILE_FILES = Ref(10)

function compilecache(pkg::PkgId, path::String, cache::TOMLCache = TOMLCache(), show_errors::Bool = true)
# decide where to put the resulting cache file
Expand All @@ -1260,7 +1260,7 @@ function compilecache(pkg::PkgId, path::String, cache::TOMLCache = TOMLCache(),
if pkg.uuid !== nothing
entrypath, entryfile = cache_file_entry(pkg)
cachefiles = filter!(x -> startswith(x, entryfile * "_"), readdir(cachepath))
if length(cachefiles) >= MAX_NUM_PRECOMPILE_FILES
if length(cachefiles) >= MAX_NUM_PRECOMPILE_FILES[]
idx = findmin(mtime.(joinpath.(cachepath, cachefiles)))[2]
rm(joinpath(cachepath, cachefiles[idx]))
end
Expand Down

0 comments on commit 58605d3

Please sign in to comment.