From 325602ca41c76753470b991c7a47b76b15e4241b Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 30 Nov 2015 13:56:04 -0500 Subject: Explicitly avoid repeat deps loading Track for each Edge whether depfile information has been loaded using an explicit flag. This will allow RecomputeDirty to be repeated for an edge without loading deps again. --- src/graph.cc | 16 ++++++++++------ src/graph.h | 3 ++- src/state.cc | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/graph.cc b/src/graph.cc index 9c2f784..bf9363d 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -75,12 +75,16 @@ bool DependencyScan::RecomputeDirty(Node* node, vector* stack, return false; } - if (!dep_loader_.LoadDeps(edge, err)) { - if (!err->empty()) - return false; - // Failed to load dependency info: rebuild to regenerate it. - // LoadDeps() did EXPLAIN() already, no need to do it here. - dirty = edge->deps_missing_ = true; + if (!edge->deps_loaded_) { + // This is our first encounter with this edge. Load discovered deps. + edge->deps_loaded_ = true; + if (!dep_loader_.LoadDeps(edge, err)) { + if (!err->empty()) + return false; + // Failed to load dependency info: rebuild to regenerate it. + // LoadDeps() did EXPLAIN() already, no need to do it here. + dirty = edge->deps_missing_ = true; + } } // Visit all inputs; we're dirty if any of the inputs are dirty. diff --git a/src/graph.h b/src/graph.h index d58fecd..20af578 100644 --- a/src/graph.h +++ b/src/graph.h @@ -136,7 +136,7 @@ struct Edge { }; Edge() : rule_(NULL), pool_(NULL), env_(NULL), mark_(VisitNone), - outputs_ready_(false), deps_missing_(false), + outputs_ready_(false), deps_loaded_(false), deps_missing_(false), implicit_deps_(0), order_only_deps_(0), implicit_outs_(0) {} /// Return true if all inputs' in-edges are ready. @@ -165,6 +165,7 @@ struct Edge { BindingEnv* env_; VisitMark mark_; bool outputs_ready_; + bool deps_loaded_; bool deps_missing_; const Rule& rule() const { return *rule_; } diff --git a/src/state.cc b/src/state.cc index 9b3c7e1..74cf4c1 100644 --- a/src/state.cc +++ b/src/state.cc @@ -186,6 +186,7 @@ void State::Reset() { i->second->ResetState(); for (vector::iterator e = edges_.begin(); e != edges_.end(); ++e) { (*e)->outputs_ready_ = false; + (*e)->deps_loaded_ = false; (*e)->mark_ = Edge::VisitNone; } } -- cgit v1.2.1