Skip to content

Commit

Permalink
stream and then tar heap snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
d-netto committed Jun 28, 2024
1 parent b5d8970 commit e2a173c
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/ProfileEndpoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,27 @@ function handle_heap_snapshot(all_one, stage_path = nothing)
else
file_path = joinpath(stage_path, "$(getpid())_$(time_ns()).heapsnapshot")
end
@info "Taking heap snapshot from ProfileEndpoints" all_one file_path
file_path = Profile.take_heap_snapshot(file_path, all_one)
@info "Taking heap snapshot from ProfileEndpoints" all_one
local output_file
@static if VERSION.build === ("RAI",) || VERSION >= v"1.11.0-"
Profile.take_heap_snapshot(file_path, all_one; streaming=true)
# Streaming version of `take_heap_snapshot` returns a bunch of files
# that need to be later assembled...
nodes_file = "$file_path.nodes"
edges_file = "$file_path.edges"
strings_file = "$file_path.strings"
metadata_json_file = "$file_path.metadata.json"
# Tar all of the files together
output_file = "$file_path.tar"
run(`tar -cf $output_file $nodes_file $edges_file $strings_file $metadata_json_file`)
else
Profile.take_heap_snapshot(file_path, all_one)
output_file = file_path
end
if stage_path === nothing
return _http_create_response_with_profile_inlined(read(file_path))
return _http_create_response_with_profile_inlined(read(output_file))
else
return _http_create_response_with_profile_as_file(file_path)
return _http_create_response_with_profile_as_file(output_file)
end
end

Expand Down

0 comments on commit e2a173c

Please sign in to comment.