@@ -205,12 +205,27 @@ function handle_heap_snapshot(all_one, stage_path = nothing)
205205 else
206206 file_path = joinpath(stage_path, " $(getpid()) _$(time_ns()) .heapsnapshot" )
207207 end
208- @info " Taking heap snapshot from ProfileEndpoints" all_one file_path
209- file_path = Profile. take_heap_snapshot(file_path, all_one)
208+ @info " Taking heap snapshot from ProfileEndpoints" all_one
209+ local output_file
210+ @static if VERSION . build === (" RAI" ,) || VERSION >= v" 1.11.0-"
211+ Profile. take_heap_snapshot(file_path, all_one; streaming= true )
212+ # Streaming version of `take_heap_snapshot` returns a bunch of files
213+ # that need to be later assembled...
214+ nodes_file = " $file_path .nodes"
215+ edges_file = " $file_path .edges"
216+ strings_file = " $file_path .strings"
217+ metadata_json_file = " $file_path .metadata.json"
218+ # Tar all of the files together
219+ output_file = " $file_path .tar"
220+ run(` tar -cf $output_file $nodes_file $edges_file $strings_file $metadata_json_file ` )
221+ else
222+ Profile. take_heap_snapshot(file_path, all_one)
223+ output_file = file_path
224+ end
210225 if stage_path === nothing
211- return _http_create_response_with_profile_inlined(read(file_path ))
226+ return _http_create_response_with_profile_inlined(read(tar_file ))
212227 else
213- return _http_create_response_with_profile_as_file(file_path )
228+ return _http_create_response_with_profile_as_file(tar_file )
214229 end
215230end
216231
0 commit comments