summaryrefslogtreecommitdiff
path: root/cli/cache/parsed_source.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-03-22 01:01:15 +0100
committerGitHub <noreply@github.com>2023-03-22 00:01:15 +0000
commit619806d7a9723eebe825281286b293b9b64f878e (patch)
tree8aad2126acc05f36033d2a009f427fbd5b26a5b3 /cli/cache/parsed_source.rs
parent7d9653d51fb0c4d3844f61e1214b6bddc50d2cef (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/parsed_source.rs')
-rw-r--r--cli/cache/parsed_source.rs44
1 files changed, 20 insertions, 24 deletions
diff --git a/cli/cache/parsed_source.rs b/cli/cache/parsed_source.rs
index b6a80e82e..7b183ce86 100644
--- a/cli/cache/parsed_source.rs
+++ b/cli/cache/parsed_source.rs
@@ -19,7 +19,7 @@ use deno_graph::ParsedSourceStore;
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;
use super::FastInsecureHasher;
#[derive(Clone, Default)]
@@ -162,8 +162,7 @@ impl ParsedSourceCacheModuleAnalyzer {
cli_version: String,
sources: ParsedSourceCacheSources,
) -> Result<Self, AnyError> {
- run_sqlite_pragma(&conn)?;
- create_tables(&conn, cli_version)?;
+ initialize(&conn, cli_version)?;
Ok(Self { conn, sources })
}
@@ -288,27 +287,24 @@ impl deno_graph::ModuleAnalyzer for ParsedSourceCacheModuleAnalyzer {
}
}
-fn create_tables(
- conn: &Connection,
- cli_version: String,
-) -> Result<(), AnyError> {
- // INT doesn't store up to u64, so use TEXT for source_hash
- conn.execute(
- "CREATE TABLE IF NOT EXISTS moduleinfocache (
- specifier TEXT PRIMARY KEY,
- media_type TEXT NOT NULL,
- source_hash TEXT NOT NULL,
- module_info 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> {
+ let query = format!(
+ "{INITIAL_PRAGMAS}
+ -- INT doesn't store up to u64, so use TEXT for source_hash
+ CREATE TABLE IF NOT EXISTS moduleinfocache (
+ specifier TEXT PRIMARY KEY,
+ media_type TEXT NOT NULL,
+ source_hash TEXT NOT NULL,
+ module_info 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