Skip to content

Commit

Permalink
cap threads to 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Sep 17, 2024
1 parent 5ffe50e commit 3e297f9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/torii/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//! documentation for usage details. This is **not recommended on Windows**. See [here](https://rust-lang.github.io/rfcs/1974-global-allocators.html#jemalloc)
//! for more info.
use std::cmp;
use std::net::SocketAddr;
use std::str::FromStr;
use std::sync::Arc;
Expand Down Expand Up @@ -168,7 +169,8 @@ async fn main() -> anyhow::Result<()> {

// Set the number of threads based on CPU count
let cpu_count = std::thread::available_parallelism().unwrap().get();
sqlx::query(&format!("PRAGMA threads = {};", cpu_count)).execute(&pool).await?;
let thread_count = cmp::min(cpu_count, 8);
sqlx::query(&format!("PRAGMA threads = {};", thread_count)).execute(&pool).await?;

sqlx::migrate!("../../crates/torii/migrations").run(&pool).await?;

Expand Down

0 comments on commit 3e297f9

Please sign in to comment.