From cfab953094c6da5a919ea968f2bd7753035005c7 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 16 Jun 2024 22:40:01 +0300 Subject: feat(tvix/store): display progress for NAR calculation This is currently still taking a noticeable amount of time, so make sure we show it is happening. Change-Id: I13d18785fbf41ae4479e1ea58d61ece1d7485719 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11847 Reviewed-by: Simon Hauser Autosubmit: flokli Tested-by: BuildkiteCI --- tvix/store/src/nar/renderer.rs | 7 +++++++ tvix/store/src/pathinfoservice/grpc.rs | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'tvix') diff --git a/tvix/store/src/nar/renderer.rs b/tvix/store/src/nar/renderer.rs index efd67671db70..e3cb54dd229f 100644 --- a/tvix/store/src/nar/renderer.rs +++ b/tvix/store/src/nar/renderer.rs @@ -6,6 +6,8 @@ use nix_compat::nar::writer::r#async as nar_writer; use sha2::{Digest, Sha256}; use tokio::io::{self, AsyncWrite, BufReader}; use tonic::async_trait; +use tracing::{instrument, Span}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use tvix_castore::{ blobservice::BlobService, directoryservice::DirectoryService, @@ -48,6 +50,7 @@ where /// Invoke [write_nar], and return the size and sha256 digest of the produced /// NAR output. +#[instrument(skip_all, fields(indicatif.pb_show=1))] pub async fn calculate_size_and_sha256( root_node: &castorepb::node::Node, blob_service: BS, @@ -60,6 +63,10 @@ where let mut h = Sha256::new(); let mut cw = CountWrite::from(&mut h); + let span = Span::current(); + span.pb_set_message("Calculating NAR"); + span.pb_start(); + write_nar( // The hasher doesn't speak async. It doesn't // actually do any I/O, so it's fine to wrap. diff --git a/tvix/store/src/pathinfoservice/grpc.rs b/tvix/store/src/pathinfoservice/grpc.rs index f6a356cf180a..63656609354d 100644 --- a/tvix/store/src/pathinfoservice/grpc.rs +++ b/tvix/store/src/pathinfoservice/grpc.rs @@ -7,7 +7,8 @@ use async_stream::try_stream; use futures::stream::BoxStream; use nix_compat::nixbase32; use tonic::{async_trait, transport::Channel, Code}; -use tracing::instrument; +use tracing::{instrument, Span}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use tvix_castore::{proto as castorepb, Error}; /// Connects to a (remote) tvix-store PathInfoService over gRPC. @@ -107,11 +108,15 @@ impl PathInfoService for GRPCPathInfoService { #[async_trait] impl NarCalculationService for GRPCPathInfoService { - #[instrument(level = "trace", skip_all, fields(root_node = ?root_node))] + #[instrument(level = "trace", skip_all, fields(root_node = ?root_node, indicatif.pb_show=1))] async fn calculate_nar( &self, root_node: &castorepb::node::Node, ) -> Result<(u64, [u8; 32]), Error> { + let span = Span::current(); + span.pb_set_message("Waiting for NAR calculation"); + span.pb_start(); + let path_info = self .grpc_client .clone() -- cgit 1.4.1