Skip to content

Off-thread continuation resumes are slow on Linux #67830

Open
@oxy

Description

@oxy

Summary:

Starting a continuation on one thread, and then firing the resume on another, when there is currently no other work being done, results in ~30 microseconds of overhead on Linux, as opposed to ~7 microseconds on macOS for the same benchmark, on the same hardware (Xcode 15 beta on macOS, Swift 5.8.1 on Linux).

Steps To Reproduce:

  1. See attached benchmark (uploaded as .txt to make GitHub happy):
  • start continuation on one thread
  • write the continuation into a pipe
  • block on read in a detached task to resume
  1. Run the same benchmark on macOS and Linux and observe significantly different results.

Results:

I expected that performance for the two platforms would be vaguely in-line with each other, but the continuation resume step is significantly slower on Linux - a profile verified that it was continuation resumes and not the relative performance of pipes on the two platforms.

Notes:

Some of the latency appears to be caused by the use of pthread semaphores for signaling on Linux in libdispatch.

Tracking as rdar://113640087.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions