From 6f9e25943f3e2f83d191cadcc76a278073626fe8 Mon Sep 17 00:00:00 2001 From: Aspen Smith Date: Tue, 30 Jan 2024 13:53:20 -0500 Subject: feat(tvix/eval/observer): Allow capturing timing of events Add a new --trace-runtime-timing flag (probably a better bikeshed for this) that enables capturing the time, relative to the last event, of each event recorded with the tracing observer. This probably isn't *super* useful yet, but I'd like to start here in adding new profiling tools to the VM, specifically based on the runtime observer Change-Id: Id7f12077291c39bf3eef42ab6744bfba53687a65 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10713 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/cli/src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tvix/cli') diff --git a/tvix/cli/src/main.rs b/tvix/cli/src/main.rs index 7683ad4c59..72f21ab5b1 100644 --- a/tvix/cli/src/main.rs +++ b/tvix/cli/src/main.rs @@ -31,6 +31,11 @@ struct Args { #[clap(long, env = "TVIX_TRACE_RUNTIME")] trace_runtime: bool, + /// Capture the time (relative to the start time of evaluation) of all events traced with + /// `--trace-runtime` + #[clap(long, env = "TVIX_TRACE_RUNTIME_TIMING", requires("trace_runtime"))] + trace_runtime_timing: bool, + /// Only compile, but do not execute code. This will make Tvix act /// sort of like a linter. #[clap(long)] @@ -113,6 +118,9 @@ fn interpret(code: &str, path: Option, args: &Args, explain: bool) -> b let mut runtime_observer = TracingObserver::new(std::io::stderr()); if args.trace_runtime { + if args.trace_runtime_timing { + runtime_observer.enable_timing() + } eval.runtime_observer = Some(&mut runtime_observer); } -- cgit 1.4.1