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

[Profiler] Implement WaitHandle wait duration profiling #6426

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

chrisnas
Copy link
Contributor

Summary of changes

Listen to .NET 9+ events related to WaitHandle-derivated instances to profile wait durations

Reason for change

R&D week based on dotnet/runtime#94737 and #5814

Implementation details

Listen to WaitHandleWaitStart/WaitHandleWaitStop events to measure wait duration and, if possible, get the type of wait object like Mutex, Semaphore, ManualResetEvent or AutoResetEvent

Test coverage

Other details

@chrisnas chrisnas requested review from a team as code owners December 12, 2024 08:15
@github-actions github-actions bot added the area:profiler Issues related to the continous-profiler label Dec 12, 2024
@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Dec 12, 2024

Datadog Report

Branch report: chrisnas/r+d_week_wait_events
Commit report: 64bb53d
Test service: dd-trace-dotnet

✅ 0 Failed, 218707 Passed, 1502 Skipped, 12h 31m 13.32s Total Time

@andrewlock
Copy link
Member

andrewlock commented Dec 12, 2024

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing the following branches/commits:

Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6426) - mean (69ms)  : 65, 73
     .   : milestone, 69,
    master - mean (68ms)  : 65, 71
     .   : milestone, 68,

    section CallTarget+Inlining+NGEN
    This PR (6426) - mean (980ms)  : 953, 1007
     .   : milestone, 980,
    master - mean (975ms)  : 954, 996
     .   : milestone, 975,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6426) - mean (107ms)  : 105, 110
     .   : milestone, 107,
    master - mean (108ms)  : 105, 110
     .   : milestone, 108,

    section CallTarget+Inlining+NGEN
    This PR (6426) - mean (674ms)  : 658, 690
     .   : milestone, 674,
    master - mean (676ms)  : 659, 693
     .   : milestone, 676,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6426) - mean (91ms)  : 89, 93
     .   : milestone, 91,
    master - mean (91ms)  : 89, 93
     .   : milestone, 91,

    section CallTarget+Inlining+NGEN
    This PR (6426) - mean (631ms)  : 617, 645
     .   : milestone, 631,
    master - mean (635ms)  : 617, 652
     .   : milestone, 635,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6426) - mean (193ms)  : 189, 197
     .   : milestone, 193,
    master - mean (194ms)  : 190, 198
     .   : milestone, 194,

    section CallTarget+Inlining+NGEN
    This PR (6426) - mean (1,095ms)  : 1071, 1119
     .   : milestone, 1095,
    master - mean (1,102ms)  : 1071, 1133
     .   : milestone, 1102,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6426) - mean (278ms)  : 274, 283
     .   : milestone, 278,
    master - mean (278ms)  : 273, 283
     .   : milestone, 278,

    section CallTarget+Inlining+NGEN
    This PR (6426) - mean (869ms)  : 830, 908
     .   : milestone, 869,
    master - mean (870ms)  : 838, 901
     .   : milestone, 870,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6426) - mean (266ms)  : 261, 270
     .   : milestone, 266,
    master - mean (267ms)  : 263, 271
     .   : milestone, 267,

    section CallTarget+Inlining+NGEN
    This PR (6426) - mean (843ms)  : 816, 869
     .   : milestone, 843,
    master - mean (854ms)  : 815, 892
     .   : milestone, 854,

Loading

currentThreadInfo->SetWaitStart(0ns);

// We are not interested in waits that are too short
if (waitDuration < 1ms)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this. Assuming a memcache request takes 300 us to complete, we would miss all sync-over-async on them, even though it could be a very serious issue.

What would be the issue with not filtering any waits?

return;
}

AddContentionSample(0ns, -1, currentThreadInfo->GetWaitType(), waitDuration, 0, WStr(""), _emptyStack);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it mean the wait events be branded as contention? I'm not sure sync-over-async can be considered as contention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:profiler Issues related to the continous-profiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants