Skip to content

[NFC] Remove -debug-time-compilation #32938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 2 additions & 28 deletions docs/CompilerPerformance.md
Original file line number Diff line number Diff line change
Expand Up @@ -559,30 +559,6 @@ compilers on hand while you're working.
0.0001 (100.0%) 0.0001 (100.0%) 0.0001 (100.0%) 0.0490 (100.0%) Total
```

- `-Xfrontend -debug-time-compilation`: asks each frontend to print out timers
for each phase of its execution. Its output (per-frontend) looks like this:

```
===-------------------------------------------------------------------------===
Swift compilation
===-------------------------------------------------------------------------===
Total Execution Time: 0.0876 seconds (0.0877 wall clock)

---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name ---
0.0241 ( 53.9%) 0.0394 ( 92.0%) 0.0635 ( 72.5%) 0.0635 ( 72.5%) Import resolution
0.0170 ( 38.0%) 0.0025 ( 5.8%) 0.0195 ( 22.3%) 0.0195 ( 22.2%) Type checking / Semantic analysis
0.0013 ( 3.0%) 0.0004 ( 0.8%) 0.0017 ( 1.9%) 0.0017 ( 1.9%) LLVM output
0.0010 ( 2.3%) 0.0003 ( 0.7%) 0.0013 ( 1.5%) 0.0013 ( 1.5%) SILGen
0.0006 ( 1.4%) 0.0002 ( 0.4%) 0.0008 ( 0.9%) 0.0008 ( 0.9%) IRGen
0.0004 ( 0.8%) 0.0000 ( 0.1%) 0.0004 ( 0.5%) 0.0004 ( 0.5%) SIL optimization
0.0002 ( 0.5%) 0.0001 ( 0.1%) 0.0003 ( 0.3%) 0.0003 ( 0.3%) LLVM optimization
0.0001 ( 0.1%) 0.0000 ( 0.1%) 0.0001 ( 0.1%) 0.0001 ( 0.1%) Parsing
0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.0%) SIL verification (pre-optimization)
0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.0%) SIL verification (post-optimization)
0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.0%) AST verification
0.0448 (100.0%) 0.0428 (100.0%) 0.0876 (100.0%) 0.0877 (100.0%) Total
```

Comment on lines -562 to -585
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking that what was nice about this was that it was an easy way to get per-frontend-per-phase info. How would you do that now? I'm sorry to see it go, but I think there are no RecursionSafeTimers in the compiler anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you have to use the full -stats-dir output.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a loss, but not your fault, since the flag doesn't work anymore.

- `-Xfrontend -debug-time-function-bodies`: asks each frontend to print out
the time spent typechecking _every function_ in the program, sorted by time
taken. The output is therefore voluminous, but can help when reducing a
Expand Down Expand Up @@ -1053,10 +1029,8 @@ getting slower between versions:
parameter of the script). Reconfirm that _just those two isolated frontend
processes_ still show the regression you're interested in isolating.

6. Check high-level diagnostic output between the two compilers, either the
newer unified stats reporter (`-stats-output-dir`) or the older flags
(`-Xfrontend -debug-time-compilation` and friends). Comparing the two will
often guide the search.
6. Check the value of performance counters between the two compilers via the
unified stats reporter (`-stats-output-dir`).

7. Run both frontend processes under a profiler and compare the profiles in
detail. At this point there ought to be _some_ sign of a difference, either
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Basic/Statistic.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Timer.h"
#include "swift/Basic/LLVM.h"
#include "swift/Basic/Timer.h"

#include <thread>
#include <tuple>
Expand Down
66 changes: 0 additions & 66 deletions include/swift/Basic/Timer.h

This file was deleted.

6 changes: 0 additions & 6 deletions include/swift/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,6 @@ class FrontendOptions {
/// If set, dumps wall time taken to check each expression.
bool DebugTimeExpressionTypeChecking = false;

/// If set, prints the time taken in each major compilation phase to
/// llvm::errs().
///
/// \sa swift::SharedTimer
bool DebugTimeCompilation = false;

/// The path to which we should output statistics files.
std::string StatsOutputDir;

Expand Down
2 changes: 0 additions & 2 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ def build_request_dependency_graph : Flag<["-"], "build-request-dependency-graph
def output_request_graphviz : Separate<["-"], "output-request-graphviz">,
HelpText<"Emit GraphViz output visualizing the request dependency graph">;

def debug_time_compilation : Flag<["-"], "debug-time-compilation">,
HelpText<"Prints the time taken by each compilation phase">;
def debug_time_function_bodies : Flag<["-"], "debug-time-function-bodies">,
HelpText<"Dumps the time it takes to type-check each function body">;
def debug_time_expression_type_checking : Flag<["-"], "debug-time-expression-type-checking">,
Expand Down
1 change: 0 additions & 1 deletion lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ add_swift_host_library(swiftBasic STATIC
StringExtras.cpp
TaskQueue.cpp
ThreadSafeRefCounted.cpp
Timer.cpp
Unicode.cpp
UUID.cpp
Version.cpp
Expand Down
7 changes: 2 additions & 5 deletions lib/Basic/Statistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "swift/Basic/Statistic.h"
#include "swift/Basic/Timer.h"
#include "swift/AST/Decl.h"
#include "swift/AST/Expr.h"
#include "llvm/ADT/DenseMap.h"
Expand Down Expand Up @@ -146,9 +145,8 @@ auxName(StringRef ModuleName,
}

class UnifiedStatsReporter::RecursionSafeTimers {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any of these left in the compiler? If not, were they replaced by something else? A quick search of the code seems to say there are none. Is NamedRegionTimer already recursion-safe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  // First make a note in the recursion-safe timers; these
  // are active anytime UnifiedStatsReporter is active.
  if (IsEntry) {
    RecursiveTimers->beginTimer(T.EventName);
  } else {
    RecursiveTimers->endTimer(T.EventName);
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard to see usages because of the Optional::emplace here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but I was looking for the individual uses in the code, like: checkTypes() { RecursiveTimer rt; .... }


struct RecursionSafeTimer {
llvm::Optional<SharedTimer> Timer;
llvm::Optional<llvm::NamedRegionTimer> Timer;
size_t RecursionDepth;
};

Expand All @@ -159,7 +157,7 @@ class UnifiedStatsReporter::RecursionSafeTimers {
void beginTimer(StringRef Name) {
RecursionSafeTimer &T = Timers[Name];
if (T.RecursionDepth == 0) {
T.Timer.emplace(Name);
T.Timer.emplace(Name, Name, "swift", "Swift compilation");
}
++T.RecursionDepth;
}
Expand Down Expand Up @@ -354,7 +352,6 @@ UnifiedStatsReporter::UnifiedStatsReporter(StringRef ProgramName,
path::append(TraceFilename, makeTraceFileName(ProgramName, AuxName));
path::append(ProfileDirname, makeProfileDirName(ProgramName, AuxName));
EnableStatistics(/*PrintOnExit=*/false);
SharedTimer::enableCompilationTimers();
if (TraceEvents || ProfileEvents || ProfileEntities)
LastTracedFrontendCounters.emplace();
if (TraceEvents)
Expand Down
17 changes: 0 additions & 17 deletions lib/Basic/Timer.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions lib/Frontend/ArgsToFrontendOptionsConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ void ArgsToFrontendOptionsConverter::computePrintStatsOptions() {

void ArgsToFrontendOptionsConverter::computeDebugTimeOptions() {
using namespace options;
Opts.DebugTimeCompilation |= Args.hasArg(OPT_debug_time_compilation);

if (const Arg *A = Args.getLastArg(OPT_stats_output_dir)) {
Opts.StatsOutputDir = A->getValue();
if (Args.getLastArg(OPT_trace_stats_events)) {
Expand Down
4 changes: 0 additions & 4 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include "swift/Basic/PrettyStackTrace.h"
#include "swift/Basic/SourceManager.h"
#include "swift/Basic/Statistic.h"
#include "swift/Basic/Timer.h"
#include "swift/Basic/UUID.h"
#include "swift/Frontend/DiagnosticVerifier.h"
#include "swift/Frontend/Frontend.h"
Expand Down Expand Up @@ -2232,9 +2231,6 @@ int swift::performFrontend(ArrayRef<const char *> Args,
PDC.setFormattingStyle(
Invocation.getDiagnosticOptions().PrintedFormattingStyle);

if (Invocation.getFrontendOptions().DebugTimeCompilation)
SharedTimer::enableCompilationTimers();

if (Invocation.getFrontendOptions().PrintStats) {
llvm::EnableStatistics();
}
Expand Down
1 change: 0 additions & 1 deletion lib/IRGen/IRGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "swift/Basic/Dwarf.h"
#include "swift/Basic/Platform.h"
#include "swift/Basic/Statistic.h"
#include "swift/Basic/Timer.h"
#include "swift/Basic/Version.h"
#include "swift/ClangImporter/ClangImporter.h"
#include "swift/ClangImporter/ClangModule.h"
Expand Down
1 change: 0 additions & 1 deletion lib/Parse/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "swift/AST/SourceFile.h"
#include "swift/Basic/Defer.h"
#include "swift/Basic/SourceManager.h"
#include "swift/Basic/Timer.h"
#include "swift/Parse/Lexer.h"
#include "swift/Parse/CodeCompletionCallbacks.h"
#include "swift/Parse/ParseSILSupport.h"
Expand Down
1 change: 0 additions & 1 deletion lib/SIL/Parser/ParseSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "swift/AST/SourceFile.h"
#include "swift/AST/TypeCheckRequests.h"
#include "swift/Basic/Defer.h"
#include "swift/Basic/Timer.h"
#include "swift/Demangling/Demangle.h"
#include "swift/Parse/Lexer.h"
#include "swift/Parse/ParseSILSupport.h"
Expand Down
1 change: 0 additions & 1 deletion lib/SILGen/SILGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "swift/AST/SourceFile.h"
#include "swift/AST/TypeCheckRequests.h"
#include "swift/Basic/Statistic.h"
#include "swift/Basic/Timer.h"
#include "swift/ClangImporter/ClangModule.h"
#include "swift/SIL/PrettyStackTrace.h"
#include "swift/SIL/SILArgument.h"
Expand Down
1 change: 0 additions & 1 deletion lib/Sema/TypeCheckCodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "swift/AST/TypeCheckRequests.h"
#include "swift/Basic/Statistic.h"
#include "swift/Basic/STLExtras.h"
#include "swift/Basic/Timer.h"
#include "swift/Parse/Lexer.h"
#include "swift/Sema/IDETypeChecking.h"
#include "swift/Strings.h"
Expand Down
1 change: 0 additions & 1 deletion lib/Sema/TypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "swift/AST/TypeCheckRequests.h"
#include "swift/Basic/Statistic.h"
#include "swift/Basic/STLExtras.h"
#include "swift/Basic/Timer.h"
#include "swift/Parse/Lexer.h"
#include "swift/Sema/IDETypeChecking.h"
#include "swift/Strings.h"
Expand Down
1 change: 0 additions & 1 deletion lib/Serialization/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "swift/Basic/Dwarf.h"
#include "swift/Basic/FileSystem.h"
#include "swift/Basic/STLExtras.h"
#include "swift/Basic/Timer.h"
#include "swift/Basic/Version.h"
#include "swift/ClangImporter/ClangImporter.h"
#include "swift/ClangImporter/ClangModule.h"
Expand Down