Skip to content

Commit d123092

Browse files
authored
Merge pull request #12432 from graydon/comment-counters
2 parents b53967f + 2d29292 commit d123092

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

include/swift/Basic/Statistics.def

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,37 @@
1818
// FRONTEND_STATISTIC(Subsystem, Id)
1919
// - Subsystem is a token to be stringified as a name prefix
2020
// - Id is an identifier suitable for use in C++
21+
//
22+
// FRONTEND_RECURSIVE_SHARED_TIMER(Id)
23+
// - Id is an identifier suitable for use in C++
24+
//
2125
//===----------------------------------------------------------------------===//
2226

2327
/// Driver statistics are collected for driver processes
2428
#ifdef DRIVER_STATISTIC
29+
30+
/// Total number of jobs (frontend, merge-modules, link, etc.) run by the
31+
/// driver. This should be some number less than the total number of files in
32+
/// the module in primary-files mode, and will likely just be 1 or 2 in WMO
33+
/// mode.
2534
DRIVER_STATISTIC(NumDriverJobsRun)
35+
36+
/// Total number of jobs (frontend, merge-modules, link, etc.) which _could_
37+
/// have been run by the driver, but that it decided to skip due to analysis of
38+
/// the dependency graph induced by .swiftdeps files. This, added together with
39+
/// the number of driver jobs run (above) should be relatively constant
40+
/// run-over-run.
2641
DRIVER_STATISTIC(NumDriverJobsSkipped)
2742

43+
/// Next 10 statistics count dirtying-events in the driver's dependency graph,
44+
/// which it uses to decide which files are invalid (and thus which files to
45+
/// build). There are two dimensions to each dirtying event:
46+
///
47+
/// - the type of dependency that caused the dirtying (top-level names, dynamic
48+
/// lookups, nominal type usage, member usage, or external-files)
49+
///
50+
/// - whether the dependency should "cascade" (transitively dirty the node's
51+
/// own downstream dependents, vs. just dirtying the node itself)
2852
DRIVER_STATISTIC(DriverDepCascadingTopLevel)
2953
DRIVER_STATISTIC(DriverDepCascadingDynamic)
3054
DRIVER_STATISTIC(DriverDepCascadingNominal)
@@ -37,46 +61,119 @@ DRIVER_STATISTIC(DriverDepNominal)
3761
DRIVER_STATISTIC(DriverDepMember)
3862
DRIVER_STATISTIC(DriverDepExternal)
3963

64+
/// Maximum Resident Set Size (roughly: physical memory actually used) by the
65+
/// tree of processes launched by the driver (i.e. the entire compilation).
4066
DRIVER_STATISTIC(ChildrenMaxRSS)
4167
#endif
4268

4369
/// Driver statistics are collected for frontend processes
4470
#ifdef FRONTEND_STATISTIC
71+
72+
/// Number of source buffers visible in the source manager.
4573
FRONTEND_STATISTIC(AST, NumSourceBuffers)
74+
75+
/// Total number of lines of source code (just by counting newlines) in all the
76+
/// source buffers visible in the source manager. Crude proxy for "project
77+
/// size".
4678
FRONTEND_STATISTIC(AST, NumSourceLines)
79+
80+
/// The NumSourceLines value of a frontend divided by the user-time of the
81+
/// frontend; stored and emitted separately so there's a precomputed value a
82+
/// user can grep-for to find a slow frontend.
4783
FRONTEND_STATISTIC(AST, NumSourceLinesPerSecond)
84+
85+
/// Number of libraries (including frameworks) linked against.
4886
FRONTEND_STATISTIC(AST, NumLinkLibraries)
87+
88+
/// Number of top-level modules loaded in the AST context.
4989
FRONTEND_STATISTIC(AST, NumLoadedModules)
90+
91+
/// Number of external definitions imported into the AST context.
5092
FRONTEND_STATISTIC(AST, NumImportedExternalDefinitions)
93+
94+
/// Number of Clang entities imported into the AST context.
5195
FRONTEND_STATISTIC(AST, NumTotalClangImportedEntities)
96+
97+
/// Number of bytes allocated in the AST's local arenas.
5298
FRONTEND_STATISTIC(AST, NumASTBytesAllocated)
99+
100+
/// Number of file-level dependencies of this frontend job, as tracked in the
101+
/// AST context's dependency collector.
53102
FRONTEND_STATISTIC(AST, NumDependencies)
103+
104+
/// Number of top-level, dynamic, and member names referenced in this frontend
105+
/// job's source file, as tracked by the AST context's referenced-name tracker.
54106
FRONTEND_STATISTIC(AST, NumReferencedTopLevelNames)
55107
FRONTEND_STATISTIC(AST, NumReferencedDynamicNames)
56108
FRONTEND_STATISTIC(AST, NumReferencedMemberNames)
109+
110+
/// Number of declarations in the AST context.
57111
FRONTEND_STATISTIC(AST, NumDecls)
112+
113+
/// Number of local type declarations in the AST context.
58114
FRONTEND_STATISTIC(AST, NumLocalTypeDecls)
115+
116+
/// Number of Objective-C declarations in the AST context.
59117
FRONTEND_STATISTIC(AST, NumObjCMethods)
118+
119+
/// Number of infix, postfix, and prefix operators in the AST context.
60120
FRONTEND_STATISTIC(AST, NumInfixOperators)
61121
FRONTEND_STATISTIC(AST, NumPostfixOperators)
62122
FRONTEND_STATISTIC(AST, NumPrefixOperators)
123+
124+
/// Number of precedence groups in the AST context.
63125
FRONTEND_STATISTIC(AST, NumPrecedenceGroups)
126+
127+
/// Number of conformances used by code processed by this frontend job.
64128
FRONTEND_STATISTIC(AST, NumUsedConformances)
65129

