feat(profiling): Introduce different profiler schedulers#1616
Merged
Zylphrex merged 7 commits intoSep 19, 2022
Conversation
Previously, the only scheduling mechanism was via `signals.SIGPROF`. This was limited to UNIX platforms and was not always consistent. This PR introduces more ways to schedule the sampling. They are the following: - `_SigprofScheduler` uses `signals.SIGPROF` to schedule - `_SigalrmScheduler` uses `signals.SIGALRM` to schedule - `_SleepScheduler` uses threads and `time.sleep` to schedule - `_EventScheduler` uses threads and `threading.Event().wait` to schedule
Zylphrex
marked this pull request as ready for review
September 15, 2022 20:13
| while True: | ||
| if self.event.is_set(): | ||
| break | ||
| self.event.wait(timeout=self._interval) |
Member
There was a problem hiding this comment.
the only event.set is in stop_profiling so won't this always timeout?
Member
Author
There was a problem hiding this comment.
Yes, that's the intent. The idea with this scheduler is to use this timeout mechanism to schedule the next time the sampling function is called. One possible concern with this approach is that CPU usage may spike due to the wait but this will be tested more and verified before we make a final decision.
Member
There was a problem hiding this comment.
ah gotcha, thx for explaining!
sl0thentr0py
approved these changes
Sep 19, 2022
Zylphrex
deleted the
txiao/feat/introduce-different-profiler-schedulers
branch
September 19, 2022 20:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Previously, the only scheduling mechanism was via
signals.SIGPROF. This was limited to UNIX platforms and was not always consistent. This PR introduces more ways to schedule the sampling. They are the following:_SigprofSchedulerusessignals.SIGPROFto schedule_SigalrmSchedulerusessignals.SIGALRMto schedule_SleepScheduleruses threads andtime.sleepto schedule_EventScheduleruses threads andthreading.Event().waitto schedule