Skip to content

Commit

Permalink
Add thread execution timing metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
nholland94 committed Mar 2, 2022
1 parent a6f1dc4 commit ee10edf
Show file tree
Hide file tree
Showing 31 changed files with 1,865 additions and 1,525 deletions.
4 changes: 2 additions & 2 deletions buildkite/src/Constants/ContainerImages.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

{
toolchainBase = "codaprotocol/ci-toolchain-base:v3",
minaToolchainStretch = "gcr.io/o1labs-192920/mina-toolchain@sha256:7ef5827fa0854a0bcfdee69dcc0c2c7aef86e1662c630e71f07c1f9162e757fa",
minaToolchainBuster = "gcr.io/o1labs-192920/mina-toolchain@sha256:71477097441872b96cce1ec6468c6aa3250bbc7159ecbcc9a716f5b54e16ec05",
minaToolchainStretch = "gcr.io/o1labs-192920/mina-toolchain@sha256:c108ac39dbd7a790a54fca94f70b8b666b52d2ab44f95a625e21e5b5ffffa4e3",
minaToolchainBuster = "gcr.io/o1labs-192920/mina-toolchain@sha256:8a0e8cc15d6a6442a747f414c231bb08f4855c6ef77479cfa5e974c3e6da70ca",
delegationBackendToolchain = "gcr.io/o1labs-192920/delegation-backend-production@sha256:8ca5880845514ef56a36bf766a0f9de96e6200d61b51f80d9f684a0ec9c031f4",
elixirToolchain = "elixir:1.10-alpine",
rustToolchain = "codaprotocol/coda:toolchain-rust-e855336d087a679f76f2dd2bbdc3fdfea9303be3",
Expand Down
2 changes: 1 addition & 1 deletion scripts/pin-external-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# update and pin packages, used by CI

PACKAGES="ocaml-sodium capnp-ocaml rpc_parallel ocaml-extlib async_kernel coda_base58 graphql_ppx ppx_deriving_yojson"
PACKAGES="ocaml-sodium capnp-ocaml rpc_parallel ocaml-extlib async_kernel async_unix coda_base58 graphql_ppx ppx_deriving_yojson"

git submodule sync && git submodule update --init --recursive

Expand Down
153 changes: 79 additions & 74 deletions src/app/cli/src/init/coda_run.ml
Original file line number Diff line number Diff line change
Expand Up @@ -501,86 +501,91 @@ let setup_local_server ?(client_trustlist = []) ?rest_server_port
server_description port)
in
Option.iter rest_server_port ~f:(fun rest_server_port ->
trace_task "full GraphQL server" (fun () ->
create_graphql_server
~bind_to_address:
Tcp.Bind_to_address.(
if insecure_rest_server then All_addresses else Localhost)
~schema:Mina_graphql.schema ~server_description:"GraphQL server"
rest_server_port)) ;
O1trace.time_execution "serving_graphql" (fun () ->
trace_task "full GraphQL server" (fun () ->
create_graphql_server
~bind_to_address:
Tcp.Bind_to_address.(
if insecure_rest_server then All_addresses else Localhost)
~schema:Mina_graphql.schema ~server_description:"GraphQL server"
rest_server_port))) ;
(*Second graphql server with limited queries exopsed*)
Option.iter limited_graphql_port ~f:(fun rest_server_port ->
trace_task "limited GraphQL server" (fun () ->
create_graphql_server
~bind_to_address:
Tcp.Bind_to_address.(
if open_limited_graphql_port then All_addresses else Localhost)
~schema:Mina_graphql.schema_limited
~server_description:"GraphQL server with limited queries"
rest_server_port)) ;
O1trace.time_execution "serving_graphql" (fun () ->
trace_task "limited GraphQL server" (fun () ->
create_graphql_server
~bind_to_address:
Tcp.Bind_to_address.(
if open_limited_graphql_port then All_addresses
else Localhost)
~schema:Mina_graphql.schema_limited
~server_description:"GraphQL server with limited queries"
rest_server_port))) ;
let where_to_listen =
Tcp.Where_to_listen.bind_to All_addresses
(On_port (Mina_lib.client_port coda))
in
trace_task "client RPC server" (fun () ->
Deferred.ignore_m
(Tcp.Server.create
~on_handler_error:
(`Call
(fun _net exn ->
[%log error]
"Exception while handling TCP server request: $error"
~metadata:
[ ("error", `String (Exn.to_string_mach exn))
; ("context", `String "rpc_tcp_server")
]))
where_to_listen
(fun address reader writer ->
let address = Socket.Address.Inet.addr address in
if
not
(Set.exists !client_trustlist ~f:(fun cidr ->
Unix.Cidr.does_match cidr address))
then (
[%log error]
!"Rejecting client connection from $address, it is not \
present in the trustlist."
~metadata:
[ ("$address", `String (Unix.Inet_addr.to_string address)) ] ;
Deferred.unit )
else
Rpc.Connection.server_with_close
~handshake_timeout:
(Time.Span.of_sec
Mina_compile_config.rpc_handshake_timeout_sec)
~heartbeat_config:
(Rpc.Connection.Heartbeat_config.create
~timeout:
(Time_ns.Span.of_sec
Mina_compile_config.rpc_heartbeat_timeout_sec)
~send_every:
(Time_ns.Span.of_sec
Mina_compile_config.rpc_heartbeat_send_every_sec)
())
reader writer
~implementations:
(Rpc.Implementations.create_exn
~implementations:(client_impls @ snark_worker_impls)
~on_unknown_rpc:`Raise)
~connection_state:(fun _ -> ())
~on_handshake_error:
(`Call
(fun exn ->
[%log warn]
"Handshake error while handling RPC server request \
from $address"
~metadata:
[ ("error", `String (Exn.to_string_mach exn))
; ("context", `String "rpc_server")
; ( "address"
, `String (Unix.Inet_addr.to_string address) )
] ;
Deferred.unit)))))
O1trace.time_execution "serving_client_rpcs" (fun () ->
trace_task "client RPC server" (fun () ->
Deferred.ignore_m
(Tcp.Server.create
~on_handler_error:
(`Call
(fun _net exn ->
[%log error]
"Exception while handling TCP server request: $error"
~metadata:
[ ("error", `String (Exn.to_string_mach exn))
; ("context", `String "rpc_tcp_server")
]))
where_to_listen
(fun address reader writer ->
let address = Socket.Address.Inet.addr address in
if
not
(Set.exists !client_trustlist ~f:(fun cidr ->
Unix.Cidr.does_match cidr address))
then (
[%log error]
!"Rejecting client connection from $address, it is not \
present in the trustlist."
~metadata:
[ ("$address", `String (Unix.Inet_addr.to_string address))
] ;
Deferred.unit )
else
Rpc.Connection.server_with_close
~handshake_timeout:
(Time.Span.of_sec
Mina_compile_config.rpc_handshake_timeout_sec)
~heartbeat_config:
(Rpc.Connection.Heartbeat_config.create
~timeout:
(Time_ns.Span.of_sec
Mina_compile_config.rpc_heartbeat_timeout_sec)
~send_every:
(Time_ns.Span.of_sec
Mina_compile_config.rpc_heartbeat_send_every_sec)
())
reader writer
~implementations:
(Rpc.Implementations.create_exn
~implementations:(client_impls @ snark_worker_impls)
~on_unknown_rpc:`Raise)
~connection_state:(fun _ -> ())
~on_handshake_error:
(`Call
(fun exn ->
[%log warn]
"Handshake error while handling RPC server \
request from $address"
~metadata:
[ ("error", `String (Exn.to_string_mach exn))
; ("context", `String "rpc_server")
; ( "address"
, `String (Unix.Inet_addr.to_string address) )
] ;
Deferred.unit))))))

