From e1fbd88872eb89a3d9d7e9ae0c604c7a819b013d Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Thu, 12 Sep 2024 15:34:45 +0200 Subject: [PATCH 1/3] Snoop/tezt: add io-only flag --- tezt/snoop/main.ml | 12 ++++++++--- tezt/snoop/perform_benchmarks.ml | 36 +++++++++++++++++++------------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/tezt/snoop/main.ml b/tezt/snoop/main.ml index 4991c7ef3fe2..863b4af0fa86 100644 --- a/tezt/snoop/main.ml +++ b/tezt/snoop/main.ml @@ -26,13 +26,19 @@ (* This module runs the scripts implemented in all other modules of this directory. *) -let run proto = +let run proto ~io_only_flag = Lwt_main.run (let* () = Prepare_data.main proto in - let* () = Perform_benchmarks.main proto in + let* () = Perform_benchmarks.main proto ~io_only_flag in let* () = Perform_inference.main () in Perform_codegen.main ()) +let io_only = + Clap.flag + ~description:"Only run the IO benchmarks (io/READ and io/WRITE)." + ~set_long:"io-only" + false + let () = Background.start (fun x -> raise x) ; - run Protocol.Alpha + run Protocol.Alpha ~io_only_flag:io_only diff --git a/tezt/snoop/perform_benchmarks.ml b/tezt/snoop/perform_benchmarks.ml index d23c6fe778e9..c9eea5d279eb 100644 --- a/tezt/snoop/perform_benchmarks.ml +++ b/tezt/snoop/perform_benchmarks.ml @@ -320,20 +320,26 @@ let perform_dal_benchmarks snoop = let* benches = Snoop.(list_benchmarks ~mode:All ~tags:[Dal] snoop) in perform_benchmarks [] snoop benches -let main protocol = +let perform_io_benchmarks snoop = + let benches = ["io/READ"; "io/WRITE"] in + perform_benchmarks [] snoop benches + +let main protocol ~io_only_flag = Log.info "Entering Perform_inference.main" ; let snoop = Snoop.create () in - let* () = perform_misc_benchmarks snoop in - let* () = perform_interpreter_benchmarks snoop protocol in - let* () = perform_typechecker_benchmarks snoop protocol in - let* () = perform_tickets_benchmarks snoop protocol in - let* () = perform_global_constants_benchmarks snoop in - let* () = perform_cache_benchmarks snoop in - let* () = perform_encoding_benchmarks snoop protocol in - let* () = perform_big_map_benchmarks snoop protocol in - let* () = perform_skip_list_benchmarks snoop protocol in - let* () = perform_carbonated_map_benchmarks snoop protocol in - let* () = perform_sc_rollup_benchmarks snoop protocol in - let* () = perform_shell_micheline_benchmarks snoop in - let* () = perform_dal_benchmarks snoop in - perform_sapling_benchmarks snoop + if io_only_flag then perform_io_benchmarks snoop + else + let* () = perform_misc_benchmarks snoop in + let* () = perform_interpreter_benchmarks snoop protocol in + let* () = perform_typechecker_benchmarks snoop protocol in + let* () = perform_tickets_benchmarks snoop protocol in + let* () = perform_global_constants_benchmarks snoop in + let* () = perform_cache_benchmarks snoop in + let* () = perform_encoding_benchmarks snoop protocol in + let* () = perform_big_map_benchmarks snoop protocol in + let* () = perform_skip_list_benchmarks snoop protocol in + let* () = perform_carbonated_map_benchmarks snoop protocol in + let* () = perform_sc_rollup_benchmarks snoop protocol in + let* () = perform_shell_micheline_benchmarks snoop in + let* () = perform_dal_benchmarks snoop in + perform_sapling_benchmarks snoop -- GitLab From 459c5e39b7af215687d7ce82a55535df102747ac Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Thu, 12 Sep 2024 17:11:54 +0200 Subject: [PATCH 2/3] Snoop/tezt: add directory options for io benchs --- tezt/snoop/main.ml | 20 +++++++++++++++++--- tezt/snoop/perform_benchmarks.ml | 28 ++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/tezt/snoop/main.ml b/tezt/snoop/main.ml index 863b4af0fa86..f463ce95e67c 100644 --- a/tezt/snoop/main.ml +++ b/tezt/snoop/main.ml @@ -26,10 +26,12 @@ (* This module runs the scripts implemented in all other modules of this directory. *) -let run proto ~io_only_flag = +let run ~io_only_flag ?io_data_dir ?io_cache_dir proto = Lwt_main.run (let* () = Prepare_data.main proto in - let* () = Perform_benchmarks.main proto ~io_only_flag in + let* () = + Perform_benchmarks.main ~io_only_flag ?io_data_dir ?io_cache_dir proto + in let* () = Perform_inference.main () in Perform_codegen.main ()) @@ -39,6 +41,18 @@ let io_only = ~set_long:"io-only" false +let io_data_dir = + Clap.optional_string + ~long:"io-data-dir" + ~description:"Path of the data dir for the io benchmarks." + () + +let io_cache_dir = + Clap.optional_string + ~long:"io-cache-dir" + ~description:"Path of the cache for the io benchmarks." + () + let () = Background.start (fun x -> raise x) ; - run Protocol.Alpha ~io_only_flag:io_only + run ~io_only_flag:io_only ?io_data_dir ?io_cache_dir Protocol.Alpha diff --git a/tezt/snoop/perform_benchmarks.ml b/tezt/snoop/perform_benchmarks.ml index c9eea5d279eb..c6eeff99a3e0 100644 --- a/tezt/snoop/perform_benchmarks.ml +++ b/tezt/snoop/perform_benchmarks.ml @@ -320,14 +320,34 @@ let perform_dal_benchmarks snoop = let* benches = Snoop.(list_benchmarks ~mode:All ~tags:[Dal] snoop) in perform_benchmarks [] snoop benches -let perform_io_benchmarks snoop = +let perform_io_benchmarks snoop io_data_dir io_cache_dir = + let patches = + [ + ( rex ".*", + fun (_json, parameters) -> + let data_dir = + Option.fold + ~none:[] + ~some:(fun x -> [("tezos_data_dir", Ezjsonm.string x)]) + io_data_dir + in + let cache_dir = + Option.fold + ~none:[] + ~some:(fun x -> [("cache_dir", Ezjsonm.string x)]) + io_cache_dir + in + let json = Ezjsonm.dict (data_dir @ cache_dir) in + return (Some json, parameters) ); + ] + in let benches = ["io/READ"; "io/WRITE"] in - perform_benchmarks [] snoop benches + perform_benchmarks patches snoop benches -let main protocol ~io_only_flag = +let main ~io_only_flag ?io_data_dir ?io_cache_dir protocol = Log.info "Entering Perform_inference.main" ; let snoop = Snoop.create () in - if io_only_flag then perform_io_benchmarks snoop + if io_only_flag then perform_io_benchmarks snoop io_data_dir io_cache_dir else let* () = perform_misc_benchmarks snoop in let* () = perform_interpreter_benchmarks snoop protocol in -- GitLab From 0c9c133ac18e5f7bd34b0a720ed0733170335bbc Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Thu, 12 Sep 2024 17:26:14 +0200 Subject: [PATCH 3/3] Snoop/infra: add parameters for IO bench machine only The bench machine should specify the directories necessary for the io benchmarks, aswell as setting the env var IO_BENCH when launching the cronjob. --- .../run_all_benchmarks_on_latest_master.sh | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/devtools/benchmarks-tools/run_all_benchmarks_on_latest_master.sh b/devtools/benchmarks-tools/run_all_benchmarks_on_latest_master.sh index 29af54cad3e4..3d15d9da0fa1 100755 --- a/devtools/benchmarks-tools/run_all_benchmarks_on_latest_master.sh +++ b/devtools/benchmarks-tools/run_all_benchmarks_on_latest_master.sh @@ -39,6 +39,26 @@ rm -f current_run_dir TODAY=$(date +"%Y%m%d_%H%M") +# Directory variables for the io benchmarks. They must be set manually. +# Data directory. This directory should contain data from a tezos node. +IO_DATA_DIR=${IO_DATA_DIR-""} +# Cache directory. This directory is used to cache context keys during benchmarks. It should +# be cleaned if the data directory changes. It can be cleaned anytime, at the cost of performance. +IO_CACHE_DIR=${IO_CACHE_DIR-""} + +# IO benchmarks are run if and only if the [IO_BENCH] environment variable, as well as the directories +# [IO_DATA_DIR] and [IO_CACHE_DIR], are defined. +if [ -n "$IO_BENCH" ]; then + if [ -n "$IO_DATA_DIR" ] && [ -n "$IO_CACHE_DIR" ]; then + extra_param="--io-only --io-cache-dir ${IO_CACHE_DIR} --io-data-dir ${IO_DATA_DIR}" + else + dated_log "Either IO_DATA_DIR or IO_CACHE_DIR is not set for the IO benchmarks. Exiting." + exit 1 + fi +else + extra_param="" +fi + dated_log() { date +"[%Y-%m-%d %T] $1." } @@ -85,7 +105,7 @@ dated_log "Install DAL trusted setup" # Run benchmarks. dated_log "Running benchmarks" -time dune exec tezt/snoop/main.exe -- --verbose +time dune exec tezt/snoop/main.exe -- --verbose "$extra_param" dated_log "End of benchmarks run" # Move results from tezos to their dedicated directory. -- GitLab