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

Add support for Performance Monitoring Counters (PMC) #59

Merged
merged 18 commits into from
May 1, 2024
Merged

Conversation

albertziegenhagel
Copy link
Owner

@albertziegenhagel albertziegenhagel commented Apr 13, 2024

This is a very coarse and initial implementation to support multiple sample sources (usually from performance monitoring counters).

Copy link

codecov bot commented Apr 13, 2024

Codecov Report

Attention: Patch coverage is 89.94253% with 70 lines in your changes are missing coverage. Please review.

Project coverage is 83.31%. Comparing base (33eb6e1) to head (80b63e6).

Files Patch % Lines
snail/analysis/perf_data_data_provider.cpp 84.53% 3 Missing and 12 partials ⚠️
snail/analysis/etl_data_provider.cpp 86.07% 3 Missing and 8 partials ⚠️
...analysis/detail/perf_data_file_process_context.cpp 78.94% 0 Missing and 8 partials ⚠️
snail/analysis/detail/pdb_resolver.cpp 0.00% 4 Missing and 2 partials ⚠️
snail/server/requests/requests.cpp 95.31% 0 Missing and 6 partials ⚠️
snail/analysis/analysis.cpp 93.75% 0 Missing and 5 partials ⚠️
snail/analysis/detail/etl_file_process_context.cpp 95.57% 0 Missing and 5 partials ⚠️
snail/server/requests/protocol.hpp 80.00% 2 Missing and 2 partials ⚠️
snail/perf_data/dispatching_event_observer.cpp 50.00% 2 Missing and 1 partial ⚠️
snail/server/storage/storage.cpp 94.64% 1 Missing and 2 partials ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #59      +/-   ##
==========================================
+ Coverage   82.70%   83.31%   +0.61%     
==========================================
  Files         101      102       +1     
  Lines        3977     4310     +333     
  Branches      732      829      +97     
==========================================
+ Hits         3289     3591     +302     
+ Misses        340      339       -1     
- Partials      348      380      +32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This is to reduce the required LFS bandwidth of the GitHub actions.
The solution is based on
actions/checkout#165 (comment)
Support samples that do not have a stack attached to them, but only a single instruction pointer (or in case of perf-data samples, they theoretically might not even have that).
Process PMC counter profile events and generate a separate list of samples per thread.
Stack walk events are attached to any matching sample for both "regular" samples, as well as PMC samples.
Only kernel events have an attribute id attached, but we tried to read/find them for all (including perf) events. This was working in cases where there is only one event source, since we did never really look for the correct id, but simply took the one and only attribute as default. Put with multiple event sources, this was failing.

To fix this, the special kernel event handling is now done a little bit earlier in the event creation code, before we try to find the correct attributes for an event, and we simply skip this step for non kernel events.
If the ETL files does not come from vsdiagnostics.exe (e.g. directly from xperf), it does not include any information about the process we where trying to profile. Hence we try to narrow down the list of processes by only looking at processes that have at least one sample.
Use an xperf command line that looks like the one that has probably started the trace.
Instead of doing an analysis for each source separately, we analyze all samples from all available sources at the same time (regardless of whether they have stacks attached or not).
The script invokes XPerf (elevating via Windows UAC dialogs if necessary) and supports sample based profiling for regular timing events, as well es PMC events.
Additionally, it introduces a new event provider and event to attach information about the target process that is being profiled to the ETL file.
@albertziegenhagel albertziegenhagel marked this pull request as ready for review May 1, 2024 13:28
@albertziegenhagel albertziegenhagel merged commit 6d03ff8 into main May 1, 2024
7 checks passed
@albertziegenhagel albertziegenhagel deleted the pmc branch May 1, 2024 13:59
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.

None yet

1 participant