From 3525004c3871ef587727c71e18e83cd23409a550 Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Fri, 13 Jun 2025 15:43:13 +0100 Subject: [PATCH] Tezt_cloud: Add PPX profiling optional argument to DAL scenario --- tezt/tests/cloud/dal.ml | 22 ++++++++++++++++++++-- tezt/tests/cloud/scenarios_cli.ml | 11 +++++++++++ tezt/tests/cloud/tezos.ml | 27 ++++++++++++++++++++++----- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/tezt/tests/cloud/dal.ml b/tezt/tests/cloud/dal.ml index ebd979c1b9b2..030ba97f5e42 100644 --- a/tezt/tests/cloud/dal.ml +++ b/tezt/tests/cloud/dal.ml @@ -136,7 +136,7 @@ module Node = struct include Node let init ?(arguments = []) ?data_dir ?identity_file ?dal_config ~rpc_external - ~name network ~snapshot cloud agent = + ~name network ~snapshot ?ppx_profiling cloud agent = toplog "Inititializing an L1 node for %s" name ; match network with | #Network.public -> ( @@ -159,6 +159,7 @@ module Node = struct let* () = may_copy_node_identity_file agent node identity_file in let* () = Node.Agent.run + ?ppx_profiling node [Network (Network.to_octez_network_options network)] in @@ -268,6 +269,7 @@ module Node = struct toplog "Launching the node %s." name ; let* () = Node.Agent.run + ?ppx_profiling node (Force_history_mode_switch :: Synchronisation_threshold 1 :: arguments) @@ -300,6 +302,7 @@ module Node = struct let* () = may_copy_node_identity_file agent node identity_file in let* () = Node.Agent.run + ?ppx_profiling node ([ No_bootstrap_peers; @@ -327,7 +330,7 @@ module Node = struct agent in let* () = may_copy_node_identity_file agent node identity_file in - let* () = Node.Agent.run node [] in + let* () = Node.Agent.run ?ppx_profiling node [] in let* () = Node.wait_for_ready node in Lwt.return node) end @@ -515,6 +518,7 @@ type configuration = { external_rpc : bool; disable_shard_validation : bool; ignore_pkhs : string list; + ppx_profiling : bool; } type bootstrap = { @@ -2182,6 +2186,7 @@ let init_public_network cloud (configuration : configuration) ~name:"bootstrap-node" configuration.network ~snapshot:configuration.snapshot + ~ppx_profiling:configuration.ppx_profiling cloud agent in @@ -2220,6 +2225,7 @@ let init_public_network cloud (configuration : configuration) ~memtrace:configuration.memtrace ~event_level:`Notice ~disable_shard_validation + ~ppx_profiling:configuration.ppx_profiling dal_node in Lwt.return_some dal_node @@ -2412,6 +2418,7 @@ let init_sandbox_and_activate_protocol cloud (configuration : configuration) ~name configuration.network ~snapshot:configuration.snapshot + ~ppx_profiling:configuration.ppx_profiling cloud agent in @@ -2516,6 +2523,7 @@ let init_sandbox_and_activate_protocol cloud (configuration : configuration) ~memtrace:configuration.memtrace ~event_level:`Notice ~disable_shard_validation:configuration.disable_shard_validation + ~ppx_profiling:configuration.ppx_profiling dal_bootstrap_node in let* () = @@ -2573,6 +2581,7 @@ let init_baker ?stake cloud (configuration : configuration) ~bootstrap teztale ~rpc_external:configuration.external_rpc configuration.network ~snapshot:configuration.snapshot + ~ppx_profiling:configuration.ppx_profiling cloud agent in @@ -2602,6 +2611,7 @@ let init_baker ?stake cloud (configuration : configuration) ~bootstrap teztale ~memtrace:configuration.memtrace ~event_level:`Notice ~disable_shard_validation:configuration.disable_shard_validation + ~ppx_profiling:configuration.ppx_profiling dal_node in Lwt.return_some dal_node @@ -2637,6 +2647,7 @@ let init_baker ?stake cloud (configuration : configuration) ~bootstrap teztale ~delegates:[account.Account.alias] ~client ?dal_node_rpc_endpoint + ~ppx_profiling:configuration.ppx_profiling node cloud agent @@ -2667,6 +2678,7 @@ let init_producer cloud configuration ~bootstrap teztale account i slot_index ~rpc_external:configuration.external_rpc configuration.network ~snapshot:configuration.snapshot + ~ppx_profiling:configuration.ppx_profiling cloud agent in @@ -2737,6 +2749,7 @@ let init_producer cloud configuration ~bootstrap teztale account i slot_index ~event_level:`Notice ~disable_shard_validation:configuration.disable_shard_validation ?ignore_pkhs + ~ppx_profiling:configuration.ppx_profiling dal_node in let () = toplog "Init producer %s: DAL node is ready" name in @@ -2766,6 +2779,7 @@ let init_observer cloud configuration ~bootstrap teztale ~topic i agent = ~rpc_external:configuration.external_rpc configuration.network ~snapshot:configuration.snapshot + ~ppx_profiling:configuration.ppx_profiling cloud agent in @@ -2807,6 +2821,7 @@ let init_observer cloud configuration ~bootstrap teztale ~topic i agent = ~memtrace:configuration.memtrace ~event_level:`Notice ~disable_shard_validation:configuration.disable_shard_validation + ~ppx_profiling:configuration.ppx_profiling dal_node in let* () = @@ -3563,6 +3578,7 @@ let on_new_level t level ~metadata = Dal_node.Agent.run ?otel:t.otel ~memtrace:t.configuration.memtrace + ~ppx_profiling:t.configuration.ppx_profiling dal_node) in Lwt.return {t with disconnection_state = Some disconnection_state} @@ -3757,6 +3773,7 @@ let register (module Cli : Scenarios_cli.Dal) = let bakers = Cli.bakers in let external_rpc = Cli.node_external_rpc_server in let disable_shard_validation = Cli.disable_shard_validation in + let ppx_profiling = Cli.ppx_profiling in let t = { with_dal; @@ -3784,6 +3801,7 @@ let register (module Cli : Scenarios_cli.Dal) = external_rpc; disable_shard_validation; ignore_pkhs; + ppx_profiling; } in (t, etherlink) diff --git a/tezt/tests/cloud/scenarios_cli.ml b/tezt/tests/cloud/scenarios_cli.ml index 6d0d9e921324..ef17e99df28b 100644 --- a/tezt/tests/cloud/scenarios_cli.ml +++ b/tezt/tests/cloud/scenarios_cli.ml @@ -89,6 +89,8 @@ module type Dal = sig val disable_shard_validation : bool val ignore_pkhs : string list + + val ppx_profiling : bool end module Dal () : Dal = struct @@ -429,6 +431,15 @@ module Dal () : Dal = struct "Specify a list of public key hashes for which all the producers will \ not publish the associated shards." () + + let ppx_profiling = + Clap.flag + ~section + ~set_long:"ppx-profiling" + ~description: + "Enable PPX profiling on all components. The level of verbosity is by \ + default `Debug` and the format of the output is `txt`. " + false end module type Layer1 = sig diff --git a/tezt/tests/cloud/tezos.ml b/tezt/tests/cloud/tezos.ml index 737c812b7ee2..b7fec52efc4d 100644 --- a/tezt/tests/cloud/tezos.ml +++ b/tezt/tests/cloud/tezos.ml @@ -5,6 +5,16 @@ (* *) (*****************************************************************************) +let ppx_profiler_env = + String_map.of_list [("PROFILING", "Debug"); ("PROFILING_BACKEND", "txt")] + +let may_add_profiling_to_env ~ppx_profiling = + if ppx_profiling then function + | None -> Some ppx_profiler_env + | Some env -> + Some (String_map.union (fun _ _ _ -> None) env ppx_profiler_env) + else Fun.id + let create_dir ?runner dir = let* () = Process.spawn ?runner "rm" ["-rf"; dir] |> Process.check in let* () = Process.spawn ?runner "mkdir" ["-p"; dir] |> Process.check in @@ -122,11 +132,11 @@ module Node = struct arguments let run ?env ?patch_config ?on_terminate ?event_level ?event_sections_levels - node args = + ?(ppx_profiling = false) node args = let name = name node in let* () = run - ?env + ?env:(may_add_profiling_to_env ~ppx_profiling env) ?patch_config ?on_terminate ?event_level @@ -228,7 +238,8 @@ module Dal_node = struct agent let run ?otel ?(memtrace = false) ?event_level - ?(disable_shard_validation = false) ?ignore_pkhs dal_node = + ?(disable_shard_validation = false) ?ignore_pkhs + ?(ppx_profiling = false) dal_node = let name = name dal_node in let filename = Format.asprintf "%s/%s-trace.ctf" Path.tmp_dir name in let env = @@ -270,6 +281,11 @@ module Dal_node = struct disable_shard_validation_env ignore_topics_env) in + let env = + if ppx_profiling then + String_map.union (fun _ _ _ -> None) env ppx_profiler_env + else env + in let* () = run ~env ?event_level dal_node in (* Update the state in the service manager *) let () = @@ -475,7 +491,8 @@ module Agnostic_baker = struct module Agent = struct let init ?(group = "L1") ?env ?name ~delegates ?(path = Uses.path Constant.octez_agnostic_baker) ~client - ?dal_node_rpc_endpoint ?dal_node_timeout_percentage node cloud agent = + ?dal_node_rpc_endpoint ?dal_node_timeout_percentage + ?(ppx_profiling = false) node cloud agent = let* path = Agent.copy agent ~source:path in let* () = Cloud.register_binary @@ -487,7 +504,7 @@ module Agnostic_baker = struct in let runner = Agent.runner agent in init - ?env + ?env:(may_add_profiling_to_env ~ppx_profiling env) ?name ~event_level:`Notice ?runner -- GitLab