From c7dabff3aaab59649fba8dc18ae5dadf0c0b8f20 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 21 Nov 2017 08:34:22 +0200 Subject: Improve skipped update diagnostics Instead of printing a line for each target skipped we now print a summary with count at the end. We also now show the skip count in progress. --- build2/cc/compile.cxx | 7 +------ build2/context.cxx | 1 + build2/context.hxx | 10 +++++++--- build2/operation.cxx | 29 +++++++++++++++++++++++++++-- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx index 6022fb6..33a0d6d 100644 --- a/build2/cc/compile.cxx +++ b/build2/cc/compile.cxx @@ -3985,13 +3985,8 @@ namespace build2 { if (md.touch) { - // Getting "everything up to date" after modifying a file can be - // unnerving. So calm the user down. - // - if (verb == 1) - text << "skip " << s; - touch (tp, false, 2); + skip_count.fetch_add (1, memory_order_relaxed); } t.mtime (md.mt); diff --git a/build2/context.cxx b/build2/context.cxx index d074d9c..68c7e6d 100644 --- a/build2/context.cxx +++ b/build2/context.cxx @@ -204,6 +204,7 @@ namespace build2 atomic_count dependency_count; atomic_count target_count; + atomic_count skip_count; bool keep_going = false; diff --git a/build2/context.hxx b/build2/context.hxx index dbb41ae..c3e0595 100644 --- a/build2/context.hxx +++ b/build2/context.hxx @@ -283,11 +283,13 @@ namespace build2 // with the expectation of it reaching 0. Used as a sanity check. // // The target count is incremented after a non-noop recipe is matched and - // decremented after such recipe has been executed. Used for progress - // monitoring. + // decremented after such recipe has been executed. If such a recipe has + // skipped updating the target, then it should increment the skip count. + // These two counters are used for progress monitoring and diagnostics. // extern atomic_count dependency_count; extern atomic_count target_count; + extern atomic_count skip_count; inline void set_current_mif (const meta_operation_info& mif) @@ -307,9 +309,11 @@ namespace build2 current_on++; current_mode = inner_oif.mode; - // Serial. + // Reset counters (serial execution). + // dependency_count.store (0, memory_order_relaxed); target_count.store (0, memory_order_relaxed); + skip_count.store (0, memory_order_relaxed); } // Keep going flag. diff --git a/build2/operation.cxx b/build2/operation.cxx index 09e7b8c..ea1e06e 100644 --- a/build2/operation.cxx +++ b/build2/operation.cxx @@ -268,10 +268,20 @@ namespace build2 [init, incr, what] (size_t c) -> size_t { size_t p ((init - c) * 100 / init); + size_t s (skip_count.load (memory_order_relaxed)); + diag_progress_lock pl; diag_progress = ' '; diag_progress += to_string (p); diag_progress += what; + + if (s != 0) + { + diag_progress += " ("; + diag_progress += to_string (s); + diag_progress += " skipped)"; + } + return c - incr; }); } @@ -302,6 +312,11 @@ namespace build2 wg.wait (); } + // We are now running serially. + // + + sched.tune (0); // Restore original scheduler settings. + // Clear the progress if present. // if (mg) @@ -310,9 +325,19 @@ namespace build2 diag_progress.clear (); } - sched.tune (0); // Restore original scheduler settings. + // Print skip count if not zero. Note that we print it regardless of the + // quiet flag since this is essentially a "summary" of all the commands + // that we did not (and, in fact, used to originally) print. + // + if (verb != 0) + { + if (size_t s = skip_count.load (memory_order_relaxed)) + { + text << "skipped " << diag_doing (a) << ' ' << s << " target(s)"; + } + } - // We are now running serially. Re-examine them all. + // Re-examine all the targets and print diagnostics. // bool fail (false); for (const void* vt: ts) -- cgit v1.1