[Lldb-commits] [lldb] [lldb] Emit signpost intervals for progress events (NFC) (PR #108498)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 12 22:52:02 PDT 2024


https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/108498

>From d15881207001934ff83934fae9cdeb52f61eaf6f Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Thu, 12 Sep 2024 22:43:40 -0700
Subject: [PATCH] [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.
---
 lldb/source/Core/Progress.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lldb/source/Core/Progress.cpp b/lldb/source/Core/Progress.cpp
index e0ba1a63c508e5..27774ce7a5521b 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);



More information about the lldb-commits mailing list