about summary refs log tree commit diff
path: root/tvix/nar-bridge/src/bin/nar-bridge.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/nar-bridge/src/bin/nar-bridge.rs')
-rw-r--r--tvix/nar-bridge/src/bin/nar-bridge.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/tvix/nar-bridge/src/bin/nar-bridge.rs b/tvix/nar-bridge/src/bin/nar-bridge.rs
index 48eba0ac44ac..d9fce9dff322 100644
--- a/tvix/nar-bridge/src/bin/nar-bridge.rs
+++ b/tvix/nar-bridge/src/bin/nar-bridge.rs
@@ -1,6 +1,7 @@
 use clap::Parser;
 use mimalloc::MiMalloc;
 use nar_bridge::AppState;
+use std::num::NonZeroUsize;
 use tower::ServiceBuilder;
 use tower_http::trace::{DefaultMakeSpan, TraceLayer};
 use tracing::info;
@@ -25,6 +26,11 @@ struct Cli {
     #[clap(flatten)]
     listen_args: tokio_listener::ListenerAddressLFlag,
 
+    /// The capacity of the lookup table from NarHash to [Node].
+    /// Should be bigger than the number of concurrent NAR uploads.
+    #[arg(long, env, default_value_t = NonZeroUsize::new(1000).unwrap())]
+    root_nodes_cache_capacity: NonZeroUsize,
+
     #[cfg(feature = "otlp")]
     /// Whether to configure OTLP. Set --otlp=false to disable.
     #[arg(long, default_missing_value = "true", default_value = "true", num_args(0..=1), require_equals(true), action(clap::ArgAction::Set))]
@@ -51,7 +57,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
     let (blob_service, directory_service, path_info_service, _nar_calculation_service) =
         tvix_store::utils::construct_services(cli.service_addrs).await?;
 
-    let state = AppState::new(blob_service, directory_service, path_info_service);
+    let state = AppState::new(
+        blob_service,
+        directory_service,
+        path_info_service,
+        cli.root_nodes_cache_capacity,
+    );
 
     let app = nar_bridge::gen_router(cli.priority)
         .layer(