about summary refs log tree commit diff
path: root/tvix/cli/src
diff options
context:
space:
mode:
authorAspen Smith <root@gws.fyi>2024-01-30T18·53-0500
committeraspen <root@gws.fyi>2024-01-31T04·41+0000
commit6f9e25943f3e2f83d191cadcc76a278073626fe8 (patch)
tree8bd57fa89dbdbb647ef619be8d4478eb0652682f /tvix/cli/src
parent3c92a5abf8489c753a45ac9f11d841c421e36058 (diff)
feat(tvix/eval/observer): Allow capturing timing of events r/7459
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 <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/cli/src')
-rw-r--r--tvix/cli/src/main.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/tvix/cli/src/main.rs b/tvix/cli/src/main.rs
index 7683ad4c59f8..72f21ab5b185 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<PathBuf>, 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);
         }