depslog: track dead record count
authorEvan Martin <martine@danga.com>
Wed, 9 Jan 2013 01:52:44 +0000 (17:52 -0800)
committerEvan Martin <martine@danga.com>
Mon, 8 Apr 2013 22:01:51 +0000 (15:01 -0700)
src/deps_log.cc
src/deps_log.h

index 5031515..b1ec009 100644 (file)
@@ -171,8 +171,10 @@ bool DepsLog::Load(const string& path, State* state, string* err) {
 
       if (out_id >= (int)deps_.size())
         deps_.resize(out_id + 1);
-      if (deps_[out_id])
+      if (deps_[out_id]) {
+        ++dead_record_count_;
         delete deps_[out_id];
+      }
       deps_[out_id] = deps;
     } else {
       StringPiece path(buf, size);
index d763a1d..e32a6fe 100644 (file)
@@ -61,6 +61,7 @@ struct State;
 /// wins, allowing updates to just be appended to the file.  A separate
 /// repacking step can run occasionally to remove dead records.
 struct DepsLog {
+  DepsLog() : dead_record_count_(0) {}
 
   // Writing (build-time) interface.
   bool OpenForWrite(const string& path, string* err);
@@ -89,6 +90,10 @@ struct DepsLog {
   // Write a node name record, assigning it an id.
   bool RecordId(Node* node);
 
+  /// Number of deps record read while loading the file that ended up
+  /// being unused (due to a latter entry superceding it).
+  int dead_record_count_;
+
   FILE* file_;
   /// Maps id -> Node.
   vector<Node*> nodes_;