Don't sync db on every sync

This fixes some lag, when Nheko is running, which could affect Nheko and
even other applications by excessively calling fsync. This should be
fine, since all filesystems seem to guarantee order and in most cases,
the modified pages are still written. In the worst case we should only
lose the last /sync results or similar.
This commit is contained in:
Nicolas Werner 2020-12-13 01:27:30 +01:00
parent dc1dd6e2e6
commit 65a4c85ed4
1 changed files with 1 additions and 1 deletions

View File

@ -189,7 +189,7 @@ Cache::setup()
// NOTE(Nico): We may want to use (MDB_MAPASYNC | MDB_WRITEMAP) in the future, but // NOTE(Nico): We may want to use (MDB_MAPASYNC | MDB_WRITEMAP) in the future, but
// it can really mess up our database, so we shouldn't. For now, hopefully // it can really mess up our database, so we shouldn't. For now, hopefully
// NOMETASYNC is fast enough. // NOMETASYNC is fast enough.
env_.open(statePath.toStdString().c_str(), MDB_NOMETASYNC); env_.open(statePath.toStdString().c_str(), MDB_NOMETASYNC | MDB_NOSYNC);
} catch (const lmdb::error &e) { } catch (const lmdb::error &e) {
if (e.code() != MDB_VERSION_MISMATCH && e.code() != MDB_INVALID) { if (e.code() != MDB_VERSION_MISMATCH && e.code() != MDB_INVALID) {
throw std::runtime_error("LMDB initialization failed" + throw std::runtime_error("LMDB initialization failed" +