summaryrefslogtreecommitdiff
path: root/lldb/source/Core/Progress.cpp
AgeCommit message (Collapse)Author
2025-03-08[lldb] Remove progress report coalescing (#130329)Jonas Devlieghere
Remove support for coalescing progress reports in LLDB. This functionality was motivated by Xcode, which wanted to listen for less frequent, aggregated progress events at the cost of losing some detail. See the original RFC [1] for more details. Since then, they've reevaluated this trade-off and opted to listen for the regular, full fidelity progress events and do any post processing on their end. rdar://146425487
2025-01-06[LLDB] Add external progress bit category (#120171)Jacob Lalonde
As feedback on #119052, it was recommended I add a new bit to delineate internal and external progress events. This patch adds this new category, and sets up Progress.h to support external events via SBProgress.
2024-12-16[lldb] Add ability to rate-limit progress reports (#119377)Pavel Labath
For high-frequency multithreaded progress reports, the contention of taking the progress mutex and the overhead of generating event can significantly slow down the operation whose progress we are reporting. This patch adds an (optional) capability to rate-limit them. It's optional because this approach has one drawback: if the progress reporting has a pattern where it generates a burst of activity and then blocks (without reporting anything) for a large amount of time, it can appear as if less progress was made that it actually was (because we only reported the first event from the burst and dropped the other ones). I've also made a small refactor of the Progress class to better distinguish between const (don't need protection), atomic (are used on the hot path) and other (need mutex protection) members.
2024-10-15[lldb] Avoid repeated hash lookups (NFC) (#112471)Kazu Hirata
2024-09-13[lldb] Emit signpost intervals for progress events (NFC) (#108498)Jonas Devlieghere
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.
2024-08-07[lldb] Make sure that a `Progress` "completed" update is always reported at ↵royitaqi
destruction (#102097) Make all `Progress` destructions to cause `progressEnd` events, regardless of the value of `m_completed` before the destruction. Currently, a `Progress` instance with `m_completed != 0 && m_complete != m_total` will cause a `progressUpdate` event (not `progressEnd`) at destruction and. This contradicts with the classdoc: "a progress completed update is reported even if the user doesn't explicitly cause one to be sent."
2024-05-09[lldb][enums] Remove broadcast bits from debugger (#91618)Chelsea Cassanova
Removes the debugger broadcast bits from `Debugger.h` and instead uses the enum from `lldb-enumerations.h` and adds the `eBroadcastSymbolChange` bit to the enum in `lldb-enumerations.h`. This fixes a bug wherein the incorrect broadcast bit could be referenced due both of these enums previously existing and being out-of-sync with each other.
2024-03-26[lldb] Implement coalescing of disjoint progress events (#84854)Jonas Devlieghere
This implements coalescing of progress events using a timeout, as discussed in the RFC on Discourse [1]. This PR consists of two commits which, depending on the feedback, I may split up into two PRs. For now, I think it's easier to review this as a whole. 1. The first commit introduces a new generic `Alarm` class. The class lets you to schedule a function (callback) to be executed after a given timeout expires. You can cancel and reset a callback before its corresponding timeout expires. It achieves this with the help of a worker thread that sleeps until the next timeout expires. The only guarantee it provides is that your function is called no sooner than the requested timeout. Because the callback is called directly from the worker thread, a long running callback could potentially block the worker thread. I intentionally kept the implementation as simple as possible while addressing the needs for the `ProgressManager` use case. If we want to rely on this somewhere else, we can reassess whether we need to address those limitations. 2. The second commit uses the Alarm class to coalesce progress events. To recap the Discourse discussion, when multiple progress events with the same title execute in close succession, they get broadcast as one to `eBroadcastBitProgressCategory`. The `ProgressManager` keeps track of the in-flight progress events and when the refcount hits zero, the Alarm class is used to schedule broadcasting the event. If a new progress event comes in before the alarm fires, the alarm is reset (and the process repeats when the new progress event ends). If no new event comes in before the timeout expires, the progress event is broadcast. [1] https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717/
2024-03-25Revert "[lldb] Implement coalescing of disjoint progress events (#84854)"Jonas Devlieghere
This reverts commit 930f64689c1fb487714c3836ffa43e49e46aa488 as it's failing on the Linux bots.
2024-03-25[lldb] Implement coalescing of disjoint progress events (#84854)Jonas Devlieghere
This implements coalescing of progress events using a timeout, as discussed in the RFC on Discourse [1]. This PR consists of two commits which, depending on the feedback, I may split up into two PRs. For now, I think it's easier to review this as a whole. 1. The first commit introduces a new generic `Alarm` class. The class lets you to schedule a function (callback) to be executed after a given timeout expires. You can cancel and reset a callback before its corresponding timeout expires. It achieves this with the help of a worker thread that sleeps until the next timeout expires. The only guarantee it provides is that your function is called no sooner than the requested timeout. Because the callback is called directly from the worker thread, a long running callback could potentially block the worker thread. I intentionally kept the implementation as simple as possible while addressing the needs for the `ProgressManager` use case. If we want to rely on this somewhere else, we can reassess whether we need to address those limitations. 2. The second commit uses the Alarm class to coalesce progress events. To recap the Discourse discussion, when multiple progress events with the same title execute in close succession, they get broadcast as one to `eBroadcastBitProgressCategory`. The `ProgressManager` keeps track of the in-flight progress events and when the refcount hits zero, the Alarm class is used to schedule broadcasting the event. If a new progress event comes in before the alarm fires, the alarm is reset (and the process repeats when the new progress event ends). If no new event comes in before the timeout expires, the progress event is broadcast. [1] https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717/
2024-03-07[lldb] Don't report all progress event as completed. (#84281)Jonas Devlieghere
Currently, progress events reported by the ProgressManager and broadcast to eBroadcastBitProgressCategory always specify they're complete. The problem is that the ProgressManager reports kNonDeterministicTotal for both the total and the completed number of (sub)events. Because the values are the same, the event reports itself as complete. This patch fixes the issue by reporting 0 as the completed value for the start event and kNonDeterministicTotal for the end event.
2024-03-01[lldb][progress] Hook up new broadcast bit and progress manager (#83069)Chelsea Cassanova
This commit adds the functionality to broadcast events using the `Debugger::eBroadcastProgressCategory` bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these reports with the `ProgressManager` class (https://github.com/llvm/llvm-project/pull/81319). The new bit is used in such a way that it will only broadcast the initial and final progress reports for specific progress categories that are managed by the progress manager. This commit also adds a new test to the progress report unit test that checks that only the initial/final reports are broadcasted when using the new bit.
2024-02-15[lldb][progress] Add progress manager class (#81319)Chelsea Cassanova
Per discussions from https://github.com/llvm/llvm-project/pull/81026, it was decided that having a class that manages a map of progress reports would be beneficial in order to categorize them. This class is a part of the overall `Progress` class and utilizes a map that keeps a count of how many times a progress report category has been sent. This would be used with the new debugger broadcast bit added in https://github.com/llvm/llvm-project/pull/81169 so that a user listening with that bit will receive grouped progress reports.
2024-01-30[lldb][progress] Correctly check total for deterministic progress (#79912)Chelsea Cassanova
The `total` parameter for the constructor for Progress was changed to a std::optional in https://github.com/llvm/llvm-project/pull/77547. It was originally set to 1 to indicate non-determinisitic progress, but this commit changes this. First, `UINT64_MAX` will again be used for non-deterministic progress, and `Progress` now has a static variable set to this value so that we can use this instead of a magic number. The member variable `m_total` could be changed to a std::optional as well, but this means that the `ProgressEventData::GetTotal()` (which is used for the public API) would either need to return a std::optional value or it would return some specific integer to represent non-deterministic progress if `m_total` is std::nullopt.
2024-01-16[lldb][Progress] Separate title and details (#77547)Chelsea Cassanova
Per this RFC: https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717 on improving progress reports, this commit separates the title field and details field so that the title specifies the category that the progress report falls under. The details field is added as a part of the constructor for progress reports and by default is an empty string. In addition, changes the total amount of progress completed into a std::optional. Also updates the test to check for details being correctly reported from the event structured data dictionary.
2023-11-28[lldb][progress] Always report progress upon Progress object destruction ↵Chelsea Cassanova
(#73605) This commit allows a final progress report upon the destruction of the `Progress` object to happen at all times as opposed to when the progress was not completed.
2023-06-16Revert "[lldb] Rate limit progress reports -- different approach [WIP-ish]"Pavel Labath
This reverts commit c30853460da7446f92bc1e516f9cbe2c5df6e136, which I pushed accidentally -- sorry.
2023-06-16[lldb] Rate limit progress reports -- different approach [WIP-ish]Pavel Labath
Have the Progress class spawn a thread to periodically send progress reports. The reporting period could be made configurable, but for now I've hardcoded it to 100ms. (This is the main WIP part) It could be argued that creating a thread for progress reporting adds overhead, but I would counter that by saying "If the task is so fast that creating a thread noticably slows it down, then it really doesn't need progress reporting". For me, this speeds up DWARF indexing by about 1.5% (which is only slightly above the error bars), but I expect it will have a much bigger impact in situations where printing a single progress update takes a nontrivial amount of time. Differential Revision: https://reviews.llvm.org/D152364
2023-02-12[lldb] Add the ability to provide a message to a progress event updateJonas Devlieghere
Consider the following example as motivation. Say you have to load symbols for 3 dynamic libraries: `libFoo`, `libBar` and `libBaz`. Currently, there are two ways to report process for this operation: 1. As 3 separate progress instances. In this case you create a progress instance with the message "Loading symbols: libFoo", "Loading symbols: libBar", and "Loading symbols: libBaz" respectively. Each progress event gets a unique ID and therefore cannot be correlated by the consumer. 2. As 1 progress instance with 3 units of work. The title would be "Loading symbols" and you call Progress::Increment for each of the libraries. The 3 progress events share the same ID and can easily be correlated, however, in the current design, there's no way to include the name of the libraries. The second approach is preferred when the amount of work is known in advance, because determinate progress can be reported (i.e. x out of y operations completed). An additional benefit is that the progress consumer can decide to ignore certain progress updates by their ID if they are deemed to noisy, which isn't trivial for the first approach due to the use of different progress IDs. This patch adds the ability to add a message (detail) to a progress event update. For the example described above, progress can now be displayed as shown: [1/3] Loading symbols: libFoo [2/3] Loading symbols: libBar [3/3] Loading symbols: libBaz Differential revision: https://reviews.llvm.org/D143690
2021-03-24Add a progress class that can track long running operations in LLDB.Greg Clayton
LLDB can often appear deadlocked to users that use IDEs when it is indexing DWARF, or parsing symbol tables. These long running operations can make a debug session appear to be doing nothing even though a lot of work is going on inside LLDB. This patch adds a public API to allow clients to listen to debugger events that report progress and will allow UI to create an activity window or display that can show users what is going on and keep them informed of expensive operations that are going on inside LLDB. Differential Revision: https://reviews.llvm.org/D97739