feat(tvix/glue/tvix_store_io): show progress info

In `store_path_to_node`, in case we need to build or fetch something,
render a progress bar, using the spinner for now.
We can upgrade this to a progress *bar* later.

Change-Id: I4a7cf5ef8f639076f176af9b39d276be3f37c8ff
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11793
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: Connor Brewster <cbrewster@hey.com>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2024-06-13 00:17:18 +03:00 committed by clbot
parent 842d6816bf
commit ddd88a589b
4 changed files with 20 additions and 5 deletions

2
tvix/Cargo.lock generated
View file

@ -4292,10 +4292,12 @@ dependencies = [
"tokio-tar", "tokio-tar",
"tokio-util", "tokio-util",
"tracing", "tracing",
"tracing-indicatif",
"tvix-build", "tvix-build",
"tvix-castore", "tvix-castore",
"tvix-eval", "tvix-eval",
"tvix-store", "tvix-store",
"tvix-tracing",
"url", "url",
"walkdir", "walkdir",
"wu-manber", "wu-manber",

View file

@ -13641,6 +13641,10 @@ rec {
name = "tracing"; name = "tracing";
packageId = "tracing"; packageId = "tracing";
} }
{
name = "tracing-indicatif";
packageId = "tracing-indicatif";
}
{ {
name = "tvix-build"; name = "tvix-build";
packageId = "tvix-build"; packageId = "tvix-build";
@ -13659,6 +13663,10 @@ rec {
packageId = "tvix-store"; packageId = "tvix-store";
usesDefaultFeatures = false; usesDefaultFeatures = false;
} }
{
name = "tvix-tracing";
packageId = "tvix-tracing";
}
{ {
name = "url"; name = "url";
packageId = "url"; packageId = "url";

View file

@ -17,7 +17,9 @@ tvix-build = { path = "../build", default-features = false, features = []}
tvix-eval = { path = "../eval" } tvix-eval = { path = "../eval" }
tvix-castore = { path = "../castore" } tvix-castore = { path = "../castore" }
tvix-store = { path = "../store", default-features = false, features = []} tvix-store = { path = "../store", default-features = false, features = []}
tvix-tracing = { path = "../tracing" }
tracing = "0.1.37" tracing = "0.1.37"
tracing-indicatif = "0.3.6"
tokio = "1.28.0" tokio = "1.28.0"
tokio-tar = "0.3.1" tokio-tar = "0.3.1"
tokio-util = { version = "0.7.9", features = ["io", "io-util", "compat"] } tokio-util = { version = "0.7.9", features = ["io", "io-util", "compat"] }

View file

@ -13,7 +13,8 @@ use std::{
sync::Arc, sync::Arc,
}; };
use tokio_util::io::SyncIoBridge; use tokio_util::io::SyncIoBridge;
use tracing::{error, info, instrument, warn, Level}; use tracing::{error, instrument, warn, Level, Span};
use tracing_indicatif::span_ext::IndicatifSpanExt;
use tvix_build::buildservice::BuildService; use tvix_build::buildservice::BuildService;
use tvix_castore::proto::node::Node; use tvix_castore::proto::node::Node;
use tvix_eval::{EvalIO, FileType, StdIO}; use tvix_eval::{EvalIO, FileType, StdIO};
@ -105,7 +106,7 @@ impl TvixStoreIO {
/// ///
/// In case there is no PathInfo yet, this means we need to build it /// In case there is no PathInfo yet, this means we need to build it
/// (which currently is stubbed out still). /// (which currently is stubbed out still).
#[instrument(skip(self, store_path), fields(store_path=%store_path), ret(level = Level::TRACE), err)] #[instrument(skip(self, store_path), fields(store_path=%store_path, indicatif.pb_show=1), ret(level = Level::TRACE), err)]
async fn store_path_to_node( async fn store_path_to_node(
&self, &self,
store_path: &StorePath, store_path: &StorePath,
@ -134,6 +135,9 @@ impl TvixStoreIO {
// it for things like <nixpkgs> pointing to a store path. // it for things like <nixpkgs> pointing to a store path.
// In the future, these things will (need to) have PathInfo. // In the future, these things will (need to) have PathInfo.
None => { None => {
let span = Span::current();
span.pb_start();
span.pb_set_style(&tvix_tracing::PB_SPINNER_STYLE);
// The store path doesn't exist yet, so we need to fetch or build it. // The store path doesn't exist yet, so we need to fetch or build it.
// We check for fetches first, as we might have both native // We check for fetches first, as we might have both native
// fetchers and FODs in KnownPaths, and prefer the former. // fetchers and FODs in KnownPaths, and prefer the former.
@ -146,7 +150,7 @@ impl TvixStoreIO {
match maybe_fetch { match maybe_fetch {
Some((name, fetch)) => { Some((name, fetch)) => {
info!(?fetch, "triggering lazy fetch"); span.pb_set_message(&format!("⏳Fetching {}", &store_path));
let (sp, root_node) = self let (sp, root_node) = self
.fetcher .fetcher
.ingest_and_persist(&name, fetch) .ingest_and_persist(&name, fetch)
@ -179,8 +183,7 @@ impl TvixStoreIO {
} }
} }
}; };
span.pb_set_message(&format!("🔨building {}", &store_path));
warn!("triggering build");
// derivation_to_build_request needs castore nodes for all inputs. // derivation_to_build_request needs castore nodes for all inputs.
// Provide them, which means, here is where we recursively build // Provide them, which means, here is where we recursively build