-
Notifications
You must be signed in to change notification settings - Fork 514
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
feat(profiling): Introduce different profiler schedulers #1616
feat(profiling): Introduce different profiler schedulers #1616
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
while True: | ||
if self.event.is_set(): | ||
break | ||
self.event.wait(timeout=self._interval) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only event.set
is in stop_profiling
so won't this always timeout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah gotcha, thx for explaining!
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
usessignals.SIGPROF
to schedule_SigalrmScheduler
usessignals.SIGALRM
to schedule_SleepScheduler
uses threads andtime.sleep
to schedule_EventScheduler
uses threads andthreading.Event().wait
to schedule