Fix perf stats filename for relative path clusters

Summary:
The computation of the perf stats file did not work in case -cluster was
passed a (relative) path.

Also, do not fail if the perf stats file cannot be opened/written, just
log a warning to stdout.

Reviewed By: jvillard

Differential Revision: D3269727

fb-gh-sync-id: c141ffa
fbshipit-source-id: c141ffa
master
Josh Berdine 9 years ago committed by Facebook Github Bot 3
parent b20ef20644
commit 12e42fefd9

@ -13,25 +13,28 @@ open! Utils
let register_report_at_exit file = let register_report_at_exit file =
Pervasives.at_exit (fun () -> Pervasives.at_exit (fun () ->
let gc_stats = Gc.quick_stat () in try
let exit_timeofday = Unix.gettimeofday () in let gc_stats = Gc.quick_stat () in
let exit_times = Unix.times () in let exit_timeofday = Unix.gettimeofday () in
let stats = let exit_times = Unix.times () in
`Assoc [ let stats =
("rtime", `Float (exit_timeofday -. initial_timeofday)) ; `Assoc [
("utime", `Float (exit_times.tms_utime -. initial_times.tms_utime)) ; ("rtime", `Float (exit_timeofday -. initial_timeofday)) ;
("stime", `Float (exit_times.tms_stime -. initial_times.tms_stime)) ; ("utime", `Float (exit_times.tms_utime -. initial_times.tms_utime)) ;
("cutime", `Float (exit_times.tms_cutime -. initial_times.tms_cutime)) ; ("stime", `Float (exit_times.tms_stime -. initial_times.tms_stime)) ;
("cstime", `Float (exit_times.tms_cstime -. initial_times.tms_cstime)) ; ("cutime", `Float (exit_times.tms_cutime -. initial_times.tms_cutime)) ;
("minor_words", `Float gc_stats.minor_words) ; ("cstime", `Float (exit_times.tms_cstime -. initial_times.tms_cstime)) ;
("promoted_words", `Float gc_stats.promoted_words) ; ("minor_words", `Float gc_stats.minor_words) ;
("major_words", `Float gc_stats.major_words) ; ("promoted_words", `Float gc_stats.promoted_words) ;
("minor_collections", `Int gc_stats.minor_collections) ; ("major_words", `Float gc_stats.major_words) ;
("major_collections", `Int gc_stats.major_collections) ; ("minor_collections", `Int gc_stats.minor_collections) ;
("compactions", `Int gc_stats.compactions) ; ("major_collections", `Int gc_stats.major_collections) ;
("top_heap_words", `Int gc_stats.top_heap_words) ; ("compactions", `Int gc_stats.compactions) ;
] in ("top_heap_words", `Int gc_stats.top_heap_words) ;
let stats_oc = open_out file in ] in
Yojson.Basic.pretty_to_channel stats_oc stats ; let stats_oc = open_out file in
close_out stats_oc Yojson.Basic.pretty_to_channel stats_oc stats ;
close_out stats_oc
with _ ->
Format.fprintf Format.std_formatter "Info: failed to write stats to %s@." file
) )

@ -355,7 +355,7 @@ let process_cluster_cmdline fname =
let register_perf_stats_report () = let register_perf_stats_report () =
let stats_dir = Filename.concat !Config.results_dir Config.backend_stats_dir_name in let stats_dir = Filename.concat !Config.results_dir Config.backend_stats_dir_name in
let cluster = match !cluster_cmdline with Some cl -> "_" ^ cl | None -> "" in let cluster = match !cluster_cmdline with Some cl -> "_" ^ (Filename.basename cl) | None -> "" in
let stats_file = Filename.concat stats_dir (Config.perf_stats_prefix ^ cluster ^ ".json") in let stats_file = Filename.concat stats_dir (Config.perf_stats_prefix ^ cluster ^ ".json") in
DB.create_dir !Config.results_dir ; DB.create_dir !Config.results_dir ;
DB.create_dir stats_dir ; DB.create_dir stats_dir ;

Loading…
Cancel
Save