From 3b027a9d255f519f5d5364efc94b98730f476111 Mon Sep 17 00:00:00 2001 From: Pavlo Khrystenko Date: Fri, 17 Mar 2023 11:47:13 +0100 Subject: [PATCH 1/6] Snoop: add module_filename in shell_benchmarks --- .../bloomer_benchmarks.ml | 4 + .../encoding_benchmarks.ml | 4 +- .../encoding_benchmarks_helpers.ml | 587 +++++++++--------- src/lib_shell_benchmarks/io_benchmarks.ml | 24 + .../micheline_benchmarks.ml | 4 + src/lib_shell_benchmarks/misc_benchmarks.ml | 4 + .../lib_benchmarks_proto/benchmarks_proto.ml | 2 +- .../lib_benchmarks_proto/benchmarks_proto.mli | 2 +- .../encodings_benchmarks.ml | 39 +- .../skip_list_benchmarks.ml | 4 +- .../translator_benchmarks.ml | 7 + 11 files changed, 377 insertions(+), 304 deletions(-) diff --git a/src/lib_shell_benchmarks/bloomer_benchmarks.ml b/src/lib_shell_benchmarks/bloomer_benchmarks.ml index 2929e5ad69d7..baf302b4c7fb 100644 --- a/src/lib_shell_benchmarks/bloomer_benchmarks.ml +++ b/src/lib_shell_benchmarks/bloomer_benchmarks.ml @@ -42,6 +42,10 @@ let make_bench ~name ~info ~model ~generator ~make_bench : let default_config = () + let module_filename = __FILE__ + + let () = ignore module_filename + let config_encoding = Data_encoding.unit type workload = unit diff --git a/src/lib_shell_benchmarks/encoding_benchmarks.ml b/src/lib_shell_benchmarks/encoding_benchmarks.ml index 10cb4d3ab572..8666f696c341 100644 --- a/src/lib_shell_benchmarks/encoding_benchmarks.ml +++ b/src/lib_shell_benchmarks/encoding_benchmarks.ml @@ -24,8 +24,10 @@ (* *) (*****************************************************************************) open Benchmarks_shell -open Encoding_benchmarks_helpers +open Encoding_benchmarks_helpers.Make (struct + let file = __FILE__ +end) (* ------------------------------------------------------------------------- *) module Make_elliptic_curve_encoding_benchmarks (A : sig diff --git a/src/lib_shell_benchmarks/encoding_benchmarks_helpers.ml b/src/lib_shell_benchmarks/encoding_benchmarks_helpers.ml index 14dcea8aae6c..612c03d1a233 100644 --- a/src/lib_shell_benchmarks/encoding_benchmarks_helpers.ml +++ b/src/lib_shell_benchmarks/encoding_benchmarks_helpers.ml @@ -59,286 +59,307 @@ module Shared_linear = struct Sparse_vec.String.of_list [("bytes", float_of_int bytes)] end -(* Generic function to cook benchmarks for fixed-size encodings *) -let fixed_size_shared : - ?check:(unit -> unit) -> - name:string -> - generator:'a Base_samplers.sampler -> - make_bench: - ((unit -> 'a) -> unit -> unit Tezos_benchmark.Generator.benchmark) -> - unit -> - Tezos_benchmark.Benchmark.t = - fun ?(check = fun () -> ()) ~name ~generator ~make_bench () -> - let free_variable = fv (Format.asprintf "%s_const" name) in - let model = - Model.make - ~conv:(fun () -> ()) - ~model:(Model.unknown_const1 ~name:(ns name) ~const:free_variable) - in - let module Bench : Benchmark.S = struct - let name = ns name - - let info = Format.asprintf "Benchmarking %a" Namespace.pp name - - let tags = ["encoding"] - - include Shared_constant_time - - let create_benchmarks ~rng_state ~bench_num () = - check () ; - let generator () = generator rng_state in - List.repeat bench_num (make_bench generator) - - let models = [("encoding", model)] - end in - ((module Bench) : Benchmark.t) - -(* Generic function to cook benchmarks for linear-time encodings *) -let linear_shared ?(check = fun () -> ()) ~name ~generator ~make_bench () = - let const = fv (Format.asprintf "%s_const" name) in - let coeff = fv (Format.asprintf "%s_coeff" name) in - let model = - Model.make - ~conv:(fun {Shared_linear.bytes} -> (bytes, ())) - ~model:(Model.affine ~name:(ns name) ~intercept:const ~coeff) - in - let module Bench : Benchmark.S = struct - let name = ns name - - let info = Format.asprintf "Benchmarking %a" Namespace.pp name - - let tags = ["encoding"] - - include Shared_linear - - let create_benchmarks ~rng_state ~bench_num () = - check () ; - let generator () = generator rng_state in - List.repeat bench_num (make_bench generator) - - let models = [("encoding", model)] - end in - ((module Bench) : Benchmark.t) - -(* Generic function to cook benchmarks for nlogn-time encodings *) -let nsqrtn_shared_with_intercept ~name ~generator ~make_bench - ~generator_intercept ~make_bench_intercept = - let const = fv (Format.asprintf "%s_const" name) in - let coeff = fv (Format.asprintf "%s_coeff" name) in - let model = - Model.make - ~conv:(fun {Shared_linear.bytes} -> (bytes, ())) - ~model:(Model.nsqrtn_const ~name:(ns name) ~intercept:const ~coeff) - in - let module Bench : Benchmark.S = struct - let name = ns name - - let info = Format.asprintf "Benchmarking %a" Namespace.pp name - - let tags = ["encoding"] - - include Shared_linear - - let create_benchmarks ~rng_state ~bench_num () = - let generator () = generator rng_state in - List.repeat bench_num (make_bench generator) - - let models = [("encoding", model)] - end in - let module Bench_intercept : Benchmark.S = struct - let name = (Namespace.make ns name) "intercept" - - let info = - Format.asprintf "Benchmarking %a (intercept case)" Namespace.pp name - - let tags = ["encoding"] - - include Shared_linear - - let create_benchmarks ~rng_state ~bench_num () = - let generator () = generator_intercept rng_state in - List.repeat bench_num (make_bench_intercept generator) - - let models = [("encoding", model)] - end in - (((module Bench) : Benchmark.t), ((module Bench_intercept) : Benchmark.t)) - -let make_encode_fixed_size : - type a. - ?check:(unit -> unit) -> - name:string -> - encoding:a Data_encoding.t -> - generator:(Random.State.t -> a) -> - unit -> - Benchmark.t = - fun ?check ~name ~encoding ~generator () -> - fixed_size_shared - ?check - ~name - ~generator - ~make_bench:(fun generator () -> - let generated = generator () in - let closure () = - ignore (Data_encoding.Binary.to_bytes_exn encoding generated) - in - Generator.Plain {workload = (); closure}) - () - -let make_encode_variable_size : - type a. - ?check:(unit -> unit) -> - name:string -> - encoding:a Data_encoding.t -> - generator:(Random.State.t -> a * Shared_linear.workload) -> - unit -> - Benchmark.t = - fun ?check ~name ~encoding ~generator -> - linear_shared ?check ~name ~generator ~make_bench:(fun generator () -> - let generated, workload = generator () in - let closure () = - ignore (Data_encoding.Binary.to_bytes_exn encoding generated) - in - Generator.Plain {workload; closure}) - -let make_decode_fixed_size : - type a. - ?check:(unit -> unit) -> - name:string -> - encoding:a Data_encoding.t -> - generator:(Random.State.t -> a) -> - unit -> - Benchmark.t = - fun ?check ~name ~encoding ~generator -> - fixed_size_shared ?check ~name ~generator ~make_bench:(fun generator () -> - let generated = generator () in - let encoded = Data_encoding.Binary.to_bytes_exn encoding generated in - let closure () = - ignore (Data_encoding.Binary.of_bytes_exn encoding encoded) - in - Generator.Plain {workload = (); closure}) - -let make_decode_variable_size : - type a. - ?check:(unit -> unit) -> - name:string -> - encoding:a Data_encoding.t -> - generator:(Random.State.t -> a * Shared_linear.workload) -> - unit -> - Benchmark.t = - fun ?check ~name ~encoding ~generator -> - linear_shared ?check ~name ~generator ~make_bench:(fun generator () -> - let generated, workload = generator () in - let encoded = Data_encoding.Binary.to_bytes_exn encoding generated in - let closure () = - ignore (Data_encoding.Binary.of_bytes_exn encoding encoded) - in - Generator.Plain {workload; closure}) - -(* Generic functions to cook benchmarks for b58check conversions (used for - typechecking in readable mode in the protocol...) and byte conversions. *) -let make_encode_fixed_size_to_string : - type a. - ?check:(unit -> unit) -> - name:string -> - to_string:(a -> string) -> - generator:(Random.State.t -> a) -> - unit -> - Benchmark.t = - fun ?check ~name ~to_string ~generator -> - fixed_size_shared ?check ~name ~generator ~make_bench:(fun generator () -> - let generated = generator () in - let closure () = ignore (to_string generated) in - Generator.Plain {workload = (); closure}) - -(* Exactly the sample implem' as above.*) -let make_encode_fixed_size_to_bytes : - type a. - ?check:(unit -> unit) -> - name:string -> - to_bytes:(a -> bytes) -> - generator:(Random.State.t -> a) -> - unit -> - Benchmark.t = - fun ?check ~name ~to_bytes ~generator -> - fixed_size_shared ?check ~name ~generator ~make_bench:(fun generator () -> - let generated = generator () in - let closure () = ignore (to_bytes generated) in - Generator.Plain {workload = (); closure}) - -let make_encode_variable_size_to_string : - type a. - ?check:(unit -> unit) -> - name:string -> - to_string:(a -> string) -> - generator:(Random.State.t -> a * Shared_linear.workload) -> - unit -> - Benchmark.t = - fun ?check ~name ~to_string ~generator -> - linear_shared ?check ~name ~generator ~make_bench:(fun generator () -> - let generated, workload = generator () in - let closure () = ignore (to_string generated) in - Generator.Plain {workload; closure}) - -let make_decode_fixed_size_from_string : - type a. - ?check:(unit -> unit) -> - name:string -> - to_string:(a -> string) -> - from_string:(string -> a) -> - generator:(Random.State.t -> a) -> - unit -> - Benchmark.t = - fun ?check ~name ~to_string ~from_string ~generator -> - fixed_size_shared ?check ~name ~generator ~make_bench:(fun generator () -> - let generated = generator () in - let string = to_string generated in - let closure () = ignore (from_string string) in - Generator.Plain {workload = (); closure}) - -let make_decode_fixed_size_from_bytes : - type a. - ?check:(unit -> unit) -> - name:string -> - to_bytes:(a -> bytes) -> - from_bytes:(bytes -> a) -> - generator:(Random.State.t -> a) -> - unit -> - Benchmark.t = - fun ?check ~name ~to_bytes ~from_bytes ~generator -> - fixed_size_shared ?check ~name ~generator ~make_bench:(fun generator () -> - let generated = generator () in - let bytes = to_bytes generated in - let closure () = ignore (from_bytes bytes) in - Generator.Plain {workload = (); closure}) - -let make_decode_variable_size_from_string : - type a. - ?check:(unit -> unit) -> - name:string -> - to_string:(a -> string) -> - from_string:(string -> a) -> - generator:(Random.State.t -> a * Shared_linear.workload) -> - unit -> - Benchmark.t = - fun ?check ~name ~to_string ~from_string ~generator -> - linear_shared ?check ~name ~generator ~make_bench:(fun generator () -> - let generated, workload = generator () in - let string = to_string generated in - let closure () = ignore (from_string string) in - Generator.Plain {workload; closure}) - -let make_decode_variable_size_from_bytes : - type a. - ?check:(unit -> unit) -> - name:string -> - to_bytes:(a -> bytes) -> - from_bytes:(bytes -> a) -> - generator:(Random.State.t -> a * Shared_linear.workload) -> - unit -> - Benchmark.t = - fun ?check ~name ~to_bytes ~from_bytes ~generator -> - linear_shared ?check ~name ~generator ~make_bench:(fun generator () -> - let generated, workload = generator () in - let string = to_bytes generated in - let closure () = ignore (from_bytes string) in - Generator.Plain {workload; closure}) +module Make (Filename : sig + val file : string +end) = +struct + (* Generic function to cook benchmarks for fixed-size encodings *) + let fixed_size_shared : + ?check:(unit -> unit) -> + name:string -> + generator:'a Base_samplers.sampler -> + make_bench: + ((unit -> 'a) -> unit -> unit Tezos_benchmark.Generator.benchmark) -> + unit -> + Tezos_benchmark.Benchmark.t = + fun ?(check = fun () -> ()) ~name ~generator ~make_bench () -> + let free_variable = fv (Format.asprintf "%s_const" name) in + let model = + Model.make + ~conv:(fun () -> ()) + ~model:(Model.unknown_const1 ~name:(ns name) ~const:free_variable) + in + let module Bench : Benchmark.S = struct + let name = ns name + + let info = Format.asprintf "Benchmarking %a" Namespace.pp name + + let module_filename = Filename.file + + let () = ignore module_filename + + let tags = ["encoding"] + + include Shared_constant_time + + let create_benchmarks ~rng_state ~bench_num () = + check () ; + let generator () = generator rng_state in + List.repeat bench_num (make_bench generator) + + let models = [("encoding", model)] + end in + ((module Bench) : Benchmark.t) + + (* Generic function to cook benchmarks for linear-time encodings *) + let linear_shared ?(check = fun () -> ()) ~name ~generator ~make_bench () = + let const = fv (Format.asprintf "%s_const" name) in + let coeff = fv (Format.asprintf "%s_coeff" name) in + let model = + Model.make + ~conv:(fun {Shared_linear.bytes} -> (bytes, ())) + ~model:(Model.affine ~name:(ns name) ~intercept:const ~coeff) + in + let module Bench : Benchmark.S = struct + let name = ns name + + let info = Format.asprintf "Benchmarking %a" Namespace.pp name + + let module_filename = Filename.file + + let () = ignore module_filename + + let tags = ["encoding"] + + include Shared_linear + + let create_benchmarks ~rng_state ~bench_num () = + check () ; + let generator () = generator rng_state in + List.repeat bench_num (make_bench generator) + + let models = [("encoding", model)] + end in + ((module Bench) : Benchmark.t) + + (* Generic function to cook benchmarks for nlogn-time encodings *) + let nsqrtn_shared_with_intercept ~name ~generator ~make_bench + ~generator_intercept ~make_bench_intercept = + let const = fv (Format.asprintf "%s_const" name) in + let coeff = fv (Format.asprintf "%s_coeff" name) in + let model = + Model.make + ~conv:(fun {Shared_linear.bytes} -> (bytes, ())) + ~model:(Model.nsqrtn_const ~name:(ns name) ~intercept:const ~coeff) + in + let module Bench : Benchmark.S = struct + let name = ns name + + let info = Format.asprintf "Benchmarking %a" Namespace.pp name + + let module_filename = Filename.file + + let () = ignore module_filename + + let tags = ["encoding"] + + include Shared_linear + + let create_benchmarks ~rng_state ~bench_num () = + let generator () = generator rng_state in + List.repeat bench_num (make_bench generator) + + let models = [("encoding", model)] + end in + let module Bench_intercept : Benchmark.S = struct + let name = (Namespace.make ns name) "intercept" + + let info = + Format.asprintf "Benchmarking %a (intercept case)" Namespace.pp name + + let module_filename = Filename.file + + let () = ignore module_filename + + let tags = ["encoding"] + + include Shared_linear + + let create_benchmarks ~rng_state ~bench_num () = + let generator () = generator_intercept rng_state in + List.repeat bench_num (make_bench_intercept generator) + + let models = [("encoding", model)] + end in + (((module Bench) : Benchmark.t), ((module Bench_intercept) : Benchmark.t)) + + let make_encode_fixed_size : + type a. + ?check:(unit -> unit) -> + name:string -> + encoding:a Data_encoding.t -> + generator:(Random.State.t -> a) -> + unit -> + Benchmark.t = + fun ?check ~name ~encoding ~generator () -> + fixed_size_shared + ?check + ~name + ~generator + ~make_bench:(fun generator () -> + let generated = generator () in + let closure () = + ignore (Data_encoding.Binary.to_bytes_exn encoding generated) + in + Generator.Plain {workload = (); closure}) + () + + let make_encode_variable_size : + type a. + ?check:(unit -> unit) -> + name:string -> + encoding:a Data_encoding.t -> + generator:(Random.State.t -> a * Shared_linear.workload) -> + unit -> + Benchmark.t = + fun ?check ~name ~encoding ~generator -> + linear_shared ?check ~name ~generator ~make_bench:(fun generator () -> + let generated, workload = generator () in + let closure () = + ignore (Data_encoding.Binary.to_bytes_exn encoding generated) + in + Generator.Plain {workload; closure}) + + let make_decode_fixed_size : + type a. + ?check:(unit -> unit) -> + name:string -> + encoding:a Data_encoding.t -> + generator:(Random.State.t -> a) -> + unit -> + Benchmark.t = + fun ?check ~name ~encoding ~generator -> + fixed_size_shared ?check ~name ~generator ~make_bench:(fun generator () -> + let generated = generator () in + let encoded = Data_encoding.Binary.to_bytes_exn encoding generated in + let closure () = + ignore (Data_encoding.Binary.of_bytes_exn encoding encoded) + in + Generator.Plain {workload = (); closure}) + + let make_decode_variable_size : + type a. + ?check:(unit -> unit) -> + name:string -> + encoding:a Data_encoding.t -> + generator:(Random.State.t -> a * Shared_linear.workload) -> + unit -> + Benchmark.t = + fun ?check ~name ~encoding ~generator -> + linear_shared ?check ~name ~generator ~make_bench:(fun generator () -> + let generated, workload = generator () in + let encoded = Data_encoding.Binary.to_bytes_exn encoding generated in + let closure () = + ignore (Data_encoding.Binary.of_bytes_exn encoding encoded) + in + Generator.Plain {workload; closure}) + + (* Generic functions to cook benchmarks for b58check conversions (used for + typechecking in readable mode in the protocol...) and byte conversions. *) + let make_encode_fixed_size_to_string : + type a. + ?check:(unit -> unit) -> + name:string -> + to_string:(a -> string) -> + generator:(Random.State.t -> a) -> + unit -> + Benchmark.t = + fun ?check ~name ~to_string ~generator -> + fixed_size_shared ?check ~name ~generator ~make_bench:(fun generator () -> + let generated = generator () in + let closure () = ignore (to_string generated) in + Generator.Plain {workload = (); closure}) + + (* Exactly the sample implem' as above.*) + let make_encode_fixed_size_to_bytes : + type a. + ?check:(unit -> unit) -> + name:string -> + to_bytes:(a -> bytes) -> + generator:(Random.State.t -> a) -> + unit -> + Benchmark.t = + fun ?check ~name ~to_bytes ~generator -> + fixed_size_shared ?check ~name ~generator ~make_bench:(fun generator () -> + let generated = generator () in + let closure () = ignore (to_bytes generated) in + Generator.Plain {workload = (); closure}) + + let make_encode_variable_size_to_string : + type a. + ?check:(unit -> unit) -> + name:string -> + to_string:(a -> string) -> + generator:(Random.State.t -> a * Shared_linear.workload) -> + unit -> + Benchmark.t = + fun ?check ~name ~to_string ~generator -> + linear_shared ?check ~name ~generator ~make_bench:(fun generator () -> + let generated, workload = generator () in + let closure () = ignore (to_string generated) in + Generator.Plain {workload; closure}) + + let make_decode_fixed_size_from_string : + type a. + ?check:(unit -> unit) -> + name:string -> + to_string:(a -> string) -> + from_string:(string -> a) -> + generator:(Random.State.t -> a) -> + unit -> + Benchmark.t = + fun ?check ~name ~to_string ~from_string ~generator -> + fixed_size_shared ?check ~name ~generator ~make_bench:(fun generator () -> + let generated = generator () in + let string = to_string generated in + let closure () = ignore (from_string string) in + Generator.Plain {workload = (); closure}) + + let make_decode_fixed_size_from_bytes : + type a. + ?check:(unit -> unit) -> + name:string -> + to_bytes:(a -> bytes) -> + from_bytes:(bytes -> a) -> + generator:(Random.State.t -> a) -> + unit -> + Benchmark.t = + fun ?check ~name ~to_bytes ~from_bytes ~generator -> + fixed_size_shared ?check ~name ~generator ~make_bench:(fun generator () -> + let generated = generator () in + let bytes = to_bytes generated in + let closure () = ignore (from_bytes bytes) in + Generator.Plain {workload = (); closure}) + + let make_decode_variable_size_from_string : + type a. + ?check:(unit -> unit) -> + name:string -> + to_string:(a -> string) -> + from_string:(string -> a) -> + generator:(Random.State.t -> a * Shared_linear.workload) -> + unit -> + Benchmark.t = + fun ?check ~name ~to_string ~from_string ~generator -> + linear_shared ?check ~name ~generator ~make_bench:(fun generator () -> + let generated, workload = generator () in + let string = to_string generated in + let closure () = ignore (from_string string) in + Generator.Plain {workload; closure}) + + let make_decode_variable_size_from_bytes : + type a. + ?check:(unit -> unit) -> + name:string -> + to_bytes:(a -> bytes) -> + from_bytes:(bytes -> a) -> + generator:(Random.State.t -> a * Shared_linear.workload) -> + unit -> + Benchmark.t = + fun ?check ~name ~to_bytes ~from_bytes ~generator -> + linear_shared ?check ~name ~generator ~make_bench:(fun generator () -> + let generated, workload = generator () in + let string = to_bytes generated in + let closure () = ignore (from_bytes string) in + Generator.Plain {workload; closure}) +end diff --git a/src/lib_shell_benchmarks/io_benchmarks.ml b/src/lib_shell_benchmarks/io_benchmarks.ml index aabd9c799d0e..a4bb9384356f 100644 --- a/src/lib_shell_benchmarks/io_benchmarks.ml +++ b/src/lib_shell_benchmarks/io_benchmarks.ml @@ -266,6 +266,10 @@ module Context_size_dependent_read_bench : Benchmark.S = struct let tags = ["io"] + let module_filename = __FILE__ + + let () = ignore module_filename + include Context_size_dependent_shared let make_bench rng_state cfg () = @@ -351,6 +355,10 @@ module Context_size_dependent_write_bench : Benchmark.S = struct "Benchmarking the write accesses with contexts of various sizes (with \ fixed storage size except for the written key)" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["io"] let write_storage context key bytes = @@ -569,6 +577,10 @@ module Irmin_pack_read_bench : Benchmark.S = struct let info = "Benchmarking read accesses in irmin-pack directories" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["io"] type workload = @@ -734,6 +746,10 @@ module Irmin_pack_write_bench : Benchmark.S = struct let info = "Benchmarking write accesses in irmin-pack directories" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["io"] type workload = @@ -894,6 +910,10 @@ module Read_random_key_bench : Benchmark.S = struct let info = "Benchmarking random read accesses in a subdirectory" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["io"] type workload = Read_random_key of {depth : int; storage_bytes : int} @@ -1037,6 +1057,10 @@ module Write_random_keys_bench : Benchmark.S = struct let info = "Benchmarking random read accesses in a subdirectory" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["io"] type workload = diff --git a/src/lib_shell_benchmarks/micheline_benchmarks.ml b/src/lib_shell_benchmarks/micheline_benchmarks.ml index 4ea66a230cc5..aefe2a18aaff 100644 --- a/src/lib_shell_benchmarks/micheline_benchmarks.ml +++ b/src/lib_shell_benchmarks/micheline_benchmarks.ml @@ -133,6 +133,10 @@ module Micheline_strip_locations : Benchmark.S = struct let info = "Benchmarking Micheline.strip_locations" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["micheline"] type config = unit diff --git a/src/lib_shell_benchmarks/misc_benchmarks.ml b/src/lib_shell_benchmarks/misc_benchmarks.ml index 79c9165e438f..fbab72582376 100644 --- a/src/lib_shell_benchmarks/misc_benchmarks.ml +++ b/src/lib_shell_benchmarks/misc_benchmarks.ml @@ -46,6 +46,10 @@ module Lwt_main_run_bench : Benchmark.S = struct let info = "Benchmark of Lwt_main.run" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["misc"] let models = [("*", lwt_model)] diff --git a/src/proto_alpha/lib_benchmarks_proto/benchmarks_proto.ml b/src/proto_alpha/lib_benchmarks_proto/benchmarks_proto.ml index 8e29cbe743e3..a541164ad48c 100644 --- a/src/proto_alpha/lib_benchmarks_proto/benchmarks_proto.ml +++ b/src/proto_alpha/lib_benchmarks_proto/benchmarks_proto.ml @@ -31,7 +31,7 @@ module Benchmark = struct val info : string - val module_location : string + val module_filename : string val tags : string list diff --git a/src/proto_alpha/lib_benchmarks_proto/benchmarks_proto.mli b/src/proto_alpha/lib_benchmarks_proto/benchmarks_proto.mli index 87b96d5ba429..d3852c8aaad1 100644 --- a/src/proto_alpha/lib_benchmarks_proto/benchmarks_proto.mli +++ b/src/proto_alpha/lib_benchmarks_proto/benchmarks_proto.mli @@ -36,7 +36,7 @@ module Benchmark : sig val info : string (** Filename of the benchmark module *) - val module_location : string + val module_filename : string (** Tags of the benchmark *) val tags : string list diff --git a/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml index 9afaa8331315..7242b17f35f3 100644 --- a/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml @@ -24,6 +24,12 @@ (*****************************************************************************) open Protocol + +module Encodings = +Tezos_shell_benchmarks.Encoding_benchmarks_helpers.Make (struct + let file = __FILE__ +end) + module Size = Gas_input_size let ns = Namespace.make Registration_helpers.ns "encoding" @@ -258,25 +264,26 @@ end let () = Registration_helpers.register (module Decoding_micheline) module Timestamp = struct + open Encodings + let () = Registration_helpers.register - @@ - let open Tezos_shell_benchmarks.Encoding_benchmarks_helpers in - fixed_size_shared - ~name:"TIMESTAMP_READABLE_ENCODING" - ~generator:(fun rng_state -> - let seconds_in_year = 30_000_000 in - let offset = Random.State.int rng_state seconds_in_year in - Script_timestamp.of_zint (Z.of_int (1597764116 + offset))) - ~make_bench:(fun generator () -> - let tstamp_string = generator () in - let closure () = ignore (Script_timestamp.to_notation tstamp_string) in - Generator.Plain {workload = (); closure}) - () + @@ fixed_size_shared + ~name:"TIMESTAMP_READABLE_ENCODING" + ~generator:(fun rng_state -> + let seconds_in_year = 30_000_000 in + let offset = Random.State.int rng_state seconds_in_year in + Script_timestamp.of_zint (Z.of_int (1597764116 + offset))) + ~make_bench:(fun generator () -> + let tstamp_string = generator () in + let closure () = + ignore (Script_timestamp.to_notation tstamp_string) + in + Generator.Plain {workload = (); closure}) + () let () = let b, b_intercept = - let open Tezos_shell_benchmarks.Encoding_benchmarks_helpers in nsqrtn_shared_with_intercept ~name:"TIMESTAMP_READABLE_DECODING" ~generator:(fun rng_state -> @@ -312,7 +319,7 @@ end https://gitlab.com/dannywillems/ocaml-bls12-381/-/blob/71d0b4d467fbfaa6452d702fcc408d7a70916a80/README.md#install *) module BLS = struct - open Tezos_shell_benchmarks.Encoding_benchmarks_helpers + open Encodings let check () = if not Bls12_381.built_with_blst_portable then ( @@ -406,7 +413,7 @@ module BLS = struct end module Timelock = struct - open Tezos_shell_benchmarks.Encoding_benchmarks_helpers + open Encodings let generator rng_state = let log_time = diff --git a/src/proto_alpha/lib_benchmarks_proto/skip_list_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/skip_list_benchmarks.ml index c502f171e8fd..ee4592c769e1 100644 --- a/src/proto_alpha/lib_benchmarks_proto/skip_list_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/skip_list_benchmarks.ml @@ -54,7 +54,7 @@ module Next : Benchmark.S = struct let default_config = {max_items = 10000} - let module_location = __FILE__ + let module_filename = __FILE__ let config_encoding = let open Data_encoding in @@ -106,7 +106,7 @@ module Hash_cell : Benchmark.S = struct let tags = ["skip_list"] - let module_location = __FILE__ + let module_filename = __FILE__ include Skip_list module Hash = Sc_rollup_inbox_repr.Hash diff --git a/src/proto_alpha/lib_benchmarks_proto/translator_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/translator_benchmarks.ml index 3fd1ac14ae8e..d10305ddaecc 100644 --- a/src/proto_alpha/lib_benchmarks_proto/translator_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/translator_benchmarks.ml @@ -24,6 +24,12 @@ (*****************************************************************************) open Protocol + +module Encodings = +Tezos_shell_benchmarks.Encoding_benchmarks_helpers.Make (struct + let file = __FILE__ +end) + module Size = Gas_input_size let ns = Translator_model.ns @@ -502,6 +508,7 @@ let rec check_printable_ascii v i = let check_printable_benchmark = let open Tezos_shell_benchmarks.Encoding_benchmarks_helpers in + let open Encodings in linear_shared ~name:"CHECK_PRINTABLE" ~generator:(fun rng_state -> -- GitLab From 6ece5adf1470b19a08c3d4af6369e4b9123d7b66 Mon Sep 17 00:00:00 2001 From: Pavlo Khrystenko Date: Fri, 17 Mar 2023 11:56:30 +0100 Subject: [PATCH 2/6] Snoop: add module filename to lib_benchmark_proto --- .../lib_benchmarks_proto/apply_benchmarks.ml | 2 ++ .../lib_benchmarks_proto/cache_benchmarks.ml | 4 +++ .../carbonated_map_benchmarks.ml | 6 ++++ .../encodings_benchmarks.ml | 8 ++++++ .../global_constants_storage_benchmarks.ml | 24 ++++++++++++++++ .../interpreter_benchmarks.ml | 16 +++++++++++ .../sapling_benchmarks.ml | 4 +++ .../sc_rollup_benchmarks.ml | 4 +++ .../script_repr_benchmarks.ml | 8 ++++++ .../script_typed_ir_size_benchmarks.ml | 16 +++++++++++ .../storage_benchmarks.ml | 4 +++ .../lib_benchmarks_proto/ticket_benchmarks.ml | 16 +++++++++++ .../translator_benchmarks.ml | 28 +++++++++++++++++++ 13 files changed, 140 insertions(+) diff --git a/src/proto_alpha/lib_benchmarks_proto/apply_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/apply_benchmarks.ml index 5908a289e552..02cd860880e7 100644 --- a/src/proto_alpha/lib_benchmarks_proto/apply_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/apply_benchmarks.ml @@ -62,6 +62,8 @@ module Take_fees_benchmark = struct let info = "Benchmark for take_fees" + let module_filename = __FILE__ + let tags = ["apply"] type config = unit diff --git a/src/proto_alpha/lib_benchmarks_proto/cache_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/cache_benchmarks.ml index 08a410788db8..e716ea22ace1 100644 --- a/src/proto_alpha/lib_benchmarks_proto/cache_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/cache_benchmarks.ml @@ -133,6 +133,10 @@ module Cache_update_benchmark : Benchmark.S = struct let info = "Benchmarking the time it takes to update a key in the cache" + let module_filename = __FILE__ + + let () = ignore module_filename + (** It is expected that cache keys are non-adversarial, ie do not share a long common prefix. This is the case for [Script_cache], for which the keys are B58-encoded contract hashes. diff --git a/src/proto_alpha/lib_benchmarks_proto/carbonated_map_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/carbonated_map_benchmarks.ml index c97db5d44081..6f99987cd040 100644 --- a/src/proto_alpha/lib_benchmarks_proto/carbonated_map_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/carbonated_map_benchmarks.ml @@ -45,6 +45,8 @@ module Config_and_workload = struct type workload = config + let module_filename = __FILE__ + let tags = ["carbonated_map"] let workload_encoding = config_encoding @@ -161,6 +163,8 @@ module Make (CS : COMPARABLE_SAMPLER) = struct let info = Printf.sprintf "Carbonated map compare cost for %s keys" CS.type_name + let module_filename = __FILE__ + let models = [ ( "carbonated_map", @@ -298,6 +302,8 @@ module Make (CS : COMPARABLE_SAMPLER) = struct let info = Printf.sprintf "Carbonated find model (intercept case)" + let module_filename = __FILE__ + let models = [ ( "carbonated_map", diff --git a/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml index 7242b17f35f3..65c6fed2c2b5 100644 --- a/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml @@ -135,6 +135,10 @@ module Encoding_micheline : Benchmark.S = struct let info = "Benchmarking strip_location + encoding of Micheline to bytes" + let module_filename = __FILE__ + + let () = ignore module_filename + let micheline_serialization_trace (micheline_node : Alpha_context.Script.node) = match @@ -201,6 +205,10 @@ module Decoding_micheline : Benchmark.S = struct let info = "Decoding of bytes to Micheline" + let module_filename = __FILE__ + + let () = ignore module_filename + let micheline_deserialization_trace (micheline_str : string) = match Data_encoding.Binary.of_string diff --git a/src/proto_alpha/lib_benchmarks_proto/global_constants_storage_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/global_constants_storage_benchmarks.ml index f26441373999..1b3ec2aacadd 100644 --- a/src/proto_alpha/lib_benchmarks_proto/global_constants_storage_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/global_constants_storage_benchmarks.ml @@ -296,6 +296,10 @@ module Set_add : Benchmark.S = struct let info = "Benchmarks and cost model for set element addition from OCaml stdlib." + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["global_constants"] type config = unit @@ -347,6 +351,10 @@ module Set_elements : Benchmark.S = struct let info = "Benchmarks and cost model for set elements from OCaml stdlib." + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["global_constants"] type config = unit @@ -400,6 +408,10 @@ module Script_expr_hash_of_b58check_opt : Benchmark.S = struct let info = "Benchmark for Script_expr_hash.of_b58check_opt" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["global_constants"] type config = unit @@ -468,6 +480,10 @@ struct Global_constants_storage.Internal_for_tests.expr_to_address_in_context \ function" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["global_constants"] type config = unit @@ -548,6 +564,10 @@ module Global_constants_storage_expand_models = struct "Benchmark for the constant branch Global_constants_storage.expand \ function" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["global_constants"] type config = unit @@ -619,6 +639,10 @@ module Global_constants_storage_expand_models = struct "Benchmark for the Global_constants_storage.expand function on the case \ without constants" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["global_constants"] type config = unit diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml index f1ca84c30743..dfd4f021b856 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml @@ -272,6 +272,10 @@ let make_benchmark : ?salt (Interpreter_workload.string_of_instruction_name name) + let module_filename = __FILE__ + + let () = ignore module_filename + let benchmark kinstr_and_stack_sampler ctxt step_constants () = let stack_instr = kinstr_and_stack_sampler () in benchmark_from_kinstr_and_stack @@ -552,6 +556,10 @@ let make_continuation_benchmark : ?salt (Interpreter_workload.string_of_continuation_name name) + let module_filename = __FILE__ + + let () = ignore module_filename + let benchmark cont_and_stack_sampler ctxt step_constants () = let stack_instr = cont_and_stack_sampler () in benchmark_from_continuation ?amplification ctxt step_constants stack_instr @@ -647,6 +655,10 @@ module Registration_section = struct let info = "Benchmarking the cost of an empty loop" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = [Tags.interpreter] type config = {max_iterations : int} @@ -2716,6 +2728,10 @@ module Registration_section = struct let info = info + let module_filename = __FILE__ + + let () = ignore module_filename + include Default_config include Default_boilerplate diff --git a/src/proto_alpha/lib_benchmarks_proto/sapling_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/sapling_benchmarks.ml index 1ceef0bfd148..3401fb381968 100644 --- a/src/proto_alpha/lib_benchmarks_proto/sapling_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/sapling_benchmarks.ml @@ -38,6 +38,10 @@ module Apply_diff_bench : Benchmark.S = struct let info = "Benchmarking SAPLING_APPLY_DIFF" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = ["sapling"] let diff_from_tx (tx : Alpha_context.Sapling.transaction) = diff --git a/src/proto_alpha/lib_benchmarks_proto/sc_rollup_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/sc_rollup_benchmarks.ml index a5b91d0c80ef..e5f8f7dddb0b 100644 --- a/src/proto_alpha/lib_benchmarks_proto/sc_rollup_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/sc_rollup_benchmarks.ml @@ -288,6 +288,8 @@ module Sc_rollup_verify_output_proof_benchmark = struct let info = "Estimating the cost of verifying an output proof" + let module_filename = __FILE__ + let tags = ["sc_rollup"] type config = { @@ -503,6 +505,8 @@ module Sc_rollup_deserialize_output_proof_benchmark = struct let info = "Estimating the cost of deserializing an output proof" + let module_filename = __FILE__ + let tags = ["sc_rollup"] type config = { diff --git a/src/proto_alpha/lib_benchmarks_proto/script_repr_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/script_repr_benchmarks.ml index f63a51c97fc5..272e369375bb 100644 --- a/src/proto_alpha/lib_benchmarks_proto/script_repr_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/script_repr_benchmarks.ml @@ -80,6 +80,10 @@ module Micheline_nodes_benchmark : Benchmark.S = struct "Benchmarking the time it takes to compute the number of nodes of a \ Micheline term" + let module_filename = __FILE__ + + let () = ignore module_filename + let size_based_model = Model.make ~conv:(function {micheline_nodes} -> (micheline_nodes, ())) @@ -119,6 +123,10 @@ module Script_repr_strip_annotations : Benchmark.S = struct let info = "Benchmarking Script_repr.strip_annotations" + let module_filename = __FILE__ + + let () = ignore module_filename + let strip_annotations_model = Model.( make diff --git a/src/proto_alpha/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml index 47f819f20231..4cf2225a0e9a 100644 --- a/src/proto_alpha/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml @@ -77,6 +77,10 @@ end = struct let info = "Benchmarking Script_typed_ir_size.value_size" + let module_filename = __FILE__ + + let () = ignore module_filename + let value_size_benchmark rng_state (node : Protocol.Script_repr.expr) (michelson_type : Script_repr.expr) = (* FIXME: cleanup and factorize this code between translator benches and these ones. *) @@ -148,6 +152,10 @@ module Type_size_benchmark : Tezos_benchmark.Benchmark.S = struct let info = "Benchmarking the time it takes to compute Script_typed_ir_size.ty_size" + let module_filename = __FILE__ + + let () = ignore module_filename + let models = [(model_name, size_based_model (Namespace.basename name))] let type_size_benchmark (Script_typed_ir.Ex_ty ty) = @@ -190,6 +198,10 @@ end = struct let info = "Benchmarking Script_typed_ir_size.kinstr_size" + let module_filename = __FILE__ + + let () = ignore module_filename + let kinstr_size_benchmark rng_state (expr : Protocol.Script_repr.expr) (stack : Script_repr.expr list) = (* FIXME: cleanup and factorize this code between translator benches and these ones. *) @@ -267,6 +279,10 @@ module Node_size_benchmark : Benchmark.S = struct let info = "Benchmarking the time it takes to compute Script_typed_ir_size.node_size" + let module_filename = __FILE__ + + let () = ignore module_filename + let size_based_model = Model.make ~conv:(function {micheline_nodes} -> (micheline_nodes, ())) diff --git a/src/proto_alpha/lib_benchmarks_proto/storage_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/storage_benchmarks.ml index 4353cc14b696..467777dff546 100644 --- a/src/proto_alpha/lib_benchmarks_proto/storage_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/storage_benchmarks.ml @@ -181,6 +181,8 @@ end module List_key_values_benchmark = struct include List_key_values_benchmark_boilerplate + let module_filename = __FILE__ + let benchmark rng_state {max_size} () = let wrap m = m >|= Environment.wrap_tzresult in let size = @@ -219,6 +221,8 @@ module List_key_values_benchmark_intercept = struct let name = Namespace.make ns (Namespace.basename name) "intercept" + let module_filename = __FILE__ + let benchmark _rng_state _config () = let ctxt = match Lwt_main.run (default_raw_context ()) with diff --git a/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml index 28b2bb8aa9df..01986fb95eba 100644 --- a/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml @@ -83,6 +83,10 @@ module Compare_ticket_hash_benchmark : Benchmark.S = struct let info = "Compare cost for Ticket_hash" + let module_filename = __FILE__ + + let () = ignore module_filename + let compare_model = Model.make ~conv:(fun () -> ()) @@ -134,6 +138,10 @@ module Compare_key_contract_benchmark : Benchmark.S = struct let info = "Compare cost for Contracts" + let module_filename = __FILE__ + + let () = ignore module_filename + let compare_model = Model.make ~conv:(fun () -> ()) @@ -192,6 +200,10 @@ module Has_tickets_type_benchmark : Benchmark.S = struct let info = "Benchmarking type_has_tickets" + let module_filename = __FILE__ + + let () = ignore module_filename + let make_bench_helper rng_state config () = let open Result_syntax in let* ctxt, _ = Lwt_main.run (Execution_context.make ~rng_state) in @@ -245,6 +257,10 @@ module Collect_tickets_benchmark : Benchmark.S = struct let info = "Benchmarking tickets_of_value" + let module_filename = __FILE__ + + let () = ignore module_filename + let make_bench_helper rng_state config () = let open Script_typed_ir in let open Result_syntax in diff --git a/src/proto_alpha/lib_benchmarks_proto/translator_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/translator_benchmarks.ml index d10305ddaecc..c80acc959c06 100644 --- a/src/proto_alpha/lib_benchmarks_proto/translator_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/translator_benchmarks.ml @@ -201,6 +201,10 @@ module Typechecking_data : Benchmark.S = struct let info = "Benchmarking typechecking of data" + let module_filename = __FILE__ + + let () = ignore module_filename + let typechecking_data_benchmark rng_state (node : Protocol.Script_repr.expr) (michelson_type : Script_repr.expr) = Lwt_main.run @@ -273,6 +277,10 @@ module Unparsing_data : Benchmark.S = struct let info = "Benchmarking unparsing of data" + let module_filename = __FILE__ + + let () = ignore module_filename + let unparsing_data_benchmark rng_state (node : Protocol.Script_repr.expr) (michelson_type : Protocol.Script_repr.expr) = Lwt_main.run @@ -352,6 +360,10 @@ module Typechecking_code : Benchmark.S = struct let info = "Benchmarking typechecking of code" + let module_filename = __FILE__ + + let () = ignore module_filename + let typechecking_code_benchmark rng_state (node : Protocol.Script_repr.expr) (stack : Script_repr.expr list) = Lwt_main.run @@ -428,6 +440,10 @@ module Unparsing_code : Benchmark.S = struct let info = "Benchmarking unparsing of code" + let module_filename = __FILE__ + + let () = ignore module_filename + let unparsing_code_benchmark rng_state (node : Protocol.Script_repr.expr) (stack : Script_repr.expr list) = Lwt_main.run @@ -557,6 +573,10 @@ module Ty_eq : Benchmark.S = struct let info = "Benchmarking equating types" + let module_filename = __FILE__ + + let () = ignore module_filename + let tags = [Tags.translator] let intercept_var = fv (Format.asprintf "%s_const" (Namespace.basename name)) @@ -702,6 +722,10 @@ module Parse_type_benchmark : Benchmark.S = struct let info = "Benchmarking parse_ty" + let module_filename = __FILE__ + + let () = ignore module_filename + let make_bench rng_state config () = ( Lwt_main.run (Execution_context.make ~rng_state) >>? fun (ctxt, _) -> let ctxt = Gas_helpers.set_limit ctxt in @@ -754,6 +778,10 @@ module Unparse_type_benchmark : Benchmark.S = struct let info = "Benchmarking unparse_ty" + let module_filename = __FILE__ + + let () = ignore module_filename + let make_bench rng_state config () = ( Lwt_main.run (Execution_context.make ~rng_state) >>? fun (ctxt, _) -> let ctxt = Gas_helpers.set_limit ctxt in -- GitLab From 67bc2f6222c8c4e2f93cbd4bff2b4bd0171bcef5 Mon Sep 17 00:00:00 2001 From: Pavlo Khrystenko Date: Fri, 17 Mar 2023 11:36:05 +0100 Subject: [PATCH 3/6] Snoop: add module filename to Benchmark.S in lib_benchmark --- src/lib_benchmark/benchmark.ml | 3 +++ src/lib_benchmark/builtin_benchmarks.ml | 2 ++ src/lib_benchmark/example/blake2b.ml | 2 ++ src/lib_benchmark/test/test_probe.ml | 2 ++ src/lib_shell_benchmarks/bloomer_benchmarks.ml | 2 -- .../encoding_benchmarks_helpers.ml | 8 -------- src/lib_shell_benchmarks/io_benchmarks.ml | 12 ------------ src/lib_shell_benchmarks/micheline_benchmarks.ml | 2 -- src/lib_shell_benchmarks/misc_benchmarks.ml | 2 -- .../lib_benchmarks_proto/cache_benchmarks.ml | 2 -- .../lib_benchmarks_proto/encodings_benchmarks.ml | 4 ---- .../global_constants_storage_benchmarks.ml | 12 ------------ .../lib_benchmarks_proto/interpreter_benchmarks.ml | 8 -------- .../lib_benchmarks_proto/sapling_benchmarks.ml | 2 -- .../lib_benchmarks_proto/script_repr_benchmarks.ml | 4 ---- .../script_typed_ir_size_benchmarks.ml | 8 -------- .../lib_benchmarks_proto/ticket_benchmarks.ml | 8 -------- .../lib_benchmarks_proto/translator_benchmarks.ml | 14 -------------- 18 files changed, 9 insertions(+), 88 deletions(-) diff --git a/src/lib_benchmark/benchmark.ml b/src/lib_benchmark/benchmark.ml index ea0443e0ee36..35f7bdac1956 100644 --- a/src/lib_benchmark/benchmark.ml +++ b/src/lib_benchmark/benchmark.ml @@ -34,6 +34,9 @@ module type S = sig (** Description of the benchmark *) val info : string + (** File where the benchmark module is defined *) + val module_filename : string + (** Tags of the benchmark *) val tags : string list diff --git a/src/lib_benchmark/builtin_benchmarks.ml b/src/lib_benchmark/builtin_benchmarks.ml index 3031c81d6bba..7e9a11cfb93d 100644 --- a/src/lib_benchmark/builtin_benchmarks.ml +++ b/src/lib_benchmark/builtin_benchmarks.ml @@ -40,6 +40,8 @@ module Timer_latency_bench : Benchmark.S = struct let info = "Measuring timer latency" + let module_filename = __FILE__ + let tags = ["misc"; "builtin"] let models = [("*", Model.(make ~conv:(fun () -> ()) ~model:Model.zero))] diff --git a/src/lib_benchmark/example/blake2b.ml b/src/lib_benchmark/example/blake2b.ml index 935dd531ea87..af1d77d6c884 100644 --- a/src/lib_benchmark/example/blake2b.ml +++ b/src/lib_benchmark/example/blake2b.ml @@ -48,6 +48,8 @@ module Blake2b_bench : Benchmark.S = struct let info = "Illustrating tezos-benchmark by benchmarking blake2b" + let module_filename = __FILE__ + let tags = ["example"] (* We will measure hashing time on random bytes with length diff --git a/src/lib_benchmark/test/test_probe.ml b/src/lib_benchmark/test/test_probe.ml index dc903bc7ef32..80b4bb6650e0 100644 --- a/src/lib_benchmark/test/test_probe.ml +++ b/src/lib_benchmark/test/test_probe.ml @@ -57,6 +57,8 @@ module Probing_bench = struct let default_config = {max_bytes = 1 lsl 16} + let module_filename = __FILE__ + (* The encoding is used by `tezos-snoop` to load the config from json files. *) let config_encoding = diff --git a/src/lib_shell_benchmarks/bloomer_benchmarks.ml b/src/lib_shell_benchmarks/bloomer_benchmarks.ml index baf302b4c7fb..7d84c1f2069e 100644 --- a/src/lib_shell_benchmarks/bloomer_benchmarks.ml +++ b/src/lib_shell_benchmarks/bloomer_benchmarks.ml @@ -44,8 +44,6 @@ let make_bench ~name ~info ~model ~generator ~make_bench : let module_filename = __FILE__ - let () = ignore module_filename - let config_encoding = Data_encoding.unit type workload = unit diff --git a/src/lib_shell_benchmarks/encoding_benchmarks_helpers.ml b/src/lib_shell_benchmarks/encoding_benchmarks_helpers.ml index 612c03d1a233..a0f74edd7ce4 100644 --- a/src/lib_shell_benchmarks/encoding_benchmarks_helpers.ml +++ b/src/lib_shell_benchmarks/encoding_benchmarks_helpers.ml @@ -86,8 +86,6 @@ struct let module_filename = Filename.file - let () = ignore module_filename - let tags = ["encoding"] include Shared_constant_time @@ -117,8 +115,6 @@ struct let module_filename = Filename.file - let () = ignore module_filename - let tags = ["encoding"] include Shared_linear @@ -149,8 +145,6 @@ struct let module_filename = Filename.file - let () = ignore module_filename - let tags = ["encoding"] include Shared_linear @@ -169,8 +163,6 @@ struct let module_filename = Filename.file - let () = ignore module_filename - let tags = ["encoding"] include Shared_linear diff --git a/src/lib_shell_benchmarks/io_benchmarks.ml b/src/lib_shell_benchmarks/io_benchmarks.ml index a4bb9384356f..d6af812df542 100644 --- a/src/lib_shell_benchmarks/io_benchmarks.ml +++ b/src/lib_shell_benchmarks/io_benchmarks.ml @@ -268,8 +268,6 @@ module Context_size_dependent_read_bench : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - include Context_size_dependent_shared let make_bench rng_state cfg () = @@ -357,8 +355,6 @@ module Context_size_dependent_write_bench : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["io"] let write_storage context key bytes = @@ -579,8 +575,6 @@ module Irmin_pack_read_bench : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["io"] type workload = @@ -748,8 +742,6 @@ module Irmin_pack_write_bench : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["io"] type workload = @@ -912,8 +904,6 @@ module Read_random_key_bench : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["io"] type workload = Read_random_key of {depth : int; storage_bytes : int} @@ -1059,8 +1049,6 @@ module Write_random_keys_bench : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["io"] type workload = diff --git a/src/lib_shell_benchmarks/micheline_benchmarks.ml b/src/lib_shell_benchmarks/micheline_benchmarks.ml index aefe2a18aaff..facc69a42af3 100644 --- a/src/lib_shell_benchmarks/micheline_benchmarks.ml +++ b/src/lib_shell_benchmarks/micheline_benchmarks.ml @@ -135,8 +135,6 @@ module Micheline_strip_locations : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["micheline"] type config = unit diff --git a/src/lib_shell_benchmarks/misc_benchmarks.ml b/src/lib_shell_benchmarks/misc_benchmarks.ml index fbab72582376..92db44d0ee13 100644 --- a/src/lib_shell_benchmarks/misc_benchmarks.ml +++ b/src/lib_shell_benchmarks/misc_benchmarks.ml @@ -48,8 +48,6 @@ module Lwt_main_run_bench : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["misc"] let models = [("*", lwt_model)] diff --git a/src/proto_alpha/lib_benchmarks_proto/cache_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/cache_benchmarks.ml index e716ea22ace1..cda89ebf7ca5 100644 --- a/src/proto_alpha/lib_benchmarks_proto/cache_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/cache_benchmarks.ml @@ -135,8 +135,6 @@ module Cache_update_benchmark : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - (** It is expected that cache keys are non-adversarial, ie do not share a long common prefix. This is the case for [Script_cache], for which the keys are B58-encoded contract hashes. diff --git a/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml index 65c6fed2c2b5..34027d0f0834 100644 --- a/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml @@ -137,8 +137,6 @@ module Encoding_micheline : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let micheline_serialization_trace (micheline_node : Alpha_context.Script.node) = match @@ -207,8 +205,6 @@ module Decoding_micheline : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let micheline_deserialization_trace (micheline_str : string) = match Data_encoding.Binary.of_string diff --git a/src/proto_alpha/lib_benchmarks_proto/global_constants_storage_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/global_constants_storage_benchmarks.ml index 1b3ec2aacadd..39859a11d5a6 100644 --- a/src/proto_alpha/lib_benchmarks_proto/global_constants_storage_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/global_constants_storage_benchmarks.ml @@ -298,8 +298,6 @@ module Set_add : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["global_constants"] type config = unit @@ -353,8 +351,6 @@ module Set_elements : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["global_constants"] type config = unit @@ -410,8 +406,6 @@ module Script_expr_hash_of_b58check_opt : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["global_constants"] type config = unit @@ -482,8 +476,6 @@ struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["global_constants"] type config = unit @@ -566,8 +558,6 @@ module Global_constants_storage_expand_models = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["global_constants"] type config = unit @@ -641,8 +631,6 @@ module Global_constants_storage_expand_models = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["global_constants"] type config = unit diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml index dfd4f021b856..73ec037dd88b 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml @@ -274,8 +274,6 @@ let make_benchmark : let module_filename = __FILE__ - let () = ignore module_filename - let benchmark kinstr_and_stack_sampler ctxt step_constants () = let stack_instr = kinstr_and_stack_sampler () in benchmark_from_kinstr_and_stack @@ -558,8 +556,6 @@ let make_continuation_benchmark : let module_filename = __FILE__ - let () = ignore module_filename - let benchmark cont_and_stack_sampler ctxt step_constants () = let stack_instr = cont_and_stack_sampler () in benchmark_from_continuation ?amplification ctxt step_constants stack_instr @@ -657,8 +653,6 @@ module Registration_section = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = [Tags.interpreter] type config = {max_iterations : int} @@ -2730,8 +2724,6 @@ module Registration_section = struct let module_filename = __FILE__ - let () = ignore module_filename - include Default_config include Default_boilerplate diff --git a/src/proto_alpha/lib_benchmarks_proto/sapling_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/sapling_benchmarks.ml index 3401fb381968..63955d43b65d 100644 --- a/src/proto_alpha/lib_benchmarks_proto/sapling_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/sapling_benchmarks.ml @@ -40,8 +40,6 @@ module Apply_diff_bench : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = ["sapling"] let diff_from_tx (tx : Alpha_context.Sapling.transaction) = diff --git a/src/proto_alpha/lib_benchmarks_proto/script_repr_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/script_repr_benchmarks.ml index 272e369375bb..a69895df80f0 100644 --- a/src/proto_alpha/lib_benchmarks_proto/script_repr_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/script_repr_benchmarks.ml @@ -82,8 +82,6 @@ module Micheline_nodes_benchmark : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let size_based_model = Model.make ~conv:(function {micheline_nodes} -> (micheline_nodes, ())) @@ -125,8 +123,6 @@ module Script_repr_strip_annotations : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let strip_annotations_model = Model.( make diff --git a/src/proto_alpha/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml index 4cf2225a0e9a..bbcdc23ca0d9 100644 --- a/src/proto_alpha/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml @@ -79,8 +79,6 @@ end = struct let module_filename = __FILE__ - let () = ignore module_filename - let value_size_benchmark rng_state (node : Protocol.Script_repr.expr) (michelson_type : Script_repr.expr) = (* FIXME: cleanup and factorize this code between translator benches and these ones. *) @@ -154,8 +152,6 @@ module Type_size_benchmark : Tezos_benchmark.Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let models = [(model_name, size_based_model (Namespace.basename name))] let type_size_benchmark (Script_typed_ir.Ex_ty ty) = @@ -200,8 +196,6 @@ end = struct let module_filename = __FILE__ - let () = ignore module_filename - let kinstr_size_benchmark rng_state (expr : Protocol.Script_repr.expr) (stack : Script_repr.expr list) = (* FIXME: cleanup and factorize this code between translator benches and these ones. *) @@ -281,8 +275,6 @@ module Node_size_benchmark : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let size_based_model = Model.make ~conv:(function {micheline_nodes} -> (micheline_nodes, ())) diff --git a/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml index 01986fb95eba..471f90a4ee49 100644 --- a/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml @@ -85,8 +85,6 @@ module Compare_ticket_hash_benchmark : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let compare_model = Model.make ~conv:(fun () -> ()) @@ -140,8 +138,6 @@ module Compare_key_contract_benchmark : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let compare_model = Model.make ~conv:(fun () -> ()) @@ -202,8 +198,6 @@ module Has_tickets_type_benchmark : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let make_bench_helper rng_state config () = let open Result_syntax in let* ctxt, _ = Lwt_main.run (Execution_context.make ~rng_state) in @@ -259,8 +253,6 @@ module Collect_tickets_benchmark : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let make_bench_helper rng_state config () = let open Script_typed_ir in let open Result_syntax in diff --git a/src/proto_alpha/lib_benchmarks_proto/translator_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/translator_benchmarks.ml index c80acc959c06..1ac41b09d433 100644 --- a/src/proto_alpha/lib_benchmarks_proto/translator_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/translator_benchmarks.ml @@ -203,8 +203,6 @@ module Typechecking_data : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let typechecking_data_benchmark rng_state (node : Protocol.Script_repr.expr) (michelson_type : Script_repr.expr) = Lwt_main.run @@ -279,8 +277,6 @@ module Unparsing_data : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let unparsing_data_benchmark rng_state (node : Protocol.Script_repr.expr) (michelson_type : Protocol.Script_repr.expr) = Lwt_main.run @@ -362,8 +358,6 @@ module Typechecking_code : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let typechecking_code_benchmark rng_state (node : Protocol.Script_repr.expr) (stack : Script_repr.expr list) = Lwt_main.run @@ -442,8 +436,6 @@ module Unparsing_code : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let unparsing_code_benchmark rng_state (node : Protocol.Script_repr.expr) (stack : Script_repr.expr list) = Lwt_main.run @@ -575,8 +567,6 @@ module Ty_eq : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let tags = [Tags.translator] let intercept_var = fv (Format.asprintf "%s_const" (Namespace.basename name)) @@ -724,8 +714,6 @@ module Parse_type_benchmark : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let make_bench rng_state config () = ( Lwt_main.run (Execution_context.make ~rng_state) >>? fun (ctxt, _) -> let ctxt = Gas_helpers.set_limit ctxt in @@ -780,8 +768,6 @@ module Unparse_type_benchmark : Benchmark.S = struct let module_filename = __FILE__ - let () = ignore module_filename - let make_bench rng_state config () = ( Lwt_main.run (Execution_context.make ~rng_state) >>? fun (ctxt, _) -> let ctxt = Gas_helpers.set_limit ctxt in -- GitLab From b1df8b0aa1068ee16c1f936b9121e2afbf9c643b Mon Sep 17 00:00:00 2001 From: Pavlo Khrystenko Date: Fri, 17 Mar 2023 11:59:44 +0100 Subject: [PATCH 4/6] Snoop: display benchmark filename in the cli --- src/bin_snoop/commands.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bin_snoop/commands.ml b/src/bin_snoop/commands.ml index 6806d8a95501..de6d446c64d2 100644 --- a/src/bin_snoop/commands.ml +++ b/src/bin_snoop/commands.ml @@ -1412,6 +1412,7 @@ module Display_info_cmd = struct let pp_fancy_benchmark fmt (module B : Benchmark.S) = bold_block fmt "Name" Namespace.pp B.name ; + bold_block fmt "Filename" Format.pp_print_string B.module_filename ; bold_block fmt "Info" Format.pp_print_string B.info ; bold_block fmt "Tags" pp_tags B.tags ; bold_block fmt "Models" (pp_models ()) B.models -- GitLab From 0d516799248206f6dfa54949db24b16388be1e55 Mon Sep 17 00:00:00 2001 From: Pavlo Khrystenko Date: Wed, 29 Mar 2023 12:39:35 +0200 Subject: [PATCH 5/6] Snoop: add benchmark filenames to proto/lima --- .../lib_benchmarks_proto/cache_benchmarks.ml | 2 + .../carbonated_map_benchmarks.ml | 8 +++ .../encodings_benchmarks.ml | 66 ++++++++++--------- .../global_constants_storage_benchmarks.ml | 12 ++++ .../interpreter_benchmarks.ml | 8 +++ .../sapling_benchmarks.ml | 2 + .../sc_rollup_benchmarks.ml | 4 ++ .../script_repr_benchmarks.ml | 4 ++ .../script_typed_ir_size_benchmarks.ml | 8 +++ .../storage_benchmarks.ml | 2 + .../lib_benchmarks_proto/ticket_benchmarks.ml | 8 +++ .../translator_benchmarks.ml | 17 +++++ .../tx_rollup_benchmarks.ml | 6 ++ 13 files changed, 116 insertions(+), 31 deletions(-) diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/cache_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/cache_benchmarks.ml index 73acf4329bcd..91c580f09c19 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/cache_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/cache_benchmarks.ml @@ -131,6 +131,8 @@ module Cache_update_benchmark : Benchmark.S = struct let info = "Benchmarking the time it takes to update a key in the cache" + let module_filename = __FILE__ + (** It is expected that cache keys are non-adversarial, ie do not share a long common prefix. This is the case for [Script_cache], for which the keys are B58-encoded contract hashes. diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/carbonated_map_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/carbonated_map_benchmarks.ml index 3864e6c17a48..8caf846bb0ec 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/carbonated_map_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/carbonated_map_benchmarks.ml @@ -81,6 +81,8 @@ module Fold_benchmark : Benchmark.S = struct let info = "Carbonated map to list" + let module_filename = __FILE__ + let fold_model = Model.make ~conv:(fun {size} -> (size, ())) @@ -169,6 +171,8 @@ module Make (CS : COMPARABLE_SAMPLER) = struct let info = Printf.sprintf "Carbonated map compare cost for %s keys" CS.type_name + let module_filename = __FILE__ + let models = [ ( "carbonated_map", @@ -209,6 +213,8 @@ module Make (CS : COMPARABLE_SAMPLER) = struct let info = Printf.sprintf "Carbonated find model" + let module_filename = __FILE__ + (** Given the cost of comparing keys, the model is used for deducing [intercept] and [traverse_overhead] from: @@ -312,6 +318,8 @@ module Make (CS : COMPARABLE_SAMPLER) = struct let info = Printf.sprintf "Carbonated find model (intercept case)" + let module_filename = __FILE__ + let models = [ ( "carbonated_map", diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/encodings_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/encodings_benchmarks.ml index 0e81ca18d788..fd8dcb25963b 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/encodings_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/encodings_benchmarks.ml @@ -135,6 +135,8 @@ module Encoding_micheline : Benchmark.S = struct let info = "Benchmarking strip_location + encoding of Micheline to bytes" + let module_filename = __FILE__ + let micheline_serialization_trace (micheline_node : Alpha_context.Script.node) = match @@ -203,6 +205,8 @@ module Decoding_micheline : Benchmark.S = struct let info = "Decoding of bytes to Micheline" + let module_filename = __FILE__ + let micheline_deserialization_trace (micheline_str : string) = match Data_encoding.Binary.of_string @@ -267,27 +271,31 @@ end let () = Registration_helpers.register (module Decoding_micheline) +module Encodings = +Tezos_shell_benchmarks.Encoding_benchmarks_helpers.Make (struct + let file = __FILE__ +end) + module Timestamp = struct let () = Registration_helpers.register - @@ - let open Tezos_shell_benchmarks.Encoding_benchmarks_helpers in - fixed_size_shared - ~name:"TIMESTAMP_READABLE_ENCODING" - ~generator:(fun rng_state -> - let seconds_in_year = 30_000_000 in - let offset = Random.State.int rng_state seconds_in_year in - Script_timestamp.of_zint (Z.of_int (1597764116 + offset))) - ~make_bench:(fun generator () -> - let tstamp_string = generator () in - let closure () = ignore (Script_timestamp.to_notation tstamp_string) in - Generator.Plain {workload = (); closure}) - () + @@ Encodings.fixed_size_shared + ~name:"TIMESTAMP_READABLE_ENCODING" + ~generator:(fun rng_state -> + let seconds_in_year = 30_000_000 in + let offset = Random.State.int rng_state seconds_in_year in + Script_timestamp.of_zint (Z.of_int (1597764116 + offset))) + ~make_bench:(fun generator () -> + let tstamp_string = generator () in + let closure () = + ignore (Script_timestamp.to_notation tstamp_string) + in + Generator.Plain {workload = (); closure}) + () let () = let b, b_intercept = - let open Tezos_shell_benchmarks.Encoding_benchmarks_helpers in - nsqrtn_shared_with_intercept + Encodings.nsqrtn_shared_with_intercept ~name:"TIMESTAMP_READABLE_DECODING" ~generator:(fun rng_state -> let offset = @@ -322,8 +330,6 @@ end https://gitlab.com/dannywillems/ocaml-bls12-381/-/blob/71d0b4d467fbfaa6452d702fcc408d7a70916a80/README.md#install *) module BLS = struct - open Tezos_shell_benchmarks.Encoding_benchmarks_helpers - let check () = if not Bls12_381.built_with_blst_portable then ( Format.eprintf @@ -334,7 +340,7 @@ module BLS = struct let () = Registration_helpers.register - @@ make_encode_fixed_size_to_bytes + @@ Encodings.make_encode_fixed_size_to_bytes ~check ~name:"ENCODING_BLS_FR" ~to_bytes:Bls12_381.Fr.to_bytes @@ -343,7 +349,7 @@ module BLS = struct let () = Registration_helpers.register - @@ make_encode_fixed_size_to_bytes + @@ Encodings.make_encode_fixed_size_to_bytes ~check ~name:"ENCODING_BLS_G1" ~to_bytes:Bls12_381.G1.to_bytes @@ -352,7 +358,7 @@ module BLS = struct let () = Registration_helpers.register - @@ make_encode_fixed_size_to_bytes + @@ Encodings.make_encode_fixed_size_to_bytes ~check ~name:"ENCODING_BLS_G2" ~to_bytes:Bls12_381.G2.to_bytes @@ -361,7 +367,7 @@ module BLS = struct let () = Registration_helpers.register - @@ make_decode_fixed_size_from_bytes + @@ Encodings.make_decode_fixed_size_from_bytes ~check ~name:"DECODING_BLS_FR" ~to_bytes:Bls12_381.Fr.to_bytes @@ -371,7 +377,7 @@ module BLS = struct let () = Registration_helpers.register - @@ make_decode_fixed_size_from_bytes + @@ Encodings.make_decode_fixed_size_from_bytes ~check ~name:"DECODING_BLS_G1" ~to_bytes:Bls12_381.G1.to_bytes @@ -381,7 +387,7 @@ module BLS = struct let () = Registration_helpers.register - @@ make_decode_fixed_size_from_bytes + @@ Encodings.make_decode_fixed_size_from_bytes ~check ~name:"DECODING_BLS_G2" ~to_bytes:Bls12_381.G2.to_bytes @@ -391,7 +397,7 @@ module BLS = struct let () = Registration_helpers.register - @@ fixed_size_shared + @@ Encodings.fixed_size_shared ~check ~name:"BLS_FR_FROM_Z" ~generator:(fun rng_state -> Bls12_381.Fr.random ~state:rng_state ()) @@ -404,7 +410,7 @@ module BLS = struct let () = Registration_helpers.register - @@ fixed_size_shared + @@ Encodings.fixed_size_shared ~check ~name:"BLS_FR_TO_Z" ~generator:(fun rng_state -> Bls12_381.Fr.random ~state:rng_state ()) @@ -416,8 +422,6 @@ module BLS = struct end module Timelock = struct - open Tezos_shell_benchmarks.Encoding_benchmarks_helpers - let generator rng_state = let log_time = Base_samplers.sample_in_interval ~range:{min = 0; max = 29} rng_state @@ -433,7 +437,7 @@ module Timelock = struct let () = Registration_helpers.register - @@ make_encode_variable_size_to_string + @@ Encodings.make_encode_variable_size_to_string ~name:"ENCODING_Chest" ~to_string: (Data_encoding.Binary.to_string_exn @@ -445,7 +449,7 @@ module Timelock = struct let () = Registration_helpers.register - @@ make_encode_fixed_size_to_string + @@ Encodings.make_encode_fixed_size_to_string ~name:"ENCODING_Chest_key" ~to_string: (Data_encoding.Binary.to_string_exn @@ -457,7 +461,7 @@ module Timelock = struct let () = Registration_helpers.register - @@ make_decode_variable_size_from_bytes + @@ Encodings.make_decode_variable_size_from_bytes ~name:"DECODING_Chest" ~to_bytes: (Data_encoding.Binary.to_bytes_exn @@ -477,7 +481,7 @@ module Timelock = struct let () = Registration_helpers.register - @@ make_decode_fixed_size_from_bytes + @@ Encodings.make_decode_fixed_size_from_bytes ~name:"DECODING_Chest_key" ~to_bytes: (Data_encoding.Binary.to_bytes_exn diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/global_constants_storage_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/global_constants_storage_benchmarks.ml index 20b9fbdbb860..9410f13e0a6d 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/global_constants_storage_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/global_constants_storage_benchmarks.ml @@ -294,6 +294,8 @@ module Set_add : Benchmark.S = struct let info = "Benchmarks and cost model for set element addition from OCaml stdlib." + let module_filename = __FILE__ + let tags = ["global_constants"] type config = unit @@ -348,6 +350,8 @@ module Set_elements : Benchmark.S = struct let info = "Benchmarks and cost model for set elements from OCaml stdlib." + let module_filename = __FILE__ + let tags = ["global_constants"] type config = unit @@ -405,6 +409,8 @@ module Script_expr_hash_of_b58check_opt : Benchmark.S = struct let info = "Benchmark for Script_expr_hash.of_b58check_opt" + let module_filename = __FILE__ + let tags = ["global_constants"] type config = unit @@ -475,6 +481,8 @@ struct Global_constants_storage.Internal_for_tests.expr_to_address_in_context \ function" + let module_filename = __FILE__ + let tags = ["global_constants"] type config = unit @@ -559,6 +567,8 @@ module Global_constants_storage_expand_models = struct "Benchmark for the constant branch Global_constants_storage.expand \ function" + let module_filename = __FILE__ + let tags = ["global_constants"] type config = unit @@ -635,6 +645,8 @@ module Global_constants_storage_expand_models = struct "Benchmark for the Global_constants_storage.expand function on the case \ without constants" + let module_filename = __FILE__ + let tags = ["global_constants"] type config = unit diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/interpreter_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/interpreter_benchmarks.ml index 2757ec3b52b6..1931e0462959 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/interpreter_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/interpreter_benchmarks.ml @@ -256,6 +256,8 @@ let make_benchmark : let tags = tags @ more_tags + let module_filename = __FILE__ + let models = (* [intercept = true] implies there's a benchmark with [intercept = false]. No need to register the model twice. *) @@ -541,6 +543,8 @@ let make_continuation_benchmark : include Default_config include Default_boilerplate + let module_filename = __FILE__ + let tags = tags @ more_tags let models = @@ -651,6 +655,8 @@ module Registration_section = struct let info = "Benchmarking the cost of an empty loop" + let module_filename = __FILE__ + let tags = [Tags.interpreter] type config = {max_iterations : int} @@ -2541,6 +2547,8 @@ module Registration_section = struct let info = info + let module_filename = __FILE__ + include Default_config include Default_boilerplate diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/sapling_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/sapling_benchmarks.ml index e0bcdf21536d..767e5861b88a 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/sapling_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/sapling_benchmarks.ml @@ -36,6 +36,8 @@ module Apply_diff_bench : Benchmark.S = struct let info = "Benchmarking SAPLING_APPLY_DIFF" + let module_filename = __FILE__ + let tags = ["sapling"] let diff_from_tx (tx : Alpha_context.Sapling.transaction) = diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/sc_rollup_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/sc_rollup_benchmarks.ml index 6b31573630f9..c769e534932f 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/sc_rollup_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/sc_rollup_benchmarks.ml @@ -41,6 +41,8 @@ module Sc_rollup_update_num_and_size_of_messages_benchmark = struct "Estimating the cost of updating the number and total size of messages \ when adding a message to a sc_rollup inbox" + let module_filename = __FILE__ + let tags = ["scoru"] type config = { @@ -143,6 +145,8 @@ module Sc_rollup_add_external_messages_benchmark = struct let info = "Estimating the costs of adding a single message to a rollup inbox" + let module_filename = __FILE__ + let tags = ["scoru"] type config = {max_length : int; max_level : int} diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/script_repr_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/script_repr_benchmarks.ml index 3c8493c028ec..a68744913e2d 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/script_repr_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/script_repr_benchmarks.ml @@ -78,6 +78,8 @@ module Micheline_nodes_benchmark : Benchmark.S = struct "Benchmarking the time it takes to compute the number of nodes of a \ Micheline term" + let module_filename = __FILE__ + let size_based_model = Model.make ~conv:(function {micheline_nodes} -> (micheline_nodes, ())) @@ -117,6 +119,8 @@ module Script_repr_strip_annotations : Benchmark.S = struct let info = "Benchmarking Script_repr.strip_annotations" + let module_filename = __FILE__ + let strip_annotations_model = Model.( make diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml index cc436c940699..5199ed85e765 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml @@ -79,6 +79,8 @@ end = struct let info = "Benchmarking Script_typed_ir_size.value_size" + let module_filename = __FILE__ + let value_size_benchmark rng_state (node : Protocol.Script_repr.expr) (michelson_type : Script_repr.expr) = (* FIXME: cleanup and factorize this code between translator benches and these ones. *) @@ -152,6 +154,8 @@ module Type_size_benchmark : Tezos_benchmark.Benchmark.S = struct let info = "Benchmarking the time it takes to compute Script_typed_ir_size.ty_size" + let module_filename = __FILE__ + let models = [(model_name, size_based_model name)] let type_size_benchmark (Script_typed_ir.Ex_ty ty) = @@ -196,6 +200,8 @@ end = struct let info = "Benchmarking Script_typed_ir_size.kinstr_size" + let module_filename = __FILE__ + let kinstr_size_benchmark rng_state (expr : Protocol.Script_repr.expr) (stack : Script_repr.expr list) = (* FIXME: cleanup and factorize this code between translator benches and these ones. *) @@ -275,6 +281,8 @@ module Node_size_benchmark : Benchmark.S = struct let info = "Benchmarking the time it takes to compute Script_typed_ir_size.node_size" + let module_filename = __FILE__ + let size_based_model = Model.make ~conv:(function {micheline_nodes} -> (micheline_nodes, ())) diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/storage_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/storage_benchmarks.ml index 03d06bdb91b3..64a07a303a78 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/storage_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/storage_benchmarks.ml @@ -143,6 +143,8 @@ module List_key_values_benchmark_boilerplate = struct let info = "List key values" + let module_filename = __FILE__ + let config_encoding = let open Data_encoding in conv diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/ticket_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/ticket_benchmarks.ml index 8ea1e4dd5970..27fc7edd42b1 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/ticket_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/ticket_benchmarks.ml @@ -81,6 +81,8 @@ module Compare_ticket_hash_benchmark : Benchmark.S = struct let info = "Compare cost for Ticket_hash" + let module_filename = __FILE__ + let compare_model = Model.make ~conv:(fun () -> ()) @@ -137,6 +139,8 @@ module Compare_key_contract_benchmark : Benchmark.S = struct let info = "Compare cost for Contracts" + let module_filename = __FILE__ + let compare_model = Model.make ~conv:(fun () -> ()) @@ -200,6 +204,8 @@ module Has_tickets_type_benchmark : Benchmark.S = struct let info = "Benchmarking type_has_tickets" + let module_filename = __FILE__ + let make_bench_helper rng_state config () = let open Result_syntax in let* ctxt, _ = Lwt_main.run (Execution_context.make ~rng_state) in @@ -260,6 +266,8 @@ module Collect_tickets_benchmark : Benchmark.S = struct let info = "Benchmarking tickets_of_value" + let module_filename = __FILE__ + let make_bench_helper rng_state config () = let open Script_typed_ir in let open Result_syntax in diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/translator_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/translator_benchmarks.ml index 7885440a0bff..55de65841f1f 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/translator_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/translator_benchmarks.ml @@ -193,6 +193,8 @@ module Typechecking_data : Benchmark.S = struct let info = "Benchmarking typechecking of data" + let module_filename = __FILE__ + let typechecking_data_benchmark rng_state (node : Protocol.Script_repr.expr) (michelson_type : Script_repr.expr) = Lwt_main.run @@ -267,6 +269,8 @@ module Unparsing_data : Benchmark.S = struct let info = "Benchmarking unparsing of data" + let module_filename = __FILE__ + let unparsing_data_benchmark rng_state (node : Protocol.Script_repr.expr) (michelson_type : Protocol.Script_repr.expr) = Lwt_main.run @@ -348,6 +352,8 @@ module Typechecking_code : Benchmark.S = struct let info = "Benchmarking typechecking of code" + let module_filename = __FILE__ + let typechecking_code_benchmark rng_state (node : Protocol.Script_repr.expr) (stack : Script_repr.expr list) = Lwt_main.run @@ -426,6 +432,8 @@ module Unparsing_code : Benchmark.S = struct let info = "Benchmarking unparsing of code" + let module_filename = __FILE__ + let unparsing_code_benchmark rng_state (node : Protocol.Script_repr.expr) (stack : Script_repr.expr list) = Lwt_main.run @@ -508,6 +516,9 @@ let rec check_printable_ascii v i = let check_printable_benchmark = let open Tezos_shell_benchmarks.Encoding_benchmarks_helpers in + let open Tezos_shell_benchmarks.Encoding_benchmarks_helpers.Make (struct + let file = __FILE__ + end) in linear_shared ~name:"CHECK_PRINTABLE" ~generator:(fun rng_state -> @@ -556,6 +567,8 @@ module Ty_eq : Benchmark.S = struct let info = "Benchmarking equating types" + let module_filename = __FILE__ + let tags = [Tags.translator] let intercept_var = Free_variable.of_string (Format.asprintf "%s_const" name) @@ -711,6 +724,8 @@ module Parse_type_benchmark : Benchmark.S = struct let info = "Benchmarking parse_ty" + let module_filename = __FILE__ + let make_bench rng_state config () = ( Lwt_main.run (Execution_context.make ~rng_state) >>? fun (ctxt, _) -> let ctxt = Gas_helpers.set_limit ctxt in @@ -765,6 +780,8 @@ module Unparse_type_benchmark : Benchmark.S = struct let info = "Benchmarking unparse_ty" + let module_filename = __FILE__ + let make_bench rng_state config () = ( Lwt_main.run (Execution_context.make ~rng_state) >>? fun (ctxt, _) -> let ctxt = Gas_helpers.set_limit ctxt in diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/tx_rollup_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/tx_rollup_benchmarks.ml index 3bb4854bb2c0..464106d9497d 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/tx_rollup_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/tx_rollup_benchmarks.ml @@ -32,6 +32,8 @@ module Inbox_add_message : Benchmark.S = struct let info = "Benchmark for Merkle.add_message" + let module_filename = __FILE__ + let tags = ["tx_rollup"; "merkle"; "inbox"; "add_message"] type config = {max_messages : int} @@ -120,6 +122,8 @@ module Commitment_full_compact_bench : Benchmark.S = struct let info = "Benchmark for Tx_rollup_commitment_repr.Full.compact" + let module_filename = __FILE__ + let tags = ["tx_rollup"; "merkle"; "commitment"; "compact"] type config = {max_messages : int} @@ -552,6 +556,8 @@ module Verify_proof_compute_bench : Benchmark.S = struct let info = "Benchmark for Tx_rollup.verify_proof" + let module_filename = __FILE__ + let tags = ["tx_rollup"; "merkle"; "verify"; "proof"] type config = {max_withdrawals : int} -- GitLab From 9c99cbe9892295bece11d7d9295fa248c584ccd0 Mon Sep 17 00:00:00 2001 From: Pavlo Khrystenko Date: Wed, 29 Mar 2023 12:45:37 +0200 Subject: [PATCH 6/6] Snoop: add benchmark filenames to proto/mumbai --- .../lib_benchmarks_proto/cache_benchmarks.ml | 2 + .../carbonated_map_benchmarks.ml | 8 +++ .../encodings_benchmarks.ml | 66 ++++++++++--------- .../global_constants_storage_benchmarks.ml | 12 ++++ .../interpreter_benchmarks.ml | 8 +++ .../sapling_benchmarks.ml | 2 + .../sc_rollup_benchmarks.ml | 4 ++ .../script_repr_benchmarks.ml | 4 ++ .../script_typed_ir_size_benchmarks.ml | 8 +++ .../skip_list_benchmarks.ml | 4 ++ .../storage_benchmarks.ml | 2 + .../lib_benchmarks_proto/ticket_benchmarks.ml | 8 +++ .../translator_benchmarks.ml | 17 +++++ .../tx_rollup_benchmarks.ml | 6 ++ 14 files changed, 120 insertions(+), 31 deletions(-) diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/cache_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/cache_benchmarks.ml index 08a410788db8..cda89ebf7ca5 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/cache_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/cache_benchmarks.ml @@ -133,6 +133,8 @@ module Cache_update_benchmark : Benchmark.S = struct let info = "Benchmarking the time it takes to update a key in the cache" + let module_filename = __FILE__ + (** It is expected that cache keys are non-adversarial, ie do not share a long common prefix. This is the case for [Script_cache], for which the keys are B58-encoded contract hashes. diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/carbonated_map_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/carbonated_map_benchmarks.ml index 119d716a4fa2..3e6c36d66624 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/carbonated_map_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/carbonated_map_benchmarks.ml @@ -86,6 +86,8 @@ module Fold_benchmark : Benchmark.S = struct let info = "Carbonated map to list" + let module_filename = __FILE__ + let fold_model = Model.make ~conv:(fun {size} -> (size, ())) @@ -170,6 +172,8 @@ module Make (CS : COMPARABLE_SAMPLER) = struct let info = Printf.sprintf "Carbonated map compare cost for %s keys" CS.type_name + let module_filename = __FILE__ + let models = [ ( "carbonated_map", @@ -206,6 +210,8 @@ module Make (CS : COMPARABLE_SAMPLER) = struct let info = Printf.sprintf "Carbonated find model" + let module_filename = __FILE__ + (** Given the cost of comparing keys, the model is used for deducing [intercept] and [traverse_overhead] from: @@ -306,6 +312,8 @@ module Make (CS : COMPARABLE_SAMPLER) = struct let info = Printf.sprintf "Carbonated find model (intercept case)" + let module_filename = __FILE__ + let models = [ ( "carbonated_map", diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/encodings_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/encodings_benchmarks.ml index 9afaa8331315..5e19e2df56a2 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/encodings_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/encodings_benchmarks.ml @@ -129,6 +129,8 @@ module Encoding_micheline : Benchmark.S = struct let info = "Benchmarking strip_location + encoding of Micheline to bytes" + let module_filename = __FILE__ + let micheline_serialization_trace (micheline_node : Alpha_context.Script.node) = match @@ -195,6 +197,8 @@ module Decoding_micheline : Benchmark.S = struct let info = "Decoding of bytes to Micheline" + let module_filename = __FILE__ + let micheline_deserialization_trace (micheline_str : string) = match Data_encoding.Binary.of_string @@ -257,27 +261,31 @@ end let () = Registration_helpers.register (module Decoding_micheline) +module Encodings = +Tezos_shell_benchmarks.Encoding_benchmarks_helpers.Make (struct + let file = __FILE__ +end) + module Timestamp = struct let () = Registration_helpers.register - @@ - let open Tezos_shell_benchmarks.Encoding_benchmarks_helpers in - fixed_size_shared - ~name:"TIMESTAMP_READABLE_ENCODING" - ~generator:(fun rng_state -> - let seconds_in_year = 30_000_000 in - let offset = Random.State.int rng_state seconds_in_year in - Script_timestamp.of_zint (Z.of_int (1597764116 + offset))) - ~make_bench:(fun generator () -> - let tstamp_string = generator () in - let closure () = ignore (Script_timestamp.to_notation tstamp_string) in - Generator.Plain {workload = (); closure}) - () + @@ Encodings.fixed_size_shared + ~name:"TIMESTAMP_READABLE_ENCODING" + ~generator:(fun rng_state -> + let seconds_in_year = 30_000_000 in + let offset = Random.State.int rng_state seconds_in_year in + Script_timestamp.of_zint (Z.of_int (1597764116 + offset))) + ~make_bench:(fun generator () -> + let tstamp_string = generator () in + let closure () = + ignore (Script_timestamp.to_notation tstamp_string) + in + Generator.Plain {workload = (); closure}) + () let () = let b, b_intercept = - let open Tezos_shell_benchmarks.Encoding_benchmarks_helpers in - nsqrtn_shared_with_intercept + Encodings.nsqrtn_shared_with_intercept ~name:"TIMESTAMP_READABLE_DECODING" ~generator:(fun rng_state -> let offset = @@ -312,8 +320,6 @@ end https://gitlab.com/dannywillems/ocaml-bls12-381/-/blob/71d0b4d467fbfaa6452d702fcc408d7a70916a80/README.md#install *) module BLS = struct - open Tezos_shell_benchmarks.Encoding_benchmarks_helpers - let check () = if not Bls12_381.built_with_blst_portable then ( Format.eprintf @@ -324,7 +330,7 @@ module BLS = struct let () = Registration_helpers.register - @@ make_encode_fixed_size_to_bytes + @@ Encodings.make_encode_fixed_size_to_bytes ~check ~name:"ENCODING_BLS_FR" ~to_bytes:Bls12_381.Fr.to_bytes @@ -333,7 +339,7 @@ module BLS = struct let () = Registration_helpers.register - @@ make_encode_fixed_size_to_bytes + @@ Encodings.make_encode_fixed_size_to_bytes ~check ~name:"ENCODING_BLS_G1" ~to_bytes:Bls12_381.G1.to_bytes @@ -342,7 +348,7 @@ module BLS = struct let () = Registration_helpers.register - @@ make_encode_fixed_size_to_bytes + @@ Encodings.make_encode_fixed_size_to_bytes ~check ~name:"ENCODING_BLS_G2" ~to_bytes:Bls12_381.G2.to_bytes @@ -351,7 +357,7 @@ module BLS = struct let () = Registration_helpers.register - @@ make_decode_fixed_size_from_bytes + @@ Encodings.make_decode_fixed_size_from_bytes ~check ~name:"DECODING_BLS_FR" ~to_bytes:Bls12_381.Fr.to_bytes @@ -361,7 +367,7 @@ module BLS = struct let () = Registration_helpers.register - @@ make_decode_fixed_size_from_bytes + @@ Encodings.make_decode_fixed_size_from_bytes ~check ~name:"DECODING_BLS_G1" ~to_bytes:Bls12_381.G1.to_bytes @@ -371,7 +377,7 @@ module BLS = struct let () = Registration_helpers.register - @@ make_decode_fixed_size_from_bytes + @@ Encodings.make_decode_fixed_size_from_bytes ~check ~name:"DECODING_BLS_G2" ~to_bytes:Bls12_381.G2.to_bytes @@ -381,7 +387,7 @@ module BLS = struct let () = Registration_helpers.register - @@ fixed_size_shared + @@ Encodings.fixed_size_shared ~check ~name:"BLS_FR_FROM_Z" ~generator:(fun rng_state -> Bls12_381.Fr.random ~state:rng_state ()) @@ -394,7 +400,7 @@ module BLS = struct let () = Registration_helpers.register - @@ fixed_size_shared + @@ Encodings.fixed_size_shared ~check ~name:"BLS_FR_TO_Z" ~generator:(fun rng_state -> Bls12_381.Fr.random ~state:rng_state ()) @@ -406,8 +412,6 @@ module BLS = struct end module Timelock = struct - open Tezos_shell_benchmarks.Encoding_benchmarks_helpers - let generator rng_state = let log_time = Base_samplers.sample_in_interval ~range:{min = 0; max = 29} rng_state @@ -423,7 +427,7 @@ module Timelock = struct let () = Registration_helpers.register - @@ make_encode_variable_size_to_string + @@ Encodings.make_encode_variable_size_to_string ~name:"ENCODING_Chest" ~to_string: (Data_encoding.Binary.to_string_exn @@ -435,7 +439,7 @@ module Timelock = struct let () = Registration_helpers.register - @@ make_encode_fixed_size_to_string + @@ Encodings.make_encode_fixed_size_to_string ~name:"ENCODING_Chest_key" ~to_string: (Data_encoding.Binary.to_string_exn @@ -447,7 +451,7 @@ module Timelock = struct let () = Registration_helpers.register - @@ make_decode_variable_size_from_bytes + @@ Encodings.make_decode_variable_size_from_bytes ~name:"DECODING_Chest" ~to_bytes: (Data_encoding.Binary.to_bytes_exn @@ -467,7 +471,7 @@ module Timelock = struct let () = Registration_helpers.register - @@ make_decode_fixed_size_from_bytes + @@ Encodings.make_decode_fixed_size_from_bytes ~name:"DECODING_Chest_key" ~to_bytes: (Data_encoding.Binary.to_bytes_exn diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/global_constants_storage_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/global_constants_storage_benchmarks.ml index 2a3030a39ee9..b32a7eefce51 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/global_constants_storage_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/global_constants_storage_benchmarks.ml @@ -296,6 +296,8 @@ module Set_add : Benchmark.S = struct let info = "Benchmarks and cost model for set element addition from OCaml stdlib." + let module_filename = __FILE__ + let tags = ["global_constants"] type config = unit @@ -349,6 +351,8 @@ module Set_elements : Benchmark.S = struct let info = "Benchmarks and cost model for set elements from OCaml stdlib." + let module_filename = __FILE__ + let tags = ["global_constants"] type config = unit @@ -404,6 +408,8 @@ module Script_expr_hash_of_b58check_opt : Benchmark.S = struct let info = "Benchmark for Script_expr_hash.of_b58check_opt" + let module_filename = __FILE__ + let tags = ["global_constants"] type config = unit @@ -476,6 +482,8 @@ struct Global_constants_storage.Internal_for_tests.expr_to_address_in_context \ function" + let module_filename = __FILE__ + let tags = ["global_constants"] type config = unit @@ -559,6 +567,8 @@ module Global_constants_storage_expand_models = struct "Benchmark for the constant branch Global_constants_storage.expand \ function" + let module_filename = __FILE__ + let tags = ["global_constants"] type config = unit @@ -633,6 +643,8 @@ module Global_constants_storage_expand_models = struct "Benchmark for the Global_constants_storage.expand function on the case \ without constants" + let module_filename = __FILE__ + let tags = ["global_constants"] type config = unit diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/interpreter_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/interpreter_benchmarks.ml index a8e752fb614c..a3c850235db0 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/interpreter_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/interpreter_benchmarks.ml @@ -261,6 +261,8 @@ let make_benchmark : let tags = tags @ more_tags + let module_filename = __FILE__ + let models = (* [intercept = true] implies there's a benchmark with [intercept = false]. No need to register the model twice. *) @@ -542,6 +544,8 @@ let make_continuation_benchmark : include Default_config include Default_boilerplate + let module_filename = __FILE__ + let tags = tags @ more_tags let models = Interpreter_model.make_model ?amplification (Cont_name name) @@ -647,6 +651,8 @@ module Registration_section = struct let info = "Benchmarking the cost of an empty loop" + let module_filename = __FILE__ + let tags = [Tags.interpreter] type config = {max_iterations : int} @@ -2696,6 +2702,8 @@ module Registration_section = struct let info = info + let module_filename = __FILE__ + include Default_config include Default_boilerplate diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/sapling_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/sapling_benchmarks.ml index 1ceef0bfd148..63955d43b65d 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/sapling_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/sapling_benchmarks.ml @@ -38,6 +38,8 @@ module Apply_diff_bench : Benchmark.S = struct let info = "Benchmarking SAPLING_APPLY_DIFF" + let module_filename = __FILE__ + let tags = ["sapling"] let diff_from_tx (tx : Alpha_context.Sapling.transaction) = diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/sc_rollup_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/sc_rollup_benchmarks.ml index 3d2ddcd056ee..790ffda4a01b 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/sc_rollup_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/sc_rollup_benchmarks.ml @@ -288,6 +288,8 @@ module Sc_rollup_verify_output_proof_benchmark = struct let info = "Estimating the cost of verifying an output proof" + let module_filename = __FILE__ + let tags = ["sc_rollup"] type config = { @@ -503,6 +505,8 @@ module Sc_rollup_deserialize_output_proof_benchmark = struct let info = "Estimating the cost of deserializing an output proof" + let module_filename = __FILE__ + let tags = ["sc_rollup"] type config = { diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/script_repr_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/script_repr_benchmarks.ml index 62931e72ea82..3823502d4ee2 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/script_repr_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/script_repr_benchmarks.ml @@ -80,6 +80,8 @@ module Micheline_nodes_benchmark : Benchmark.S = struct "Benchmarking the time it takes to compute the number of nodes of a \ Micheline term" + let module_filename = __FILE__ + let size_based_model = Model.make ~conv:(function {micheline_nodes} -> (micheline_nodes, ())) @@ -124,6 +126,8 @@ module Script_repr_strip_annotations : Benchmark.S = struct let info = "Benchmarking Script_repr.strip_annotations" + let module_filename = __FILE__ + let strip_annotations_model = Model.( make diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml index eac715216405..f21095fe7411 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/script_typed_ir_size_benchmarks.ml @@ -77,6 +77,8 @@ end = struct let info = "Benchmarking Script_typed_ir_size.value_size" + let module_filename = __FILE__ + let value_size_benchmark rng_state (node : Protocol.Script_repr.expr) (michelson_type : Script_repr.expr) = (* FIXME: cleanup and factorize this code between translator benches and these ones. *) @@ -148,6 +150,8 @@ module Type_size_benchmark : Tezos_benchmark.Benchmark.S = struct let info = "Benchmarking the time it takes to compute Script_typed_ir_size.ty_size" + let module_filename = __FILE__ + let models = [(model_name, size_based_model (Namespace.basename name))] let type_size_benchmark (Script_typed_ir.Ex_ty ty) = @@ -190,6 +194,8 @@ end = struct let info = "Benchmarking Script_typed_ir_size.kinstr_size" + let module_filename = __FILE__ + let kinstr_size_benchmark rng_state (expr : Protocol.Script_repr.expr) (stack : Script_repr.expr list) = (* FIXME: cleanup and factorize this code between translator benches and these ones. *) @@ -267,6 +273,8 @@ module Node_size_benchmark : Benchmark.S = struct let info = "Benchmarking the time it takes to compute Script_typed_ir_size.node_size" + let module_filename = __FILE__ + let size_based_model = Model.make ~conv:(function {micheline_nodes} -> (micheline_nodes, ())) diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/skip_list_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/skip_list_benchmarks.ml index 5125478a75ab..3be54fc0b014 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/skip_list_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/skip_list_benchmarks.ml @@ -45,6 +45,8 @@ module Next : Benchmark.S = struct let info = "Benchmark for Skip_list_repr.next" + let module_filename = __FILE__ + let tags = ["skip_list"] type config = {max_items : int} @@ -97,6 +99,8 @@ module Hash_cell = struct let info = "Estimating the costs of hashing a skip list cell" + let module_filename = __FILE__ + let tags = ["skip_list"] include Skip_list diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/storage_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/storage_benchmarks.ml index 4967805a7b75..0f85b7714aad 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/storage_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/storage_benchmarks.ml @@ -145,6 +145,8 @@ module List_key_values_benchmark_boilerplate = struct let info = "List key values" + let module_filename = __FILE__ + let config_encoding = let open Data_encoding in conv diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/ticket_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/ticket_benchmarks.ml index 8e37c1989a1b..521038eec8c9 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/ticket_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/ticket_benchmarks.ml @@ -83,6 +83,8 @@ module Compare_ticket_hash_benchmark : Benchmark.S = struct let info = "Compare cost for Ticket_hash" + let module_filename = __FILE__ + let compare_model = Model.make ~conv:(fun () -> ()) @@ -139,6 +141,8 @@ module Compare_key_contract_benchmark : Benchmark.S = struct let info = "Compare cost for Contracts" + let module_filename = __FILE__ + let compare_model = Model.make ~conv:(fun () -> ()) @@ -202,6 +206,8 @@ module Has_tickets_type_benchmark : Benchmark.S = struct let info = "Benchmarking type_has_tickets" + let module_filename = __FILE__ + let make_bench_helper rng_state config () = let open Result_syntax in let* ctxt, _ = Lwt_main.run (Execution_context.make ~rng_state) in @@ -265,6 +271,8 @@ module Collect_tickets_benchmark : Benchmark.S = struct let info = "Benchmarking tickets_of_value" + let module_filename = __FILE__ + let make_bench_helper rng_state config () = let open Script_typed_ir in let open Result_syntax in diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/translator_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/translator_benchmarks.ml index f7c6ec25ea51..1f5a79acdbb6 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/translator_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/translator_benchmarks.ml @@ -195,6 +195,8 @@ module Typechecking_data : Benchmark.S = struct let info = "Benchmarking typechecking of data" + let module_filename = __FILE__ + let typechecking_data_benchmark rng_state (node : Protocol.Script_repr.expr) (michelson_type : Script_repr.expr) = Lwt_main.run @@ -267,6 +269,8 @@ module Unparsing_data : Benchmark.S = struct let info = "Benchmarking unparsing of data" + let module_filename = __FILE__ + let unparsing_data_benchmark rng_state (node : Protocol.Script_repr.expr) (michelson_type : Protocol.Script_repr.expr) = Lwt_main.run @@ -346,6 +350,8 @@ module Typechecking_code : Benchmark.S = struct let info = "Benchmarking typechecking of code" + let module_filename = __FILE__ + let typechecking_code_benchmark rng_state (node : Protocol.Script_repr.expr) (stack : Script_repr.expr list) = Lwt_main.run @@ -422,6 +428,8 @@ module Unparsing_code : Benchmark.S = struct let info = "Benchmarking unparsing of code" + let module_filename = __FILE__ + let unparsing_code_benchmark rng_state (node : Protocol.Script_repr.expr) (stack : Script_repr.expr list) = Lwt_main.run @@ -502,6 +510,9 @@ let rec check_printable_ascii v i = let check_printable_benchmark = let open Tezos_shell_benchmarks.Encoding_benchmarks_helpers in + let open Tezos_shell_benchmarks.Encoding_benchmarks_helpers.Make (struct + let file = __FILE__ + end) in linear_shared ~name:"CHECK_PRINTABLE" ~generator:(fun rng_state -> @@ -550,6 +561,8 @@ module Ty_eq : Benchmark.S = struct let info = "Benchmarking equating types" + let module_filename = __FILE__ + let tags = [Tags.translator] let intercept_var = fv (Format.asprintf "%s_const" (Namespace.basename name)) @@ -706,6 +719,8 @@ module Parse_type_benchmark : Benchmark.S = struct let info = "Benchmarking parse_ty" + let module_filename = __FILE__ + let make_bench rng_state config () = ( Lwt_main.run (Execution_context.make ~rng_state) >>? fun (ctxt, _) -> let ctxt = Gas_helpers.set_limit ctxt in @@ -758,6 +773,8 @@ module Unparse_type_benchmark : Benchmark.S = struct let info = "Benchmarking unparse_ty" + let module_filename = __FILE__ + let make_bench rng_state config () = ( Lwt_main.run (Execution_context.make ~rng_state) >>? fun (ctxt, _) -> let ctxt = Gas_helpers.set_limit ctxt in diff --git a/src/proto_016_PtMumbai/lib_benchmarks_proto/tx_rollup_benchmarks.ml b/src/proto_016_PtMumbai/lib_benchmarks_proto/tx_rollup_benchmarks.ml index 8dfaf211d7db..04ce5cba93db 100644 --- a/src/proto_016_PtMumbai/lib_benchmarks_proto/tx_rollup_benchmarks.ml +++ b/src/proto_016_PtMumbai/lib_benchmarks_proto/tx_rollup_benchmarks.ml @@ -34,6 +34,8 @@ module Inbox_add_message : Benchmark.S = struct let info = "Benchmark for Merkle.add_message" + let module_filename = __FILE__ + let tags = ["tx_rollup"; "merkle"; "inbox"; "add_message"] type config = {max_messages : int} @@ -116,6 +118,8 @@ module Commitment_full_compact_bench : Benchmark.S = struct let info = "Benchmark for Tx_rollup_commitment_repr.Full.compact" + let module_filename = __FILE__ + let tags = ["tx_rollup"; "merkle"; "commitment"; "compact"] type config = {max_messages : int} @@ -545,6 +549,8 @@ module Verify_proof_compute_bench : Benchmark.S = struct let info = "Benchmark for Tx_rollup.verify_proof" + let module_filename = __FILE__ + let tags = ["tx_rollup"; "merkle"; "verify"; "proof"] type config = {max_withdrawals : int} -- GitLab