diff options
author | Florian Klink <flokli@flokli.de> | 2024-11-09T16·00+0000 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-11-12T00·27+0000 |
commit | 0c5ad949148b178c13b0cb8f2ed3fe274e9cf522 (patch) | |
tree | 105d3108a415dca2c92041debde114c0d0a3c5ca /tvix/nar-bridge/src/lib.rs | |
parent | 85de9b8dabfcbe169e3c5f6d33c1f2b60d56176d (diff) |
feat(tvix/nar-bridge): make root_nodes_cache_capacity configurable r/8905
Allow this to be overridden via the CLI, also getting rid of the unsafe because this doesn't need to be const anymore. Change-Id: I5e51b52e42522a21f59ef69628b464477c0764d1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12753 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
Diffstat (limited to 'tvix/nar-bridge/src/lib.rs')
-rw-r--r-- | tvix/nar-bridge/src/lib.rs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/tvix/nar-bridge/src/lib.rs b/tvix/nar-bridge/src/lib.rs index 9246a334c7f6..db926e8cede4 100644 --- a/tvix/nar-bridge/src/lib.rs +++ b/tvix/nar-bridge/src/lib.rs @@ -15,12 +15,6 @@ use tvix_store::pathinfoservice::PathInfoService; mod nar; mod narinfo; -/// The capacity of the lookup table from NarHash to [Node]. -/// Should be bigger than the number of concurrent NAR upload. -/// Cannot be [NonZeroUsize] here due to rust-analyzer going bananas. -/// SAFETY: 1000 != 0 -const ROOT_NODES_CACHE_CAPACITY: usize = 1000; - #[derive(Clone)] pub struct AppState { blob_service: Arc<dyn BlobService>, @@ -37,15 +31,13 @@ impl AppState { blob_service: Arc<dyn BlobService>, directory_service: Arc<dyn DirectoryService>, path_info_service: Arc<dyn PathInfoService>, + root_nodes_cache_capacity: NonZeroUsize, ) -> Self { Self { blob_service, directory_service, path_info_service, - root_nodes: Arc::new(RwLock::new(LruCache::new({ - // SAFETY: 1000 != 0 - unsafe { NonZeroUsize::new_unchecked(ROOT_NODES_CACHE_CAPACITY) } - }))), + root_nodes: Arc::new(RwLock::new(LruCache::new(root_nodes_cache_capacity))), } } } |