Skip to content

Commit

Permalink
Cache downloaded and extracted traces for the duration of the Julia s…
Browse files Browse the repository at this point in the history
…ession. (#89)
  • Loading branch information
maleadt authored Aug 17, 2022
1 parent d471ff4 commit 900bb95
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "BugReporting"
uuid = "bcf9a6e7-4020-453c-b88e-690564246bb8"
authors = ["Keno Fischer <[email protected]>",
"Tim Besard <[email protected]>"]
version = "0.2.6"
version = "0.2.7"

[deps]
AWS = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc"
Expand Down
26 changes: 17 additions & 9 deletions src/BugReporting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ end
# Values that are initialized in `__init__()`
default_rr_record_flags = ``
julia_checkout = ""
trace_cache = ""

struct InvalidPerfEventParanoidError <: Exception
value
Expand Down Expand Up @@ -234,10 +235,12 @@ function decompress_rr_trace(trace_file, out_dir)
end

function decompress_rr_trace(trace_file)
# Extract into temporary directory (we'll clean-up when the process exists)
dir = mktempdir()
decompress_rr_trace(trace_file, dir)
return dir
# extract, cached for the duration of this session
trace_dir = joinpath(trace_cache, basename(trace_file))
if !isdir(trace_dir)
decompress_rr_trace(trace_file, trace_dir)
end
return trace_dir
end

function download_rr_trace(trace_url)
Expand All @@ -256,12 +259,16 @@ function download_rr_trace(trace_url)
end
progress = isinteractive() ? update_progress : nothing

mktempdir() do dl_dir
# Download into temporary directory (we'll clean-up straight away)
local_path = joinpath(dl_dir, "trace.tar.zst")
Downloads.download(trace_url, local_path; progress=progress)
decompress_rr_trace(local_path)
# download and extract, cached for the duration of this session
trace_dir = joinpath(trace_cache, basename(trace_url))
if !isdir(trace_dir)
mktempdir() do dl_dir
local_path = joinpath(dl_dir, "trace.tar.zst")
Downloads.download(trace_url, local_path; progress=progress)
decompress_rr_trace(local_path, trace_dir)
end
end
return trace_dir
end

function get_sourcecode(commit)
Expand Down Expand Up @@ -582,6 +589,7 @@ function __init__()
end

global julia_checkout = @get_scratch!("julia")
global trace_cache = mktempdir()
end


Expand Down

2 comments on commit 900bb95

@maleadt
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/66413

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.7 -m "<description of version>" 900bb953696bea4bc0c63c9936f1e84514722671
git push origin v0.2.7

Please sign in to comment.