aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Lassieur <clement@lassieur.org>2018-07-19 12:48:44 +0200
committerClément Lassieur <clement@lassieur.org>2018-07-20 15:19:23 +0200
commit6f8dc0b6169fa43a340377e3a95a0352cfc2148a (patch)
tree4b0e15a2f60f4132475039548dc790a94ca90101
parent7b2f9e0de1ad2d320973b7aea132a8afcad8bece (diff)
downloadcuirass-6f8dc0b6169fa43a340377e3a95a0352cfc2148a.tar
cuirass-6f8dc0b6169fa43a340377e3a95a0352cfc2148a.tar.gz
database: Use SQLite in Multi-thread mode.
This disables mutexing on database connection and prepared statement objects, thus making us responsible for serializing access to database connections and prepared statements. It may result in a performance improvement. * src/cuirass/database.scm (db-init, db-open): Pass the SQLITE_OPEN_NOMUTEX flag to SQLITE-OPEN.
-rw-r--r--src/cuirass/database.scm11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index 72acb15..df41d75 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -189,7 +189,8 @@ database object."
(format (current-error-port) "Removing leftover database ~a~%" db-name)
(delete-file db-name))
(let ((db (sqlite-open db-name (logior SQLITE_OPEN_CREATE
- SQLITE_OPEN_READWRITE))))
+ SQLITE_OPEN_READWRITE
+ SQLITE_OPEN_NOMUTEX))))
(db-load db schema)
(db-set-schema-version db (latest-db-schema-version))
db))
@@ -215,8 +216,14 @@ database object."
;; Use "write-ahead log" mode because it improves concurrency and should
;; avoid SQLITE_LOCKED errors when we have several readers:
;; <https://www.sqlite.org/wal.html>.
+
+ ;; SQLITE_OPEN_NOMUTEX disables mutexing on database connection and prepared
+ ;; statement objects, thus making us responsible for serializing access to
+ ;; database connections and prepared statements.
(set-db-options (if (file-exists? db)
- (db-upgrade (sqlite-open db SQLITE_OPEN_READWRITE))
+ (db-upgrade
+ (sqlite-open db (logior SQLITE_OPEN_READWRITE
+ SQLITE_OPEN_NOMUTEX)))
(db-init db))))
(define (db-close db)