perf: disable WAL for transpiled source cache (#18084)

Disable Write-Ahead Log for the cached module source database.

This brings SQLite connection cost on startup from 2.5% to 1.6%.
This commit is contained in:
Bartek Iwańczuk 2023-03-22 01:01:15 +01:00 committed by GitHub
parent 7d9653d51f
commit 619806d7a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 95 additions and 131 deletions

30
cli/cache/common.rs vendored
View file

@ -2,9 +2,6 @@
use std::hash::Hasher;
use deno_core::error::AnyError;
use deno_runtime::deno_webstorage::rusqlite::Connection;
/// A very fast insecure hasher that uses the xxHash algorithm.
#[derive(Default)]
pub struct FastInsecureHasher(twox_hash::XxHash64);
@ -47,19 +44,14 @@ impl FastInsecureHasher {
}
}
/// Runs the common sqlite pragma.
pub fn run_sqlite_pragma(conn: &Connection) -> Result<(), AnyError> {
// Enable write-ahead-logging and tweak some other stuff
let initial_pragmas = "
-- enable write-ahead-logging mode
PRAGMA journal_mode=WAL;
PRAGMA synchronous=NORMAL;
PRAGMA temp_store=memory;
PRAGMA page_size=4096;
PRAGMA mmap_size=6000000;
PRAGMA optimize;
";
conn.execute_batch(initial_pragmas)?;
Ok(())
}
/// Disable write-ahead-logging and tweak some other stuff.
/// We want to favor startup time over cache performance and
/// creating a WAL is expensive on startup.
pub static INITIAL_PRAGMAS: &str = "
PRAGMA journal_mode=OFF;
PRAGMA synchronous=NORMAL;
PRAGMA temp_store=memory;
PRAGMA page_size=4096;
PRAGMA mmap_size=6000000;
PRAGMA optimize;
";