Commit Graph

12 Commits

Author SHA1 Message Date
Mykola Pokhylets
6298d41edf Reapply "Fix quadratic performance of the ListMerger in specific usage pattern"
This reverts commit 2640ff613b.
2024-05-30 13:08:42 +02:00
Mike Ash
634295c85e Merge pull request #73796 from mikeash/fix-resume-function-for-logging
[Concurrency] Refine getResumeFunctionForLogging to avoid reading invalid future contexts.
2024-05-22 16:57:37 -04:00
Andrew Trick
2640ff613b Revert "Fix quadratic performance of the ListMerger in specific usage pattern" 2024-05-21 16:23:57 -07:00
Mike Ash
0f226b6667 [Concurrency] Refine getResumeFunctionForLogging to avoid reading invalid future contexts.
When using a future adapter, the resume context may not be valid after the task starts running. Only peer through the adapter when we're starting to run.

rdar://126298035
2024-05-21 16:22:40 -04:00
Mykola Pokhylets
40c38f9803 Using multiple insertion points to ensure all jobs are always inserted in O(1)
Fully separated unprocessed jobs and processed jobs
Reverse jobs after updating status to minimise contention
2024-05-10 11:05:22 +02:00
Konrad `ktoso` Malawski
5546f4da7b Rename ExecutorRef to SerialExecutorRef 2023-11-01 18:39:44 +09:00
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