Skip to content

Commit 6009606

Browse files
committed
[lldb] Emit signpost intervals for progress events (NFC)
Emit signpost intervals for progress events so that when users report an operation takes a long time, we can see investigate the issue with Instruments.
1 parent 7ba4968 commit 6009606

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lldb/source/Core/Progress.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "lldb/Core/Debugger.h"
1212
#include "lldb/Utility/StreamString.h"
13+
#include "llvm/Support/Signposts.h"
1314

1415
#include <cstdint>
1516
#include <mutex>
@@ -20,6 +21,9 @@ using namespace lldb_private;
2021

2122
std::atomic<uint64_t> Progress::g_id(0);
2223

24+
// Instrument progress events with singposts when supported.
25+
static llvm::ManagedStatic<llvm::SignpostEmitter> g_progress_signposts;
26+
2327
Progress::Progress(std::string title, std::string details,
2428
std::optional<uint64_t> total,
2529
lldb_private::Debugger *debugger)
@@ -39,9 +43,15 @@ Progress::Progress(std::string title, std::string details,
3943
// Report to the ProgressManager if that subsystem is enabled.
4044
if (ProgressManager::Enabled())
4145
ProgressManager::Instance().Increment(m_progress_data);
46+
47+
// Start signpost interval right before the meaningful work starts.
48+
g_progress_signposts->startInterval(this, m_progress_data.title);
4249
}
4350

4451
Progress::~Progress() {
52+
// End signpost interval as soon as possible.
53+
g_progress_signposts->endInterval(this, m_progress_data.title);
54+
4555
// Make sure to always report progress completed when this object is
4656
// destructed so it indicates the progress dialog/activity should go away.
4757
std::lock_guard<std::mutex> guard(m_mutex);

0 commit comments

Comments
 (0)