diff --git a/crates/database/db/src/db.rs b/crates/database/db/src/db.rs index 2705111e..ac27f3f0 100644 --- a/crates/database/db/src/db.rs +++ b/crates/database/db/src/db.rs @@ -27,14 +27,23 @@ use tokio::sync::{Mutex, Semaphore}; const BUSY_TIMEOUT_SECS: u64 = 5; /// The maximum number of connections in the database connection pool. -const MAX_CONNECTIONS: u32 = 32; +const MAX_CONNECTIONS: u32 = 6; /// The minimum number of connections in the database connection pool. -const MIN_CONNECTIONS: u32 = 5; +const MIN_CONNECTIONS: u32 = 2; /// The timeout for acquiring a connection from the pool. const ACQUIRE_TIMEOUT_SECS: u64 = 5; +/// The cache size in KB +const CACHE_SIZE_KB: &str = "-131072"; // 128 MB + +/// The mmap size in bytes +const MMAP_SIZE_BYTES: &str = "536870912"; // 512 MB + +/// The wal auto checkpoint size in pages +const WAL_AUTO_CHECKPOINT_PAGES: &str = "50000"; // 200 MB (with default page size of 4 KB) + /// A wrapper around `DatabaseInner` which provides retry features. #[derive(Debug)] pub struct Database { @@ -595,7 +604,11 @@ impl DatabaseInner { .journal_mode(sea_orm::sqlx::sqlite::SqliteJournalMode::Wal) .busy_timeout(Duration::from_secs(busy_timeout_secs)) .foreign_keys(true) - .synchronous(sea_orm::sqlx::sqlite::SqliteSynchronous::Normal); + .synchronous(sea_orm::sqlx::sqlite::SqliteSynchronous::Normal) + .pragma("cache_size", CACHE_SIZE_KB) + .pragma("mmap_size", MMAP_SIZE_BYTES) + .pragma("wal_autocheckpoint", WAL_AUTO_CHECKPOINT_PAGES) + .pragma("temp_store", "MEMORY"); let sqlx_pool = SqlitePoolOptions::new() .max_connections(max_connections) diff --git a/crates/derivation-pipeline/src/lib.rs b/crates/derivation-pipeline/src/lib.rs index ed245e89..e34f00a2 100644 --- a/crates/derivation-pipeline/src/lib.rs +++ b/crates/derivation-pipeline/src/lib.rs @@ -95,7 +95,7 @@ impl Stream for DerivationPipeline { } /// The maximum number of concurrent batch derivation futures. -const DERIVATION_PIPELINE_WORKER_CONCURRENCY: usize = 5; +const DERIVATION_PIPELINE_WORKER_CONCURRENCY: usize = 3; /// A structure holding the current unresolved futures for the derivation pipeline. #[derive(Debug)] diff --git a/sequencer-migration/send-l1-messages.sh b/sequencer-migration/send-l1-messages.sh old mode 100644 new mode 100755 index 73ef984f..9e289939 --- a/sequencer-migration/send-l1-messages.sh +++ b/sequencer-migration/send-l1-messages.sh @@ -78,5 +78,7 @@ main() { log_info "Next queue index: $next_queue_index " done - echo "Done" + log_info "Done" } + +main "$@"