Skip to content

Commit b062656

Browse files
authored
feat: enable WAL mode on sqlite 1.39-1.9xing Trin performance (#1662)
1 parent a63239f commit b062656

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

crates/storage/src/sql.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,6 @@ pub const HISTORICAL_SUMMARIES_EPOCH_LOOKUP_QUERY: &str =
7777

7878
// todo: remove this in the future
7979
pub const DROP_USAGE_STATS_DB: &str = "DROP TABLE IF EXISTS usage_stats;";
80+
81+
/// Benchmarking with WAL mode enabled 1.4 to 1.9x's Trin performance
82+
pub const ENABLE_WAL_MODE: &str = "PRAGMA journal_mode = WAL;PRAGMA synchronous = NORMAL;";

crates/storage/src/utils.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use tracing::info;
77
use crate::{
88
error::ContentStoreError,
99
sql::{
10-
DROP_USAGE_STATS_DB, HISTORICAL_SUMMARIES_CREATE_TABLE, LC_BOOTSTRAP_CREATE_TABLE,
11-
LC_UPDATE_CREATE_TABLE,
10+
DROP_USAGE_STATS_DB, ENABLE_WAL_MODE, HISTORICAL_SUMMARIES_CREATE_TABLE,
11+
LC_BOOTSTRAP_CREATE_TABLE, LC_UPDATE_CREATE_TABLE,
1212
},
1313
versioned::sql::STORE_INFO_CREATE_TABLE,
1414
DATABASE_NAME,
@@ -22,6 +22,7 @@ pub fn setup_sql(node_data_dir: &Path) -> Result<Pool<SqliteConnectionManager>,
2222
let manager = SqliteConnectionManager::file(sql_path);
2323
let pool = Pool::new(manager)?;
2424
let conn = pool.get()?;
25+
conn.execute_batch(ENABLE_WAL_MODE)?;
2526
conn.execute_batch(LC_BOOTSTRAP_CREATE_TABLE)?;
2627
conn.execute_batch(LC_UPDATE_CREATE_TABLE)?;
2728
conn.execute_batch(HISTORICAL_SUMMARIES_CREATE_TABLE)?;

0 commit comments

Comments
 (0)