fix(tvix/store/pathinfo): use gRPC NarCalculationService

If the PathInfoService is using gRPC, expose it via the
nar_calculation_service() method in the PathInfoService.

Also pass nar_calculation_service through in tha blanket impl.

This now causes a `tvix-store import` using the default config to not
fall back to `SimpleRenderer`, which will calculate the NAR hash and
size by downloading the uploaded blobs (and blobs it didn't need to
upload) locally, making such imports faster.

Change-Id: If2c3fe6584e9093cba322d2360f355a3923904ae
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12658
Tested-by: BuildkiteCI
Reviewed-by: edef <edef@edef.eu>
Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
Florian Klink 2024-10-15 17:10:09 +03:00 committed by clbot
parent 98df0e4e34
commit bd6894d265
2 changed files with 14 additions and 1 deletions

View file

@ -8,7 +8,7 @@ use futures::stream::BoxStream;
use nix_compat::nixbase32;
use std::sync::Arc;
use tonic::{async_trait, Code};
use tracing::{instrument, Span};
use tracing::{instrument, warn, Span};
use tracing_indicatif::span_ext::IndicatifSpanExt;
use tvix_castore::composition::{CompositionContext, ServiceBuilder};
use tvix_castore::Error;
@ -95,6 +95,13 @@ where
Box::pin(stream)
}
#[instrument(level = "trace", skip_all)]
fn nar_calculation_service(&self) -> Option<Box<dyn NarCalculationService>> {
Some(Box::new(GRPCPathInfoService {
grpc_client: self.grpc_client.clone(),
}) as Box<dyn NarCalculationService>)
}
}
#[async_trait]

View file

@ -62,6 +62,8 @@ pub trait PathInfoService: Send + Sync {
/// [async_trait] generates, but for streams instead of futures.
fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>>;
/// Returns a (more) suitable NarCalculationService.
/// This can be used to offload NAR calculation to the remote side.
fn nar_calculation_service(&self) -> Option<Box<dyn NarCalculationService>> {
None
}
@ -83,6 +85,10 @@ where
fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>> {
self.as_ref().list()
}
fn nar_calculation_service(&self) -> Option<Box<dyn NarCalculationService>> {
self.as_ref().nar_calculation_service()
}
}
/// Registers the builtin PathInfoService implementations with the registry