From 51dea8bdffc1abcb0869cadf6cb8057b3d3f18a9 Mon Sep 17 00:00:00 2001 From: Tang Jiawei Date: Thu, 7 Dec 2023 04:24:27 +0800 Subject: [PATCH] add timing log to `check_database` --- src/lib/merkle_ledger/database.ml | 4 +++- src/lib/transition_frontier/transition_frontier.ml | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib/merkle_ledger/database.ml b/src/lib/merkle_ledger/database.ml index ec1e2c1e856..a0a173e98b7 100644 --- a/src/lib/merkle_ledger/database.ml +++ b/src/lib/merkle_ledger/database.ml @@ -713,7 +713,9 @@ module Make (Inputs : Inputs_intf) : List.map locations ~f:Location.merkle_path_dependencies_exn in let all_locs = - List.map list_of_dependencies ~f:(fun deps -> List.map ~f:fst deps |> expand_query) |> List.concat + List.map list_of_dependencies ~f:(fun deps -> + List.map ~f:fst deps |> expand_query ) + |> List.concat in let hashes = get_hash_batch_exn mdb all_locs in snd @@ List.fold_map ~init:hashes ~f:compute_path list_of_dependencies diff --git a/src/lib/transition_frontier/transition_frontier.ml b/src/lib/transition_frontier/transition_frontier.ml index e8022518d48..e97cb10ae67 100644 --- a/src/lib/transition_frontier/transition_frontier.ml +++ b/src/lib/transition_frontier/transition_frontier.ml @@ -177,6 +177,14 @@ let load_from_persistence_and_start ~context:(module Context : CONTEXT) (Precomputed_values.genesis_state_hashes precomputed_values).state_hash } +let time ~logger ~label f = + let start = Time.now () in + let x = f () in + let stop = Time.now () in + [%log info] "%s took %s" label + (Time.Span.to_string_hum (Time.diff stop start)) ; + x + let rec load_with_max_length : context:(module CONTEXT) -> max_length:int @@ -283,6 +291,8 @@ let rec load_with_max_length : ~snarked_ledger_hash:genesis_ledger_hash in match + time ~label:"Persistent_frontier.Instsance.check_database" ~logger + @@ fun () -> Persistent_frontier.Instance.check_database ~genesis_state_hash: (State_hash.With_state_hashes.state_hash