aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2024-09-13 13:42:55 -0700
committerGitHub <noreply@github.com>2024-09-13 13:42:55 -0700
commit90f077cba8f41a2ba0eb8ffebed8da48322ed0d7 (patch)
treed21884d2de5be83a4f4f1a15be354dd78493dc70
parent1b4aea601d3e891a2b04ff35b9749c7fbec6503e (diff)
downloadllvm-90f077cba8f41a2ba0eb8ffebed8da48322ed0d7.zip
llvm-90f077cba8f41a2ba0eb8ffebed8da48322ed0d7.tar.gz
llvm-90f077cba8f41a2ba0eb8ffebed8da48322ed0d7.tar.bz2
[lldb] Emit signpost intervals for progress events (NFC) (#108498)
Emit signpost intervals for progress events so that when users report an operation takes a long time, we can investigate the issue with Instruments.app.
-rw-r--r--lldb/source/Core/Progress.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp
index e0ba1a6..27774ce 100644
--- a/lldb/source/Core/Progress.cpp
+++ b/lldb/source/Core/Progress.cpp
@@ -10,6 +10,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Utility/StreamString.h"
+#include "llvm/Support/Signposts.h"
#include <cstdint>
#include <mutex>
@@ -20,6 +21,9 @@ using namespace lldb_private;
std::atomic<uint64_t> Progress::g_id(0);
+// Instrument progress events with signposts when supported.
+static llvm::ManagedStatic<llvm::SignpostEmitter> g_progress_signposts;
+
Progress::Progress(std::string title, std::string details,
std::optional<uint64_t> total,
lldb_private::Debugger *debugger)
@@ -39,9 +43,15 @@ Progress::Progress(std::string title, std::string details,
// Report to the ProgressManager if that subsystem is enabled.
if (ProgressManager::Enabled())
ProgressManager::Instance().Increment(m_progress_data);
+
+ // Start signpost interval right before the meaningful work starts.
+ g_progress_signposts->startInterval(this, m_progress_data.title);
}
Progress::~Progress() {
+ // End signpost interval as soon as possible.
+ g_progress_signposts->endInterval(this, m_progress_data.title);
+
// Make sure to always report progress completed when this object is
// destructed so it indicates the progress dialog/activity should go away.
std::lock_guard<std::mutex> guard(m_mutex);