From 7c1773cf37ce52958c3287363c0690c591e3c364 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sat, 19 May 2012 01:25:06 -0400 Subject: [PATCH] Default to DB_TXN_WRITE_NOSYNC for all transactional operations * This is safer than DB_TXN_NOSYNC, and does not appear to impact performance. * Applying this to the dbenv is necessary to avoid many fdatasync(2) calls on db 5.x * We carefully and thoroughly flush databases upon shutdown and other important events already. --- src/db.cpp | 1 + src/db.h | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 12647e5..ef45976 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -96,6 +96,7 @@ CDB::CDB(const char *pszFile, const char* pszMode) : pdb(NULL) dbenv.set_lk_max_locks(10000); dbenv.set_lk_max_objects(10000); dbenv.set_errfile(fopen(pathErrorFile.string().c_str(), "a")); /// debug + dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1); dbenv.set_flags(DB_AUTO_COMMIT, 1); dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1); ret = dbenv.open(pathDataDir.string().c_str(), diff --git a/src/db.h b/src/db.h index 3ce8f17..399b62f 100644 --- a/src/db.h +++ b/src/db.h @@ -216,7 +216,7 @@ public: if (!pdb) return false; DbTxn* ptxn = NULL; - int ret = dbenv.txn_begin(GetTxn(), &ptxn, DB_TXN_NOSYNC); + int ret = dbenv.txn_begin(GetTxn(), &ptxn, DB_TXN_WRITE_NOSYNC); if (!ptxn || ret != 0) return false; vTxn.push_back(ptxn); -- 1.7.1