Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm

slingshot: configurable cache sizes

Changed files
+16 -3
slingshot
+4 -2
slingshot/src/firehose_cache.rs
··· 4 4 5 5 pub async fn firehose_cache( 6 6 cache_dir: impl AsRef<Path>, 7 + memory_mb: usize, 8 + disk_gb: usize, 7 9 ) -> Result<HybridCache<String, CachedRecord>, String> { 8 10 let cache = HybridCacheBuilder::new() 9 11 .with_name("firehose") 10 - .memory(64 * 2_usize.pow(20)) 12 + .memory(memory_mb * 2_usize.pow(20)) 11 13 .with_weighter(|k: &String, v| k.len() + std::mem::size_of_val(v)) 12 14 .storage(Engine::large()) 13 15 .with_device_options( 14 16 DirectFsDeviceOptions::new(cache_dir) 15 - .with_capacity(2_usize.pow(30)) // TODO: configurable (1GB to have something) 17 + .with_capacity(disk_gb * 2_usize.pow(30)) 16 18 .with_file_size(16 * 2_usize.pow(20)), // note: this does limit the max cached item size, warning jumbo records 17 19 ) 18 20 .build()
+12 -1
slingshot/src/main.rs
··· 25 25 /// where to keep disk caches 26 26 #[arg(long)] 27 27 cache_dir: PathBuf, 28 + /// memory cache size in MB 29 + #[arg(long, default_value_t = 64)] 30 + cache_memory_mb: usize, 31 + /// disk cache size in GB 32 + #[arg(long, default_value_t = 1)] 33 + cache_disk_gb: usize, 28 34 /// the domain pointing to this server 29 35 /// 30 36 /// if present: ··· 83 89 log::info!("cache dir ready at at {cache_dir:?}."); 84 90 85 91 log::info!("setting up firehose cache..."); 86 - let cache = firehose_cache(cache_dir.join("./firehose")).await?; 92 + let cache = firehose_cache( 93 + cache_dir.join("./firehose"), 94 + args.cache_memory_mb, 95 + args.cache_disk_gb, 96 + ) 97 + .await?; 87 98 log::info!("firehose cache ready."); 88 99 89 100 let mut tasks: tokio::task::JoinSet<Result<(), MainTaskError>> = tokio::task::JoinSet::new();