130+
/// Number of conformances that were deserialized by this frontend job.
66131
FRONTEND_STATISTIC(Sema, NumConformancesDeserialized)
132+
133+
/// Number of constraint-solving scopes created in the typechecker, while
134+
/// solving expression type constraints. A rough proxy for "how much work the
135+
/// expression typechecker did".
67136
FRONTEND_STATISTIC(Sema, NumConstraintScopes)
137+
138+
/// Number of declarations that were deserialized. A rough proxy for the amount
139+
/// of material loaded from other modules.
68140
FRONTEND_STATISTIC(Sema, NumDeclsDeserialized)
141+
142+
/// Number of declarations validated.
69143
FRONTEND_STATISTIC(Sema, NumDeclsValidated)
144+
145+
/// Number of full function bodies typechecked.
70146
FRONTEND_STATISTIC(Sema, NumFunctionsTypechecked)
147+
148+
/// Number of generic signature builders constructed. Rough proxy for
149+
/// amount of work the GSB does analyzing type signatures.
71150
FRONTEND_STATISTIC(Sema, NumGenericSignatureBuilders)
151+
152+
/// Number of lazy generic environments built.
72153
FRONTEND_STATISTIC(Sema, NumLazyGenericEnvironments)
154+
155+
/// Number of lazy generic environments deserialized.
73156
FRONTEND_STATISTIC(Sema, NumLazyGenericEnvironmentsLoaded)
157+
158+
/// Number of lazy iterable declaration contexts constructed.
74159
FRONTEND_STATISTIC(Sema, NumLazyIterableDeclContexts)
160+
161+
/// Number of direct member-name lookups performed on nominal types.
75162
FRONTEND_STATISTIC(Sema, NominalTypeLookupDirectCount)
163+
164+
/// Number of types deserialized.
76165
FRONTEND_STATISTIC(Sema, NumTypesDeserialized)
166+
167+
/// Number of types validated.
77168
FRONTEND_STATISTIC(Sema, NumTypesValidated)
169+
170+
/// Number of lazy iterable declaration contexts left unloaded.
78171
FRONTEND_STATISTIC(Sema, NumUnloadedLazyIterableDeclContexts)
79172

173+
/// The next 10 statistics count 5 kinds of SIL entities present
174+
/// after the SILGen and SILOpt phases. The entities are functions,
175+
/// vtables, witness tables, default witness tables and global
176+
/// variables.
80177
FRONTEND_STATISTIC(SILModule, NumSILGenFunctions)
81178
FRONTEND_STATISTIC(SILModule, NumSILGenVtables)
82179
FRONTEND_STATISTIC(SILModule, NumSILGenWitnessTables)
@@ -89,6 +186,10 @@ FRONTEND_STATISTIC(SILModule, NumSILOptWitnessTables)
89186
FRONTEND_STATISTIC(SILModule, NumSILOptDefaultWitnessTables)
90187
FRONTEND_STATISTIC(SILModule, NumSILOptGlobalVariables)
91188

189+
/// The next 9 statistics count kinds of LLVM entities produced
190+
/// during the IRGen phase: globals, functions, aliases, ifuncs,
191+
/// named metadata, value and comdat symbols, basic blocks,
192+
/// and instructions.
92193
FRONTEND_STATISTIC(IRModule, NumIRGlobals)
93194
FRONTEND_STATISTIC(IRModule, NumIRFunctions)
94195
FRONTEND_STATISTIC(IRModule, NumIRAliases)
@@ -99,11 +200,18 @@ FRONTEND_STATISTIC(IRModule, NumIRComdatSymbols)
99200
FRONTEND_STATISTIC(IRModule, NumIRBasicBlocks)
100201
FRONTEND_STATISTIC(IRModule, NumIRInsts)
101202

203+
/// Number of bytes written to the object-file output stream
204+
/// of the frontend job, which should be the same as the size of
205+
/// the .o file you find on disk after the frontend exits.
102206
FRONTEND_STATISTIC(LLVM, NumLLVMBytesOutput)
103207
#endif
104208

105209
/// Frontend timers for recursive routines
106210
#ifdef FRONTEND_RECURSIVE_SHARED_TIMER
211+
212+
/// Time spent in NominalTypeDecl::lookupDirect.
107213
FRONTEND_RECURSIVE_SHARED_TIMER(NominalTypeDecl__lookupDirect)
214+
215+
/// Time spent in ClangImporter::Implementation::loadAllMembers.
108216
FRONTEND_RECURSIVE_SHARED_TIMER(ClangImporter__Implementation__loadAllMembers)
109217
#endif

0 commit comments

Comments
 (0)