Commit Graph

6 Commits

Author SHA1 Message Date
Mike Ash
e5c61b3945 [Concurrency] Minor tweaks to continuation, task, and job tracing.
Change continuation signposts to emit an interval for init/resume.

Fix task_create to take the decoded flags as separate parameters, matching other calls.

Move job_run trace calls into runJobInEstablishedExecutorContext. swift_job_runImpl didn't catch everything.

rdar://92149411
2022-04-22 15:50:10 -04:00
Mike Ash
a64b75e6c3 Merge pull request #41808 from mikeash/more-signposts
[Concurrency] Decode actor/task flags in signposts, make task_wait an interval.
2022-03-17 11:02:45 -04:00
Mike Ash
b555b6083b [Concurrency] Decode actor/task flags in signposts, make task_wait an interval, signpost continuations.
Decode all fields from the various flags values, pass each field as a separate argument to the various signposts. We were just passing the raw value of the flags and requiring the signpost client to decode them, which was ugly and required the client to know details they shouldn't need to know.

Strip ptrauth bits from the task resume function when signposting, when ptrauth is supported.

Add signpost events for continuation init/await/resume events.

We also make task_wait into an interval, rather than a single event. The interval ends when the task resumes. As part of this change, we also skip emitting the interval when the wait completed immediately and the task didn't have to suspend.

While we're in there, clean up a few SWIFT_TASK_DEBUG_LOG lines that emitted warnings when built with the logging enabled.

rdar://88658803
2022-03-14 15:46:09 -04:00
Alastair Houghton
f204f0634b Add a build option for the concurrency tracing feature.
Concurrency tracing was enabled depending on the presence of a header
file, but if a similarly named header was found somewhere in the path
that didn't do the same thing, that might cause problems.

Instead, we should have a build time configuration option.

rdar://89787540
2022-03-09 12:53:10 +00:00
John McCall
c70d73cb7e Fix a use-after-free with task tracing.
We cannot access the executed job after it has finished executing:

- If it's a non-task job, it is always invalidated; such jobs are
  self-owning, and they are expected to destroy themselves after
  execution.

- If it's a task, and it completes during execution, it will invalidate
  itself synchronously, e.g. by releasing itself.  At this point, it
  must be assumed that the task memory has been releaed.

- If it's a task, and it hasn't completed during execution, we are
  now racing with whatever event *does* complete the task.

Any information we want to log about the job must be recorded when it
starts to run.

rdar://88817560
2022-02-24 13:58:30 -05:00
Mike Ash
0977920217 [Concurrency] Add tracing for major operations in the concurrency runtime.
Each trace point is declared as a function in the new `Tracing.h` header. These functions are called from the appropriate places in the concurrency runtime.

On Darwin, an implementation of these functions is provided which uses the `os/signpost.h` API to emit signpost events/intervals.

When the signpost API is not available, no-op stub implementations are provided. Implementations for other OSes can be provided by providing implementations of the trace functions for that OS.

rdar://81858487
2022-01-07 11:35:40 -05:00