Wrap eval cache creation in a giant transaction
This speeds up the creation of the cache for the nixpkgs flake from 21.2s to 10.2s. Oddly, it also speeds up querying the cache (i.e. running 'nix flake show nixpkgs/nixos-20.03 --legacy') from 4.2s to 3.4s. (For comparison, running with --no-eval-cache takes 9.5s, so the overhead of building the SQLite cache is only 0.7s.)
This commit is contained in:
parent
aaa109565e
commit
69cb9f7eee
1 changed files with 14 additions and 0 deletions
|
@ -695,6 +695,7 @@ struct AttrDb
|
|||
SQLiteStmt insertAttribute;
|
||||
SQLiteStmt queryAttribute;
|
||||
SQLiteStmt queryAttributes;
|
||||
std::unique_ptr<SQLiteTxn> txn;
|
||||
};
|
||||
|
||||
struct placeholder_t {};
|
||||
|
@ -726,6 +727,19 @@ struct AttrDb
|
|||
|
||||
state->queryAttributes.create(state->db,
|
||||
"select name from Attributes where parent = ?");
|
||||
|
||||
state->txn = std::make_unique<SQLiteTxn>(state->db);
|
||||
}
|
||||
|
||||
~AttrDb()
|
||||
{
|
||||
try {
|
||||
auto state(_state->lock());
|
||||
state->txn->commit();
|
||||
state->txn.reset();
|
||||
} catch (...) {
|
||||
ignoreException();
|
||||
}
|
||||
}
|
||||
|
||||
AttrId setAttr(
|
||||
|
|
Loading…
Reference in a new issue