Skip to content

Commit 6441428

Browse files
committed
Fix tokenization_workers count when num_cpus == num_shards
1 parent 38871fb commit 6441428

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

router/src/main.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,13 @@ fn main() -> Result<(), std::io::Error> {
103103
// Determine number of threads to use for tokenization based on number of cores
104104
let num_cpus = num_cpus::get();
105105
let num_shards = sharded_client.shard_count();
106-
num_cpus.checked_sub(num_shards).unwrap_or(1).min(8)
106+
num_cpus.checked_sub(num_shards).unwrap_or(1).clamp(1, 8)
107107
});
108108

109109
tracing::info!("Using pool of {tokenization_workers} threads for tokenization");
110110

111-
// Clear the cache; useful if the webserver rebooted
112-
sharded_client
113-
.clear_cache()
114-
.await
115-
.expect("Unable to clear cache");
111+
// Clear the cache; useful if this process rebooted
112+
sharded_client.clear_cache().await.expect("Unable to clear cache");
116113
tracing::info!("Connected");
117114

118115
let grpc_addr = SocketAddr::new(

0 commit comments

Comments
 (0)