about summary refs log tree commit diff
path: root/src/libstore/store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-06-21T07·38+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-06-21T07·38+0000
commitdaf0a923c7c77300dfb09ee34c1ae31c87002a0e (patch)
treed72b2533082046b3f02a8e8d2a54423af823c8cf /src/libstore/store.cc
parent15c60ca1b64a4e5dc874f60c764f0ccc8899d740 (diff)
* Wrap calls to registerSubstitute() in a single transaction to
  improve throughput.
* Don't build the `substitute-rev' table for now, since it caused
  Theta(N^2) time and log file consumption when adding N substitutes.
  Maybe we can do without it.

Diffstat (limited to 'src/libstore/store.cc')
-rw-r--r--src/libstore/store.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/libstore/store.cc b/src/libstore/store.cc
index 74f182468a5d..9c5d0bab8aae 100644
--- a/src/libstore/store.cc
+++ b/src/libstore/store.cc
@@ -302,19 +302,16 @@ static void writeSubstitutes(const Transaction & txn,
 }
 
 
-void registerSubstitute(const Path & srcPath,
-    const Substitute & sub)
+void registerSubstitute(const Transaction & txn,
+    const Path & srcPath, const Substitute & sub)
 {
     assertStorePath(srcPath);
     assertStorePath(sub.storeExpr);
     
-    Transaction txn(nixDB);
-
     Substitutes subs = readSubstitutes(txn, srcPath);
 
     if (find(subs.begin(), subs.end(), sub) != subs.end()) {
         /* Nothing to do if the substitute is already known. */
-        txn.abort();
         return;
     }
     subs.push_front(sub); /* new substitutes take precedence */
@@ -325,10 +322,9 @@ void registerSubstitute(const Path & srcPath,
     nixDB.queryStrings(txn, dbSubstitutesRev, sub.storeExpr, revs);
     if (find(revs.begin(), revs.end(), srcPath) == revs.end())
         revs.push_back(srcPath);
-    
-    nixDB.setStrings(txn, dbSubstitutesRev, sub.storeExpr, revs);
 
-    txn.commit();
+    // !!! O(n^2) complexity in building this
+    //    nixDB.setStrings(txn, dbSubstitutesRev, sub.storeExpr, revs);
 }