feat(tvix/cli): add toplevel progress span

This gives some better feedback something is going on, gives a (named)
root for all the progress children we're drawing, and also counts the
time we are in eval.

Change-Id: Ibe81dcebf0a2b59bb0680da62e206eb5270f9d3c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11798
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: aspen <root@gws.fyi>
This commit is contained in:
Florian Klink 2024-06-13 10:32:57 +03:00 committed by clbot
parent 7f29cab1cc
commit 29eda2d5b2
4 changed files with 15 additions and 1 deletions

1
tvix/Cargo.lock generated
View file

@ -4203,6 +4203,7 @@ dependencies = [
"tikv-jemallocator",
"tokio",
"tracing",
"tracing-indicatif",
"tvix-build",
"tvix-castore",
"tvix-eval",

View file

@ -13305,6 +13305,10 @@ rec {
name = "tracing";
packageId = "tracing";
}
{
name = "tracing-indicatif";
packageId = "tracing-indicatif";
}
{
name = "tvix-build";
packageId = "tvix-build";

View file

@ -23,6 +23,7 @@ rnix = "0.11.0"
thiserror = "1.0.38"
tokio = "1.28.0"
tracing = "0.1.40"
tracing-indicatif = "0.3.6"
[dependencies.wu-manber]
git = "https://github.com/tvlfyi/wu-manber.git"

View file

@ -4,7 +4,8 @@ use clap::Parser;
use repl::Repl;
use std::rc::Rc;
use std::{fs, path::PathBuf};
use tracing::Level;
use tracing::{instrument, Level, Span};
use tracing_indicatif::span_ext::IndicatifSpanExt;
use tvix_build::buildservice;
use tvix_eval::builtins::impure_builtins;
use tvix_eval::observer::{DisassemblingObserver, TracingObserver};
@ -152,6 +153,7 @@ struct IncompleteInput;
/// Interprets the given code snippet, printing out warnings, errors
/// and the result itself. The return value indicates whether
/// evaluation succeeded.
#[instrument(skip_all, fields(indicatif.pb_show=1))]
fn interpret(
tvix_store_io: Rc<TvixStoreIO>,
code: &str,
@ -160,6 +162,11 @@ fn interpret(
explain: bool,
allow_incomplete: AllowIncomplete,
) -> Result<bool, IncompleteInput> {
let span = Span::current();
span.pb_start();
span.pb_set_style(&tvix_tracing::PB_SPINNER_STYLE);
span.pb_set_message("Setting up evaluator…");
let mut eval = tvix_eval::Evaluation::new(
Box::new(TvixIO::new(tvix_store_io.clone() as Rc<dyn EvalIO>)) as Box<dyn EvalIO>,
true,
@ -187,6 +194,7 @@ fn interpret(
eval.runtime_observer = Some(&mut runtime_observer);
}
span.pb_set_message("Evaluating…");
eval.evaluate(code, path)
};