Commit 3f13aec7 authored by Tomas Krizek's avatar Tomas Krizek

dbhelper: re-add unsafe fast option

This option is actually used in msgdiff and provides a significant speed
boost.
parent f4789a0b
......@@ -31,7 +31,8 @@ class LMDB:
# integerkey support in LMDB
} # type: Dict[str, Any]
def __init__(self, path: str, create: bool = False, readonly: bool = False) -> None:
def __init__(self, path: str, create: bool = False,
readonly: bool = False, fast: bool = False) -> None:
self.path = path
self.dbs = {} # type: Dict[bytes, Any]
self.config = LMDB.ENV_DEFAULTS.copy()
......@@ -40,6 +41,12 @@ class LMDB:
'create': create,
'readonly': readonly
})
if fast: # unsafe on crashes, but faster
self.config.update({
'writemap': True,
'sync': False,
'map_async': True,
})
if not os.path.exists(self.path):
os.makedirs(self.path)
......
......@@ -247,7 +247,7 @@ def main():
criteria = config['diff']['criteria']
target = config['diff']['target']
with LMDB(args.envdir) as lmdb_:
with LMDB(args.envdir, fast=True) as lmdb_:
lmdb = lmdb_
lmdb.open_db(LMDB.ANSWERS)
lmdb.open_db(LMDB.DIFFS, create=True, drop=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment