diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-02-24T12·48+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-02-24T12·48+0000 |
commit | 90b6352d0a5d08dc7feabcfde92653dd1f6e324b (patch) | |
tree | bc549b7e7b1d8d38292c54060a4c3b911b02a58d /src/libstore/local-store.cc | |
parent | fae0427324269e420d8ea5774f2fab2330acda9d (diff) |
* Do registerValidPaths() in one transaction, which is much faster.
E.g. it cuts the runtime of the referrers test from 50s to 23s.
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r-- | src/libstore/local-store.cc | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 8e5448446065..6e8082776dd0 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -765,39 +765,19 @@ Hash LocalStore::queryPathHash(const Path & path) } -static void dfsVisit(std::map<Path, ValidPathInfo> & infos, - const Path & path, PathSet & visited, Paths & sorted) +void LocalStore::registerValidPaths(const ValidPathInfos & infos) { - if (visited.find(path) != visited.end()) return; - visited.insert(path); - - ValidPathInfo & info(infos[path]); + SQLiteTxn txn(db); - foreach (PathSet::iterator, i, info.references) - if (infos.find(*i) != infos.end()) - dfsVisit(infos, *i, visited, sorted); - - sorted.push_back(path); -} + foreach (ValidPathInfos::const_iterator, i, infos) addValidPath(*i); + foreach (ValidPathInfos::const_iterator, i, infos) { + unsigned long long referrer = queryPathInfo(i->path).id; + foreach (PathSet::iterator, j, i->references) + addReference(referrer, queryPathInfo(*j).id); + } -void LocalStore::registerValidPaths(const ValidPathInfos & infos) -{ - std::map<Path, ValidPathInfo> infosMap; - - /* Sort the paths topologically under the references relation, so - that if path A is referenced by B, then A is registered before - B. */ - foreach (ValidPathInfos::const_iterator, i, infos) - infosMap[i->path] = *i; - - PathSet visited; - Paths sorted; - foreach (ValidPathInfos::const_iterator, i, infos) - dfsVisit(infosMap, i->path, visited, sorted); - - foreach (Paths::iterator, i, sorted) - registerValidPath(infosMap[*i]); + txn.commit(); } |