-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb-dap] Speed up TestDAP_Progress #134048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) ChangesWhile trying to make progress on #133782, I noticed that TestDAP_Progress was taking 90 seconds to complete. This patch brings that down to 10 seocnds by making the following changes:
Full diff: https://github.com/llvm/llvm-project/pull/134048.diff 2 Files Affected:
diff --git a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
index 445d1bdf4e496..33dee33e28b23 100644
--- a/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
+++ b/lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
@@ -38,8 +38,8 @@ def create_options(cls):
parser.add_option(
"--total",
- dest="total",
- help="Total items in this progress object. When this option is not specified, this will be an indeterminate progress.",
+ dest="total", help="Total items in this progress object. When this
+ option is not specified, this will be an indeterminate progress.",
type="int",
default=None,
)
@@ -88,11 +88,11 @@ def __call__(self, debugger, command, exe_ctx, result):
progress = lldb.SBProgress(
"Progress tester", "Initial Detail", total, debugger
)
- # Check to see if total is set to None to indicate an indeterminate progress
- # then default to 10 steps.
+ # Check to see if total is set to None to indicate an indeterminate
+ # progress then default to 3 steps.
with progress:
if total is None:
- total = 10
+ total = 3
for i in range(1, total):
if cmd_options.no_details:
diff --git a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
index f723a2d254825..ffe3d38eb49a3 100755
--- a/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
+++ b/lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py
@@ -19,7 +19,6 @@ def verify_progress_events(
expected_not_in_message=None,
only_verify_first_update=False,
):
- self.dap_server.wait_for_event("progressEnd", 15)
self.assertTrue(len(self.dap_server.progress_events) > 0)
start_found = False
update_found = False
@@ -45,20 +44,18 @@ def verify_progress_events(
self.assertTrue(start_found)
self.assertTrue(update_found)
self.assertTrue(end_found)
+ self.dap_server.progress_events.clear()
@skipIfWindows
- def test_output(self):
+ def test(self):
program = self.getBuildArtifact("a.out")
self.build_and_launch(program)
progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
- source = "main.cpp"
- breakpoint_ids = self.set_source_breakpoints(
- source, [line_number(source, "// break here")]
- )
- self.continue_to_breakpoints(breakpoint_ids)
self.dap_server.request_evaluate(
f"`command script import {progress_emitter}", context="repl"
)
+
+ # Test details.
self.dap_server.request_evaluate(
"`test-progress --total 3 --seconds 1", context="repl"
)
@@ -68,19 +65,7 @@ def test_output(self):
expected_not_in_message="Progress tester",
)
- @skipIfWindows
- def test_output_nodetails(self):
- program = self.getBuildArtifact("a.out")
- self.build_and_launch(program)
- progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
- source = "main.cpp"
- breakpoint_ids = self.set_source_breakpoints(
- source, [line_number(source, "// break here")]
- )
- self.continue_to_breakpoints(breakpoint_ids)
- self.dap_server.request_evaluate(
- f"`command script import {progress_emitter}", context="repl"
- )
+ # Test no details.
self.dap_server.request_evaluate(
"`test-progress --total 3 --seconds 1 --no-details", context="repl"
)
@@ -90,19 +75,7 @@ def test_output_nodetails(self):
expected_message="Initial Detail",
)
- @skipIfWindows
- def test_output_indeterminate(self):
- program = self.getBuildArtifact("a.out")
- self.build_and_launch(program)
- progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
- source = "main.cpp"
- breakpoint_ids = self.set_source_breakpoints(
- source, [line_number(source, "// break here")]
- )
- self.continue_to_breakpoints(breakpoint_ids)
- self.dap_server.request_evaluate(
- f"`command script import {progress_emitter}", context="repl"
- )
+ # Test details indeterminate.
self.dap_server.request_evaluate("`test-progress --seconds 1", context="repl")
self.verify_progress_events(
@@ -111,19 +84,7 @@ def test_output_indeterminate(self):
only_verify_first_update=True,
)
- @skipIfWindows
- def test_output_nodetails_indeterminate(self):
- program = self.getBuildArtifact("a.out")
- self.build_and_launch(program)
- progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
- source = "main.cpp"
- breakpoint_ids = self.set_source_breakpoints(
- source, [line_number(source, "// break here")]
- )
- self.dap_server.request_evaluate(
- f"`command script import {progress_emitter}", context="repl"
- )
-
+ # Test no details indeterminate.
self.dap_server.request_evaluate(
"`test-progress --seconds 1 --no-details", context="repl"
)
|
While trying to make progress on llvm#133782, I noticed that TestDAP_Progress was taking 90 seconds to complete. This patch brings that down to 10 seocnds by making the following changes: 1. Don't call `wait_for_event` with a 15 second timeout. By the time we call this, all progress events have been emitted, which means that we're just sitting there until we hit the timeout. 2. Don't use 10 steps (= 10 seconds) for indeterminate progress. We have two indeterminate progress tests so that's 6 seconds instead of 20. 3. Don't launch the process over and over. Once we have a dap session, we can clear the progress vector and emit new progress events.
b2e6660
to
960aefe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for fixing
I wonder if there's a potential race between lldb emitting the last progress event and lldb-dap ingesting it. If we see that this test becomes flakey, we can add the |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/13904 Here is the relevant piece of the build log for the reference
|
It looks like the test may indeed be flakey. It looks like it hit a failure on And also failed on I am unable to reproduce the failure locally on x86_64 linux. |
Alright, let me add |
Before llvm#134048, TestDAP_Progress would wait up to 15 seconds before checking whether the events came in. Now the test is a lot faster, but we risk checking the events before they've all arrived. Make up to 10 attempts to find the end event, with a 100ms sleep in between, giving the test up to a second for the event to arrive after it has been broadcast.
I ended up addressing this slightly differently because I really hate the idea of waiting on an event we already received: #134157 |
Before llvm#134048, TestDAP_Progress relied on wait_for_event to block until the progressEnd came in. However, progress events were not added to the packet list, so this call would always time out. This PR makes it so that packets are added to the packet list, and you can block on them.
Before #134048, TestDAP_Progress relied on wait_for_event to block until the progressEnd came in. However, progress events were not added to the packet list, so this call would always time out. This PR makes it so that packets are added to the packet list, and you can block on them.
While trying to make progress on #133782, I noticed that TestDAP_Progress was taking 90 seconds to complete. This patch brings that down to 10 seocnds by making the following changes:
Don't call
wait_for_event
with a 15 second timeout. By the time we call this, all progress events have been emitted, which means that we're just sitting there until we hit the timeout.Don't use 10 steps (= 10 seconds) for indeterminate progress. We have two indeterminate progress tests so that's 6 seconds instead of 20.
Don't launch the process over and over. Once we have a dap session, we can clear the progress vector and emit new progress events.