Adding StopProfile function to System.Runtime.ProfileOptimization. #33252
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change adds StopProfile function to System.Runtime.ProfileOptimization
class and MulticoreJit feature of CoreCLR itself.
ProfileOptimization class always have SetProfileRoot and StartProfile
methods, but previously had no possibility to forcibly stop recording of
program profile and write out collected profile to the file.
Previously profiling can be stopped only at the time the program
finishes or after timeout expiration (timeout can be set by environment
variable COMPlus_MultiCoreJitProfileWriteDelay). Unfortunately timeout
works only on Windows platform, but not on Unix (no code for this
function in MulticoreJit component).
If we want speed up program startup time (if we are talking about
GUI applications -- this is the time util program's window appears on
the screen), we don't need to collect complete profile, until
termination of the program. We interested only on functions (methods),
which program runs at startup time. So we want to stop collecting
profile after program is "started" from users point of view.
This change adds this possibility.
There are several reasons, why we want to stop collecting profile
at some moment of time:
program might be buggy and always crashes on exit, for example,
due to this reason profile might never be saved (or, program
never terminates: it once started and works until reboot or
power fail);
for large programs, profile might be too big: class loading
and compilation of excessive set of the functions (which not
required at program startup, but might be required only after
some program function is activated) might slow down start up
process.