Skip to content
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

Cleanup more EventSource calls in SPC to work better with illinker #40539

Merged
merged 4 commits into from
Oct 9, 2020

Conversation

marek-safar
Copy link
Contributor

  • Adds missing IsEnabled guard
  • Tweak the logic to be detectable by linker

- Adds missing IsEnabled guard
- Tweak the logic to be detectable by linker
@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@marek-safar marek-safar requested a review from eerhardt August 7, 2020 17:17
@@ -3253,6 +3249,8 @@ internal void FinishContinuations()
lock (continuations) { }
int continuationCount = continuations.Count;

bool etwIsEnabled = log.IsEnabled();
Copy link
Member

Choose a reason for hiding this comment

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

Are we concerned that IsEnabled() may have changed in-between the above check and now? I assume that is why the existing code is written the way it was.

cc @stephentoub

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 was actually looking at the existing cases and we are pretty inconsistent on this

Copy link
Member

Choose a reason for hiding this comment

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

Why not store this Boolean at the top of the method, where it was storing log in a variable?

Copy link
Member

Choose a reason for hiding this comment

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

I assume that is why the existing code is written the way it was.

Yes. The goal was to avoid output the subsequent events if and only if the starting event was written.

@@ -311,7 +311,7 @@ internal override void Run(Task completedTask, bool canInlineContinuationTask)
// If the task was cancel before running (e.g a ContinueWhenAll with a cancelled caancelation token)
// we will still flow it to ScheduleAndStart() were it will check the status before running
// We check here to avoid faulty logs that contain a join event to an operation that was already set as completed.
if (!continuationTask.IsCanceled && TplEventSource.Log.IsEnabled())
if (TplEventSource.Log.IsEnabled() && !continuationTask.IsCanceled)
Copy link
Member

Choose a reason for hiding this comment

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

Does the linker not handle something && false should just be false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does, it just didn't look right to me to do the call and then scrap it.

Copy link
Member

Choose a reason for hiding this comment

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

I don’t think I understand, to do what call? This was checking a property.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep but why to check the property if it's needed only when tracing is enabled. I don't feel strongly about this and could revert to the original logic event though continuationTask.IsCanceled is probably most of time false

@eerhardt
Copy link
Member

eerhardt commented Aug 7, 2020

How much savings are you seeing with this change? I didn't dig deep into this area originally, because it looked like the savings were not significant vs the risk for potential behavior change.

@marek-safar
Copy link
Contributor Author

Not a lot (few kB) but that's because there are still few cases which bring EventSource

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

These changes look good to me. Thanks.

@marek-safar
Copy link
Contributor Author

Timeouts are unrelated, merging

@marek-safar marek-safar merged commit ea75ac6 into dotnet:master Oct 9, 2020
@marek-safar marek-safar deleted the TplEventSource branch October 9, 2020 17:00
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants