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/check.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/check.rs')
-rw-r--r-- | cli/cache/check.rs | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/cli/cache/check.rs b/cli/cache/check.rs index c991c14b1..c8b5717ec 100644 --- a/cli/cache/check.rs +++ b/cli/cache/check.rs @@ -7,7 +7,7 @@ use deno_core::error::AnyError; use deno_runtime::deno_webstorage::rusqlite::params; use deno_runtime::deno_webstorage::rusqlite::Connection; -use super::common::run_sqlite_pragma; +use super::common::INITIAL_PRAGMAS; /// The cache used to tell whether type checking should occur again. /// @@ -60,8 +60,7 @@ impl TypeCheckCache { conn: Connection, cli_version: String, ) -> Result<Self, AnyError> { - run_sqlite_pragma(&conn)?; - create_tables(&conn, cli_version)?; + initialize(&conn, cli_version)?; Ok(Self(Some(conn))) } @@ -158,31 +157,24 @@ impl TypeCheckCache { } } -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 checkcache ( - check_hash TEXT PRIMARY KEY - )", - [], - )?; - conn.execute( - "CREATE TABLE IF NOT EXISTS tsbuildinfo ( - specifier TEXT PRIMARY KEY, - text 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 check_hash + let query = format!( + "{INITIAL_PRAGMAS} + CREATE TABLE IF NOT EXISTS checkcache ( + check_hash TEXT PRIMARY KEY + ); + CREATE TABLE IF NOT EXISTS tsbuildinfo ( + specifier TEXT PRIMARY KEY, + text 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 |