diff --git a/lyra/memory.py b/lyra/memory.py index 0529612..a7a3478 100644 --- a/lyra/memory.py +++ b/lyra/memory.py @@ -131,6 +131,11 @@ def _connection() -> sqlite3.Connection: # alongside the web server without tripping "database is locked". _conn.execute("PRAGMA busy_timeout=5000") _conn.execute("PRAGMA journal_mode=WAL") + # WAL's recommended companion: don't fsync on every commit (only at + # checkpoint). Safe against app crashes; a power/OS crash can lose the last + # txn but never corrupt. On disk-backed storage this turns ~0.15s-per-commit + # fsync latency into ~nothing — big win for per-turn writes + the dream loop. + _conn.execute("PRAGMA synchronous=NORMAL") _conn.executescript(SCHEMA) # Migrations for DBs created before a column existed (no-op if present). for ddl in ("ALTER TABLE sessions ADD COLUMN mode TEXT",):