···1515 .with_device_options(
1616 DirectFsDeviceOptions::new(cache_dir)
1717 .with_capacity(disk_gb * 2_usize.pow(30))
1818- .with_file_size(16 * 2_usize.pow(20)), // note: this does limit the max cached item size, warning jumbo records
1818+ .with_file_size(16 * 2_usize.pow(20)), // note: this does limit the max cached item size (records should be max 1mb cbor, bit bigger json)
1919 )
2020 .build()
2121 .await
+8-4
slingshot/src/identity.rs
···161161}
162162163163impl Identity {
164164- pub async fn new(cache_dir: impl AsRef<Path>) -> Result<Self, IdentityError> {
164164+ pub async fn new(
165165+ cache_dir: impl AsRef<Path>,
166166+ memory_mb: usize,
167167+ disk_gb: usize,
168168+ ) -> Result<Self, IdentityError> {
165169 let http_client = Arc::new(DefaultHttpClient::default());
166170 let handle_resolver = AtprotoHandleResolver::new(AtprotoHandleResolverConfig {
167171 dns_txt_resolver: HickoryDnsTxtResolver::new().unwrap(),
···174178175179 let cache = HybridCacheBuilder::new()
176180 .with_name("identity")
177177- .memory(16 * 2_usize.pow(20))
181181+ .memory(memory_mb * 2_usize.pow(20))
178182 .with_weighter(|k, v| std::mem::size_of_val(k) + std::mem::size_of_val(v))
179183 .storage(Engine::small())
180184 .with_device_options(
181185 DirectFsDeviceOptions::new(cache_dir)
182182- .with_capacity(2_usize.pow(30)) // TODO: configurable (1GB to have something)
183183- .with_file_size(2_usize.pow(20)), // note: this does limit the max cached item size, warning jumbo records
186186+ .with_capacity(disk_gb * 2_usize.pow(30)) // TODO: configurable (1GB to have something)
187187+ .with_file_size(2_usize.pow(20)), // note: this does limit the max cached item size!
184188 )
185189 .build()
186190 .await?;
+24-11
slingshot/src/main.rs
···3131 #[arg(long, env = "SLINGSHOT_BIND")]
3232 #[clap(default_value = "0.0.0.0:8080")]
3333 bind: std::net::SocketAddr,
3434- /// memory cache size in megabytes
3535- #[arg(long, env = "SLINGSHOT_CACHE_MEMORY_MB")]
3434+ /// memory cache size in megabytes for records
3535+ #[arg(long, env = "SLINGSHOT_RECORD_CACHE_MEMORY_MB")]
3636 #[clap(default_value_t = 64)]
3737- cache_memory_mb: usize,
3838- /// disk cache size in gigabytes
3939- #[arg(long, env = "SLINGHSOT_CACHE_DISK_DB")]
3737+ record_cache_memory_mb: usize,
3838+ /// disk cache size in gigabytes for records
3939+ #[arg(long, env = "SLINGSHOT_RECORD_CACHE_DISK_DB")]
4040 #[clap(default_value_t = 1)]
4141- cache_disk_gb: usize,
4141+ record_cache_disk_gb: usize,
4242+ /// memory cache size in megabytes for identities
4343+ #[arg(long, env = "SLINGSHOT_IDENTITY_CACHE_MEMORY_MB")]
4444+ #[clap(default_value_t = 64)]
4545+ identity_cache_memory_mb: usize,
4646+ /// disk cache size in gigabytes for identities
4747+ #[arg(long, env = "SLINGSHOT_IDENTITY_CACHE_DISK_DB")]
4848+ #[clap(default_value_t = 1)]
4949+ identity_cache_disk_gb: usize,
4250 /// the domain pointing to this server
4351 ///
4452 /// if present:
···118126 log::info!("setting up firehose cache...");
119127 let cache = firehose_cache(
120128 cache_dir.join("./firehose"),
121121- args.cache_memory_mb,
122122- args.cache_disk_gb,
129129+ args.record_cache_memory_mb,
130130+ args.record_cache_disk_gb,
123131 )
124132 .await?;
125133 log::info!("firehose cache ready.");
···127135 let mut tasks: tokio::task::JoinSet<Result<(), MainTaskError>> = tokio::task::JoinSet::new();
128136129137 log::info!("starting identity service...");
130130- let identity = Identity::new(cache_dir.join("./identity"))
131131- .await
132132- .map_err(|e| format!("identity setup failed: {e:?}"))?;
138138+ let identity = Identity::new(
139139+ cache_dir.join("./identity"),
140140+ args.identity_cache_memory_mb,
141141+ args.identity_cache_disk_gb,
142142+ )
143143+ .await
144144+ .map_err(|e| format!("identity setup failed: {e:?}"))?;
145145+133146 log::info!("identity service ready.");
134147 let identity_refresher = identity.clone();
135148 let identity_shutdown = shutdown.clone();