Skip to content

[Concurrency] Decode actor/task flags in signposts, make task_wait an interval. #41808

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
merged 1 commit into from
Mar 17, 2022

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented Mar 14, 2022

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
rdar://88597345

@mikeash mikeash requested review from rokhinip and Harjas12 March 14, 2022 19:45
… 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
// the enum values, but this explicit conversion provides room for change.
uint8_t traceState = 255;
switch (getActorState()) {
case ActiveActorStatus::Idle:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these values be exported in a private header somewhere for Instruments to slurp up?

And maybe we have a version number as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or do we think we'd just change the signpost ID value if we had a breaking change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a header probably wouldn't make things any easier. @Harjas12 any thoughts on that?

We have several options for making changes. We can refrain from using traceState values that are no longer in use and add new ones, we can keep this parameter in some sort of degraded state and add a new one with new info, or we can change the signpost ID. Adding a version number doesn't give us anything particularly useful on top of that.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think the best way to handle this is to add the new values by appending to the log string. Parsers should be smart enough that the old versions ignore anything new and new version know to ignore the old fields and look at the new fields. If we do have to "deprecate" a field, we would ideally keep it in a good enough state for 1 year before we completely removed it. Any changes that remove from the format would need a 1 year lead time.

Copy link

@Harjas12 Harjas12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@mikeash
Copy link
Contributor Author

mikeash commented Mar 16, 2022

@swift-ci please test

@mikeash
Copy link
Contributor Author

mikeash commented Mar 16, 2022

@swift-ci please test linux platform

@mikeash
Copy link
Contributor Author

mikeash commented Mar 16, 2022

@swift-ci please smoke test macos platform

@ktoso
Copy link
Contributor

ktoso commented Mar 17, 2022

Nice, looking good :)

I noticed the failure was a distributed test -- looking into it -- ok the failure was #41840 so that should be ok now (and it'd was only on 32bit watch anyway).

@mikeash
Copy link
Contributor Author

mikeash commented Mar 17, 2022

@ktoso Thanks for checking into that. Sorry, I should have pinged you when I saw the failure. I get so very focused on getting to a mergable state sometimes....

@mikeash mikeash merged commit a64b75e into swiftlang:main Mar 17, 2022
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.

4 participants