-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add json output and make target for benchmarking layered store. #1146
Changes from all commits
9d1fdae
33bf8a5
9c27b7b
e53aa86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -229,7 +229,7 @@ let first_5_cycles config repo = | |
print_commit_stats config c 0 0.0; | ||
let rec aux i c = | ||
add_min c; | ||
if i >= 4 then Lwt.return c | ||
if i > 4 then Lwt.return c | ||
else write_cycle config repo c >>= fun c -> aux (i + 1) c | ||
in | ||
aux 0 c | ||
|
@@ -267,7 +267,28 @@ let run config = | |
Fmt.epr "After freeze thread finished : "; | ||
FSHelper.print_size config.root) | ||
|
||
let main () ncommits ncycles depth clear no_freeze show_stats = | ||
type result = { | ||
total_time : float; | ||
time_per_commit : float; | ||
commits_per_sec : float; | ||
} | ||
[@@deriving yojson] | ||
|
||
let get_json_str total_time time_per_commit commits_per_sec = | ||
let res = { total_time; time_per_commit; commits_per_sec } in | ||
let obj = | ||
`Assoc | ||
[ | ||
( "results", | ||
`Assoc | ||
[ | ||
("name", `String "benchmarks"); ("metrics", result_to_yojson res); | ||
] ); | ||
] | ||
in | ||
Yojson.Safe.to_string obj | ||
|
||
let main () ncommits ncycles depth clear no_freeze show_stats json = | ||
let config = | ||
{ | ||
ncommits; | ||
|
@@ -281,13 +302,15 @@ let main () ncommits ncycles depth clear no_freeze show_stats = | |
in | ||
init config; | ||
let d, _ = Lwt_main.run (with_timer (fun () -> run config)) in | ||
let all_commits = ncommits * ncycles in | ||
let all_commits = ncommits * (ncycles + 5) in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems odd to always run 5 more cycles than requested. Perhaps we could run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The first 5 cycles are run in addition to the number of cycles passed as arg. https://github.com/mirage/irmin/blob/master/bench/irmin-pack/layers.ml#L263 runs the first 5 cycles followed by run_cycles. Maybe we should remove the first_5_cycles and change the doc to say running at least 5 is necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, I think it's better to have a more explicit behaviour. Out of interest, why is it necessary to have at least 5 cycles? It seems that I might want to just run ~1 cycle when working on the benchmarks, for instance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know! Paging @icristescu 😁 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The benchmarks are meant to be somewhat similar to the tezos usecase where every freeze copies the last 5 cycles. So we need to have the first 5 cycles before calling the first freeze. Then each cycle we call freeze again (done by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Merge when ready then, @gs0510 🙂 |
||
let rate = d /. float all_commits in | ||
let freq = 1. /. rate in | ||
Logs.app (fun l -> | ||
l | ||
"%d commits completed in %.2fs.\n\ | ||
[%.3fs per commit, %.0f commits per second]" all_commits d rate freq) | ||
if json then Logs.app (fun l -> l "%s" (get_json_str d rate freq)) | ||
else | ||
Logs.app (fun l -> | ||
l | ||
"%d commits completed in %.2fs.\n\ | ||
[%.3fs per commit, %.0f commits per second]" all_commits d rate freq) | ||
|
||
open Cmdliner | ||
|
||
|
@@ -296,7 +319,13 @@ let ncommits = | |
Arg.(value @@ opt int 4096 doc) | ||
|
||
let ncycles = | ||
let doc = Arg.info ~doc:"Number of cycles." [ "b"; "ncycles" ] in | ||
let doc = | ||
Arg.info | ||
~doc: | ||
"Number of cycles. This will be in addition to the 5 cycles that run \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this documentation here, hopefully it makes it clearer that it will be 5 + ncycles running. cc @craigfe @icristescu |
||
to emulate freeze." | ||
[ "b"; "ncycles" ] | ||
in | ||
Arg.(value @@ opt int 10 doc) | ||
|
||
let depth = | ||
|
@@ -317,6 +346,10 @@ let stats = | |
let doc = Arg.info ~doc:"Show performance stats." [ "s"; "stats" ] in | ||
Arg.(value @@ flag doc) | ||
|
||
let json = | ||
let doc = Arg.info ~doc:"Json output on command line." [ "j"; "json" ] in | ||
Arg.(value @@ flag doc) | ||
|
||
let setup_log style_renderer level = | ||
Fmt_tty.setup_std_outputs ?style_renderer (); | ||
Logs.set_level level; | ||
|
@@ -335,7 +368,8 @@ let main_term = | |
$ depth | ||
$ clear | ||
$ no_freeze | ||
$ stats) | ||
$ stats | ||
$ json) | ||
|
||
let () = | ||
let info = Term.info "Benchmarks for layered store" in | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only 4 cycles were running before, fixed to run 5 cycles as the function name suggests 😸
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One day, we'll live in an
Lwt
utopia with helper functions for these things...