Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(torii-core): WAL journal mode & remove max conns #2439

Merged
merged 9 commits into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions bin/torii/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
use dojo_metrics::{metrics_process, prometheus_exporter};
use dojo_utils::parse::{parse_socket_address, parse_url};
use dojo_world::contracts::world::WorldContractReader;
use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
use sqlx::sqlite::{
SqliteAutoVacuum, SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions, SqliteSynchronous,
};
use sqlx::SqlitePool;
use starknet::core::types::Felt;
use starknet::providers::jsonrpc::HttpTransport;
Expand Down Expand Up @@ -153,19 +155,15 @@
})
.expect("Error setting Ctrl-C handler");

let database_url = format!("sqlite:{}", &args.database);
let options =
SqliteConnectOptions::from_str(&database_url)?.create_if_missing(true).with_regexp();
let pool = SqlitePoolOptions::new()
.min_connections(1)
.max_connections(5)
.connect_with(options)
.await?;
let mut options =
SqliteConnectOptions::from_str(&args.database)?.create_if_missing(true).with_regexp();

// Performance settings
options = options.auto_vacuum(SqliteAutoVacuum::None);
options = options.journal_mode(SqliteJournalMode::Wal);
options = options.synchronous(SqliteSynchronous::Normal);

Check warning on line 164 in bin/torii/src/main.rs

View check run for this annotation

Codecov / codecov/patch

bin/torii/src/main.rs#L158-L164

Added lines #L158 - L164 were not covered by tests

// Disable auto-vacuum
sqlx::query("PRAGMA auto_vacuum = NONE;").execute(&pool).await?;
sqlx::query("PRAGMA journal_mode = WAL;").execute(&pool).await?;
sqlx::query("PRAGMA synchronous = NORMAL;").execute(&pool).await?;
let pool = SqlitePoolOptions::new().min_connections(1).connect_with(options).await?;

Check warning on line 166 in bin/torii/src/main.rs

View check run for this annotation

Codecov / codecov/patch

bin/torii/src/main.rs#L166

Added line #L166 was not covered by tests

// Set the number of threads based on CPU count
let cpu_count = std::thread::available_parallelism().unwrap().get();
Expand Down
Loading