let coda_crash_message ~log_issue ~action ~error =
let followup =
Expand Down
2 changes: 1 addition & 1 deletion src/app/cli/src/init/coda_tracing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open Async

(** [start dir] starts writing the trace output to [dir ^/ "trace" ^/(current_pid ^ ".trace")]. *)
let start dir =
O1trace_webkit_event.forget_tid (fun () ->
O1trace.forget_tid (fun () ->
let trace_dir = dir ^/ "trace" in
let%bind () = File_system.create_dir trace_dir in
Writer.open_file ~append:true
Expand Down
4 changes: 2 additions & 2 deletions src/app/libp2p_helper/src/libp2p_helper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func main() {
Format: logging.JSONOutput,
Stderr: true,
Stdout: false,
Level: logging.LevelDebug,
Level: logging.LevelWarn,
File: "",
})
helperLog := logging.Logger("helper top-level JSON handling")
Expand Down Expand Up @@ -126,7 +126,7 @@ func main() {
_ = logging.SetLogLevel("autonat", "debug")
_ = logging.SetLogLevel("discovery", "debug")
_ = logging.SetLogLevel("routing/record", "debug")
_ = logging.SetLogLevel("pubsub", "debug") // Spammy about blacklisted peers, maybe should be info?
_ = logging.SetLogLevel("pubsub", "info") // Spammy about blacklisted peers, maybe should be info?
_ = logging.SetLogLevel("badger", "debug")
_ = logging.SetLogLevel("relay", "info") // Log relayed byte counts spammily
_ = logging.SetLogLevel("routedhost", "debug")
Expand Down
2 changes: 1 addition & 1 deletion src/external/async_kernel
10 changes: 7 additions & 3 deletions src/lib/child_processes/child_processes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,20 @@ let start_custom :
in
let terminated_ivar = Ivar.create () in
let stdout_pipe =
reader_to_strict_pipe (Process.stdout process) (name ^ "-stdout") stdout
O1trace.time_execution "in_libp2p_child_processes_stdout" (fun () ->
reader_to_strict_pipe (Process.stdout process) (name ^ "-stdout") stdout)
in
let stderr_pipe =
reader_to_strict_pipe (Process.stderr process) (name ^ "-stderr") stderr
O1trace.time_execution "in_libp2p_child_processes_stderr" (fun () ->
reader_to_strict_pipe (Process.stderr process) (name ^ "-stderr") stderr)
in
let t =
{ process
; stdout_pipe
; stderr_pipe
; stdin = Process.stdin process
; stdin =
O1trace.time_execution "in_libp2p_child_processes_stdin" (fun () ->
Process.stdin process)
; terminated_ivar
; killing = false
; termination_response = termination
Expand Down
Loading

0 comments on commit ee10edf

Please sign in to comment.