Skip to content

Commit 80d1c6a

Browse files
authored
Revert "[clang-doc] add ftime profiling" (#100251)
This broke the build due to failing some clang-tidy checks: https://lab.llvm.org/buildbot/#/builders/145/builds/789
1 parent 61dcc9f commit 80d1c6a

File tree

6 files changed

+9
-70
lines changed

6 files changed

+9
-70
lines changed

clang-tools-extra/clang-doc/BitcodeReader.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "BitcodeReader.h"
1010
#include "llvm/ADT/IndexedMap.h"
1111
#include "llvm/Support/Error.h"
12-
#include "llvm/Support/TimeProfiler.h"
1312
#include "llvm/Support/raw_ostream.h"
1413
#include <optional>
1514

@@ -671,7 +670,6 @@ llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, T I) {
671670

672671
template <>
673672
llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, Reference *I) {
674-
llvm::TimeTraceScope("Reducing infos", "readRecord");
675673
Record R;
676674
llvm::StringRef Blob;
677675
llvm::Expected<unsigned> MaybeRecID = Stream.readRecord(ID, R, &Blob);
@@ -683,7 +681,6 @@ llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, Reference *I) {
683681
// Read a block of records into a single info.
684682
template <typename T>
685683
llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) {
686-
llvm::TimeTraceScope("Reducing infos", "readBlock");
687684
if (llvm::Error Err = Stream.EnterSubBlock(ID))
688685
return Err;
689686

@@ -714,7 +711,6 @@ llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) {
714711

715712
template <typename T>
716713
llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) {
717-
llvm::TimeTraceScope("Reducing infos", "readSubBlock");
718714
switch (ID) {
719715
// Blocks can only have certain types of sub blocks.
720716
case BI_COMMENT_BLOCK_ID: {
@@ -821,7 +817,6 @@ llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) {
821817

822818
ClangDocBitcodeReader::Cursor
823819
ClangDocBitcodeReader::skipUntilRecordOrBlock(unsigned &BlockOrRecordID) {
824-
llvm::TimeTraceScope("Reducing infos", "skipUntilRecordOrBlock");
825820
BlockOrRecordID = 0;
826821

827822
while (!Stream.AtEndOfStream()) {
@@ -883,7 +878,6 @@ llvm::Error ClangDocBitcodeReader::validateStream() {
883878
}
884879

885880
llvm::Error ClangDocBitcodeReader::readBlockInfoBlock() {
886-
llvm::TimeTraceScope("Reducing infos", "readBlockInfoBlock");
887881
Expected<std::optional<llvm::BitstreamBlockInfo>> MaybeBlockInfo =
888882
Stream.ReadBlockInfoBlock();
889883
if (!MaybeBlockInfo)
@@ -900,7 +894,6 @@ llvm::Error ClangDocBitcodeReader::readBlockInfoBlock() {
900894
template <typename T>
901895
llvm::Expected<std::unique_ptr<Info>>
902896
ClangDocBitcodeReader::createInfo(unsigned ID) {
903-
llvm::TimeTraceScope("Reducing infos", "createInfo");
904897
std::unique_ptr<Info> I = std::make_unique<T>();
905898
if (auto Err = readBlock(ID, static_cast<T *>(I.get())))
906899
return std::move(Err);
@@ -909,7 +902,6 @@ ClangDocBitcodeReader::createInfo(unsigned ID) {
909902

910903
llvm::Expected<std::unique_ptr<Info>>
911904
ClangDocBitcodeReader::readBlockToInfo(unsigned ID) {
912-
llvm::TimeTraceScope("Reducing infos", "readBlockToInfo");
913905
switch (ID) {
914906
case BI_NAMESPACE_BLOCK_ID:
915907
return createInfo<NamespaceInfo>(ID);

clang-tools-extra/clang-doc/HTMLGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ static llvm::Error serializeIndex(ClangDocContext &CDCtx) {
983983
llvm::json::OStream J(OS, 2);
984984
std::function<void(Index)> IndexToJSON = [&](const Index &I) {
985985
J.object([&] {
986-
J.attribute("USR", toHex(llvm::toStringRef(I.USR)));
986+
//J.attribute("USR", toHex(llvm::toStringRef(I.USR)));
987987
J.attribute("Name", I.Name);
988988
J.attribute("RefType", getRefType(I.RefType));
989989
J.attribute("Path", I.getRelativeFilePath(""));

clang-tools-extra/clang-doc/Mapper.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,12 @@
1313
#include "clang/Index/USRGeneration.h"
1414
#include "llvm/ADT/StringExtras.h"
1515
#include "llvm/Support/Error.h"
16-
#include "llvm/Support/TimeProfiler.h"
1716

1817
namespace clang {
1918
namespace doc {
2019

2120
void MapASTVisitor::HandleTranslationUnit(ASTContext &Context) {
22-
if (CDCtx.FTimeTrace)
23-
llvm::timeTraceProfilerInitialize(200, "clang-doc");
2421
TraverseDecl(Context.getTranslationUnitDecl());
25-
if (CDCtx.FTimeTrace)
26-
llvm::timeTraceProfilerFinishThread();
2722
}
2823

2924
template <typename T> bool MapASTVisitor::mapDecl(const T *D) {
@@ -35,7 +30,6 @@ template <typename T> bool MapASTVisitor::mapDecl(const T *D) {
3530
if (D->getParentFunctionOrMethod())
3631
return true;
3732

38-
llvm::timeTraceProfilerBegin("Mapping declaration", "emit info from astnode");
3933
llvm::SmallString<128> USR;
4034
// If there is an error generating a USR for the decl, skip this decl.
4135
if (index::generateUSRForDecl(D, USR))
@@ -46,10 +40,7 @@ template <typename T> bool MapASTVisitor::mapDecl(const T *D) {
4640
auto I = serialize::emitInfo(D, getComment(D, D->getASTContext()),
4741
getLine(D, D->getASTContext()), File,
4842
IsFileInRootDir, CDCtx.PublicOnly);
49-
llvm::timeTraceProfilerEnd();
5043

51-
llvm::timeTraceProfilerBegin("Mapping declaration",
52-
"serialized info into bitcode");
5344
// A null in place of I indicates that the serializer is skipping this decl
5445
// for some reason (e.g. we're only reporting public decls).
5546
if (I.first)
@@ -58,7 +49,6 @@ template <typename T> bool MapASTVisitor::mapDecl(const T *D) {
5849
if (I.second)
5950
CDCtx.ECtx->reportResult(llvm::toHex(llvm::toStringRef(I.second->USR)),
6051
serialize::serialize(I.second));
61-
llvm::timeTraceProfilerEnd();
6252
return true;
6353
}
6454

clang-tools-extra/clang-doc/Representation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,9 @@ ClangDocContext::ClangDocContext(tooling::ExecutionContext *ECtx,
368368
StringRef ProjectName, bool PublicOnly,
369369
StringRef OutDirectory, StringRef SourceRoot,
370370
StringRef RepositoryUrl,
371-
std::vector<std::string> UserStylesheets,
372-
bool FTimeTrace)
371+
std::vector<std::string> UserStylesheets)
373372
: ECtx(ECtx), ProjectName(ProjectName), PublicOnly(PublicOnly),
374-
OutDirectory(OutDirectory), UserStylesheets(UserStylesheets),
375-
FTimeTrace(FTimeTrace) {
373+
OutDirectory(OutDirectory), UserStylesheets(UserStylesheets) {
376374
llvm::SmallString<128> SourceRootDir(SourceRoot);
377375
if (SourceRoot.empty())
378376
// If no SourceRoot was provided the current path is used as the default

clang-tools-extra/clang-doc/Representation.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,10 @@ struct ClangDocContext {
482482
ClangDocContext(tooling::ExecutionContext *ECtx, StringRef ProjectName,
483483
bool PublicOnly, StringRef OutDirectory, StringRef SourceRoot,
484484
StringRef RepositoryUrl,
485-
std::vector<std::string> UserStylesheets,
486-
bool FTimeTrace = false);
485+
std::vector<std::string> UserStylesheets);
487486
tooling::ExecutionContext *ECtx;
488487
std::string ProjectName; // Name of project clang-doc is documenting.
489488
bool PublicOnly; // Indicates if only public declarations are documented.
490-
bool FTimeTrace; // Indicates if ftime trace is turned on
491-
int Granularity; // Granularity of ftime trace
492489
std::string OutDirectory; // Directory for outputting generated files.
493490
std::string SourceRoot; // Directory where processed files are stored. Links
494491
// to definition locations will only be generated if

clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#include "llvm/Support/Process.h"
4242
#include "llvm/Support/Signals.h"
4343
#include "llvm/Support/ThreadPool.h"
44-
#include "llvm/Support/TimeProfiler.h"
4544
#include "llvm/Support/raw_ostream.h"
4645
#include <atomic>
4746
#include <mutex>
@@ -100,11 +99,6 @@ URL of repository that hosts code.
10099
Used for links to definition locations.)"),
101100
llvm::cl::cat(ClangDocCategory));
102101

103-
static llvm::cl::opt<bool> FTimeTrace("ftime-trace", llvm::cl::desc(R"(
104-
Turn on time profiler. Generates clang-doc-tracing.json)"),
105-
llvm::cl::init(false),
106-
llvm::cl::cat(ClangDocCategory));
107-
108102
enum OutputFormatTy {
109103
md,
110104
yaml,
@@ -235,12 +229,6 @@ Example usage for a project using a compile commands database:
235229
return 1;
236230
}
237231

238-
// turns on ftime trace profiling
239-
if (FTimeTrace)
240-
llvm::timeTraceProfilerInitialize(200, "clang-doc");
241-
242-
llvm::TimeTraceScope("main");
243-
244232
// Fail early if an invalid format was provided.
245233
std::string Format = getFormatString();
246234
llvm::outs() << "Emiting docs in " << Format << " format.\n";
@@ -264,8 +252,8 @@ Example usage for a project using a compile commands database:
264252
OutDirectory,
265253
SourceRoot,
266254
RepositoryUrl,
267-
{UserStylesheets.begin(), UserStylesheets.end()},
268-
FTimeTrace};
255+
{UserStylesheets.begin(), UserStylesheets.end()}
256+
};
269257

270258
if (Format == "html") {
271259
if (auto Err = getHtmlAssetFiles(argv[0], CDCtx)) {
@@ -274,7 +262,6 @@ Example usage for a project using a compile commands database:
274262
}
275263
}
276264

277-
llvm::timeTraceProfilerBegin("Mapping declaration", "total runtime");
278265
// Mapping phase
279266
llvm::outs() << "Mapping decls...\n";
280267
auto Err =
@@ -289,28 +276,24 @@ Example usage for a project using a compile commands database:
289276
return 1;
290277
}
291278
}
292-
llvm::timeTraceProfilerEnd();
293279

294280
// Collect values into output by key.
295281
// In ToolResults, the Key is the hashed USR and the value is the
296282
// bitcode-encoded representation of the Info object.
297-
llvm::timeTraceProfilerBegin("Collect Info", "total runtime");
298283
llvm::outs() << "Collecting infos...\n";
299284
llvm::StringMap<std::vector<StringRef>> USRToBitcode;
300285
Executor->get()->getToolResults()->forEachResult(
301286
[&](StringRef Key, StringRef Value) {
302287
auto R = USRToBitcode.try_emplace(Key, std::vector<StringRef>());
303288
R.first->second.emplace_back(Value);
304289
});
305-
llvm::timeTraceProfilerEnd();
306290

307291
// Collects all Infos according to their unique USR value. This map is added
308292
// to from the thread pool below and is protected by the USRToInfoMutex.
309293
llvm::sys::Mutex USRToInfoMutex;
310294
llvm::StringMap<std::unique_ptr<doc::Info>> USRToInfo;
311295

312296
// First reducing phase (reduce all decls into one info per decl).
313-
llvm::timeTraceProfilerBegin("Reducing infos", "total runtime");
314297
llvm::outs() << "Reducing " << USRToBitcode.size() << " infos...\n";
315298
std::atomic<bool> Error;
316299
Error = false;
@@ -319,11 +302,8 @@ Example usage for a project using a compile commands database:
319302
llvm::DefaultThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency));
320303
for (auto &Group : USRToBitcode) {
321304
Pool.async([&]() {
322-
if (FTimeTrace)
323-
llvm::timeTraceProfilerInitialize(200, "clang-doc");
324-
325-
llvm::timeTraceProfilerBegin("Reducing infos", "decoding bitcode");
326305
std::vector<std::unique_ptr<doc::Info>> Infos;
306+
327307
for (auto &Bitcode : Group.getValue()) {
328308
llvm::BitstreamCursor Stream(Bitcode);
329309
doc::ClangDocBitcodeReader Reader(Stream);
@@ -336,40 +316,32 @@ Example usage for a project using a compile commands database:
336316
std::move(ReadInfos->begin(), ReadInfos->end(),
337317
std::back_inserter(Infos));
338318
}
339-
llvm::timeTraceProfilerEnd();
340319

341-
llvm::timeTraceProfilerBegin("Reducing infos", "merging bitcode");
342320
auto Reduced = doc::mergeInfos(Infos);
343321
if (!Reduced) {
344322
llvm::errs() << llvm::toString(Reduced.takeError());
345323
return;
346324
}
347-
llvm::timeTraceProfilerEnd();
348325

349326
// Add a reference to this Info in the Index
350327
{
351328
std::lock_guard<llvm::sys::Mutex> Guard(IndexMutex);
352329
clang::doc::Generator::addInfoToIndex(CDCtx.Idx, Reduced.get().get());
353330
}
354-
// Save in the result map (needs a lock due to threaded access).
355331

332+
// Save in the result map (needs a lock due to threaded access).
356333
{
357334
std::lock_guard<llvm::sys::Mutex> Guard(USRToInfoMutex);
358335
USRToInfo[Group.getKey()] = std::move(Reduced.get());
359336
}
360-
361-
if (CDCtx.FTimeTrace)
362-
llvm::timeTraceProfilerFinishThread();
363337
});
364338
}
365-
llvm::timeTraceProfilerEnd();
366339

367340
Pool.wait();
368341

369342
if (Error)
370343
return 1;
371344

372-
llvm::timeTraceProfilerBegin("Writing output", "total runtime");
373345
// Ensure the root output directory exists.
374346
if (std::error_code Err = llvm::sys::fs::create_directories(OutDirectory);
375347
Err != std::error_code()) {
@@ -390,16 +362,6 @@ Example usage for a project using a compile commands database:
390362
if (Err) {
391363
llvm::outs() << "warning: " << toString(std::move(Err)) << "\n";
392364
}
393-
llvm::timeTraceProfilerEnd();
394-
395-
if (FTimeTrace) {
396-
std::error_code EC;
397-
llvm::raw_fd_ostream OS("clang-doc-tracing.json", EC,
398-
llvm::sys::fs::OF_Text);
399-
if (!EC)
400-
llvm::timeTraceProfilerWrite(OS);
401-
else
402-
return 1;
403-
}
365+
404366
return 0;
405367
}

0 commit comments

Comments
 (0)