-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12874 from openmina/feature/prover-internal-tracing
Internal tracing for prover and verifier (internal tracing PR 2 of 3)
- Loading branch information
Showing
44 changed files
with
533 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(library | ||
(name internal_tracing_context_call) | ||
(public_name internal_tracing.context_call) | ||
(library_flags -linkall) | ||
(inline_tests) | ||
(libraries | ||
;; opam libraries | ||
base.base_internalhash_types | ||
core_kernel | ||
sexplib0 | ||
async_kernel) | ||
(preprocess | ||
(pps ppx_jane ppx_mina ppx_version ppx_deriving_yojson)) | ||
(instrumentation | ||
(backend bisect_ppx)) | ||
(synopsis "Internal tracing context call ID helper")) |
13 changes: 13 additions & 0 deletions
13
src/lib/internal_tracing/context_call/internal_tracing_context_call.ml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
open Core_kernel | ||
|
||
let last_call_id = ref 0 | ||
|
||
let key = Univ_map.Key.create ~name:"call_id" sexp_of_int | ||
|
||
let with_call_id f = | ||
incr last_call_id ; | ||
Async_kernel.Async_kernel_scheduler.with_local key (Some !last_call_id) ~f | ||
|
||
let get_opt () = Async_kernel.Async_kernel_scheduler.find_local key | ||
|
||
let get () = Option.value (get_opt ()) ~default:0 |
12 changes: 12 additions & 0 deletions
12
src/lib/internal_tracing/context_call/internal_tracing_context_call.mli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(** Helper module for setting the execution context call ID. | ||
Useful for being able to detect context switches when | ||
there are concurrent verifier/prover calls. *) | ||
|
||
(** [with_call_id f] runs [f] in a context in which | ||
an unique identifier has been associated to the current call. *) | ||
val with_call_id : (unit -> 'a) -> 'a | ||
|
||
(** [get ()] returns current call ID bound to the current context (if any), | ||
or 0 *) | ||
val get : unit -> int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(library | ||
(name internal_tracing_context_logger) | ||
(public_name internal_tracing.context_logger) | ||
(library_flags -linkall) | ||
(inline_tests) | ||
(libraries | ||
;; opam libraries | ||
base.base_internalhash_types | ||
core_kernel | ||
sexplib0 | ||
async_kernel | ||
;; local libraries | ||
logger) | ||
(preprocess | ||
(pps ppx_jane ppx_mina ppx_version ppx_deriving_yojson)) | ||
(instrumentation | ||
(backend bisect_ppx)) | ||
(synopsis "Internal tracing context logger helper")) |
10 changes: 10 additions & 0 deletions
10
src/lib/internal_tracing/context_logger/internal_tracing_context_logger.ml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
open Core_kernel | ||
|
||
let key = Univ_map.Key.create ~name:"logger" sexp_of_opaque | ||
|
||
let with_logger logger f = | ||
Async_kernel.Async_kernel_scheduler.with_local key logger ~f | ||
|
||
let get_opt () = Async_kernel.Async_kernel_scheduler.find_local key | ||
|
||
let get () = Option.value (get_opt ()) ~default:(Logger.null ()) |
12 changes: 12 additions & 0 deletions
12
src/lib/internal_tracing/context_logger/internal_tracing_context_logger.mli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(** Helper module for setting the execution context logger. | ||
Useful for very deep call-stack where adding a logger parameter | ||
to all the functions in the call-chain is too cumbersome. *) | ||
|
||
(** [with_logger logger f] runs [f] in a context in which | ||
a call to [get] will return [logger]. *) | ||
val with_logger : Logger.t option -> (unit -> 'a) -> 'a | ||
|
||
(** [get ()] returns the logger bound to the current context (if any), | ||
or the null logger otherwise. *) | ||
val get : unit -> Logger.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.