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

[release/6.0] Fix EventPipe sample profiler resolution on Windows. #59056

Merged
merged 1 commit into from
Sep 14, 2021

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 13, 2021

Backport of #58997 to release/6.0

/cc @lateralusX

Customer Impact

Users on Windows that use the environment variable or startup suspension mechanisms to start an EventPipe session will only see a stack sample resolution of 16ms. Any subsequent traces after that will also have the lower resolution due to how the reference counting is handled inside the sample profiler. This patch fixes that to allow for 1ms time resolution.

Testing

@lateralusX performed local testing to validate this fixes the scenario.

Risk

Low. This patch moves the loading of Windows libraries for changing the time resolution up so that suspended scenarios and the env var have the higher resolution. The load is still gated on internal reference counting and behavior shouldn't change other than enabling the load.

(filled out by @josalem on behalf of @lateralusX)

If sample profiler was initially created before sampling has been
enabled, happens when setting up sessions during startup,
sample_profiler_load_dependecies won't get called, meaning we won't
setup timeBeginPeriod/timeEndPeriod on Windows, and won't adjust
default scheduling resolution to 1ms staying on default 16ms.

There is a ref count check in current sample_profiler_enable checking
if we should call sample_profiler_load_dependecies (_ref_count == 0),
but in case where we can't start profiling _can_start_sampling == false,
we won't call sample_profiler_enable but always increase _ref_count
that in turn will prevent calls to sample_profiler_load_dependecies when
enabling sample profiler and that in turn won't call timeBeginPeriod
staying on default scheduling resolution.

Fix is to always call sample_profiler_load_dependecies making sure we
will setup needed dependencies when _ref_count == 0.
Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

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

Approved. Please get a code review and once we have a green ci we can merge.

@josalem josalem added this to the 6.0.0 milestone Sep 13, 2021
@jeffschwMSFT jeffschwMSFT added the Servicing-approved Approved for servicing release label Sep 14, 2021
@jeffschwMSFT jeffschwMSFT merged commit bf2a7d0 into release/6.0 Sep 14, 2021
@jkotas jkotas deleted the backport/pr-58997-to-release/6.0 branch September 18, 2021 04:09
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Tracing-coreclr Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants