diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-22 01:01:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-22 00:01:15 +0000 |
commit | 619806d7a9723eebe825281286b293b9b64f878e (patch) | |
tree | 8aad2126acc05f36033d2a009f427fbd5b26a5b3 /cli/cache/incremental.rs | |
parent | 7d9653d51fb0c4d3844f61e1214b6bddc50d2cef (diff) |
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%.
Diffstat (limited to 'cli/cache/incremental.rs')
-rw-r--r-- | cli/cache/incremental.rs | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/cli/cache/incremental.rs b/cli/cache/incremental.rs index 985181c59..88520a031 100644 --- a/cli/cache/incremental.rs +++ b/cli/cache/incremental.rs @@ -12,8 +12,8 @@ use deno_runtime::deno_webstorage::rusqlite::Connection; use serde::Serialize; use tokio::task::JoinHandle; -use super::common::run_sqlite_pragma; use super::common::FastInsecureHasher; +use super::common::INITIAL_PRAGMAS; /// Cache used to skip formatting/linting a file again when we /// know it is already formatted or has no lint diagnostics. @@ -174,8 +174,7 @@ impl SqlIncrementalCache { state_hash: u64, cli_version: String, ) -> Result<Self, AnyError> { - run_sqlite_pragma(&conn)?; - create_tables(&conn, cli_version)?; + initialize(&conn, cli_version)?; Ok(Self { conn, state_hash }) } @@ -238,26 +237,21 @@ impl SqlIncrementalCache { } } -fn create_tables( - conn: &Connection, - cli_version: String, -) -> Result<(), AnyError> { - // INT doesn't store up to u64, so use TEXT - conn.execute( - "CREATE TABLE IF NOT EXISTS incrementalcache ( - file_path TEXT PRIMARY KEY, - state_hash TEXT NOT NULL, - source_hash TEXT NOT NULL - )", - [], - )?; - conn.execute( - "CREATE TABLE IF NOT EXISTS info ( - key TEXT PRIMARY KEY, - value TEXT NOT NULL - )", - [], - )?; +fn initialize(conn: &Connection, cli_version: String) -> Result<(), AnyError> { + // INT doesn't store up to u64, so use TEXT for source_hash + let query = format!( + "{INITIAL_PRAGMAS} + CREATE TABLE IF NOT EXISTS incrementalcache ( + file_path TEXT PRIMARY KEY, + state_hash TEXT NOT NULL, + source_hash TEXT NOT NULL + ); + CREATE TABLE IF NOT EXISTS info ( + key TEXT PRIMARY KEY, + value TEXT NOT NULL + );" + ); + conn.execute_batch(&query)?; // delete the cache when the CLI version changes let data_cli_version: Option<String> = conn |