Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 16 additions & 3 deletions crates/database/db/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a typo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean the variable name?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the dash in front of 131072

Copy link
Collaborator Author

@frisitano frisitano Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh no, positive numbers specify number of pages, negative numbers specify the size in KB:

If the argument N is positive then the suggested cache size is set to N. If the argument N is negative, then the number of cache pages is adjusted to be a number of pages that would use approximately abs(N*1024) bytes of memory based on the current page size. SQLite remembers the number of pages in the page cache, not the amount of memory used. So if you set the cache size using a negative number and subsequently change the page size (using the PRAGMA page_size command) then the maximum amount of cache memory will go up or down in proportion to the change in page size.


/// 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 {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion crates/derivation-pipeline/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 3 additions & 1 deletion sequencer-migration/send-l1-messages.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ main() {
log_info "Next queue index: $next_queue_index "
done

echo "Done"
log_info "Done"
}

main "$@"
Loading