Skip to content

Conversation

@lateralusX
Copy link
Member

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.

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.
@ghost ghost added the area-Tracing-coreclr label Sep 12, 2021
@lateralusX
Copy link
Member Author

//CC @josalem

Copy link
Contributor

@josalem josalem left a comment

Choose a reason for hiding this comment

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

It's worth pointing out that this only affects Windows tracing sessions that suspend the runtime on startup to capture startup events. This should affect any other scenarios.

Thanks @lateralusX

@lateralusX
Copy link
Member Author

lateralusX commented Sep 13, 2021

It's worth pointing out that this only affects Windows tracing sessions that suspend the runtime on startup to capture startup events. This should affect any other scenarios.

Thanks @lateralusX

Yes, it only happens if there are sessions created before EventPipe init finished (as part of doing suspended startup), but also applies to the default file based session controlled through COMPlus_EnableEventPipe environment variable.

@lateralusX
Copy link
Member Author

/backport to release/6.0

@github-actions
Copy link
Contributor

@josalem josalem merged commit d6d527f into dotnet:main Sep 13, 2021
@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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants