Skip to content

🍒[lldb] Cherry-pick Task pointer fixes for caching and captured variable diagnostics #10926

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

Merged

Conversation

felipepiovezan
Copy link

No description provided.

…tTasks

Obtaining the TLS from debugserver over a wired (or slower) conection
was identified as a major source of slowdown after introducing
OperatingSystemSwiftTasks. This is due to multiple memory reads being
necessary:

1. Memory reads to obtain auxiliary information from libpthread that is
   then sent to the jThreadExtendedInfo packet. See
   "plo_pthread_tsd_base_address_offset","plo_pthread_tsd_base_offset"
   and "plo_pthread_tsd_entry_size".
2. A packet requesting jThreadExtendedInfo.

Both 1 and 2 are done per thread, on every stop. However, there is
strong evidence that we can safely cache the TLS pointer after a certain
point in the thread lifetime, which is what this patch accomplishes.

Caching is done at the OperatingSystemSwiftTasks level, not at the
core Thread class. This is done for two reasons:

1. To minimize the surface area / risk of this change.
2. jThreadExtendedInfo can produce an invalid TLS address earlier in the
   thread lifetime, so we can only cache this if a memory read at that
   location is successful.

On local testing over a wired connection, this reduces stepping time by
about 100ms, from an average of 300ms.

(cherry picked from commit 306407b)
This is a useful fallback for debugging.

(cherry picked from commit ae2a89d)
…SwiftTasks

Computing a Task name can be an expensive operation, especially over
slower connections to the inferior process. To improve this situation,
this patch:

* Makes the computation lazy, and
* Caches the result of the computation (a task name is immutable).

The first point is the most important, as prior to this we were
computing the task name on every stop, even when the same MemoryThread
was reused between two consecutive stops.

On local testing with a wired connection, this reduces stepping time by
around 20-30ms, out of an average of 230ms.

(cherry picked from commit 1d2a6be)
These have a "Constructor" demangle node kind that should be considered.

(cherry picked from commit 6eef42d)
This just deletes the initial breakpoint so other parts of the test
don't need to consider it.

(cherry picked from commit 4f4a7bc)
These use the Static mangled node, which we were not handling.

(cherry picked from commit fcbd055)
(cherry picked from commit dba046f)
@felipepiovezan felipepiovezan merged commit cba17b0 into swiftlang:next Jun 30, 2025
@felipepiovezan felipepiovezan deleted the felipe/task_cherry_picks branch June 30, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant