-
Notifications
You must be signed in to change notification settings - Fork 128
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
Using wall-clock profiling on macOS makes Ruby thread scheduling starve background threads #158
Comments
Thanks for reporting this. It must be a problem with My best guess is that this is due to the timer on macOS using a thread and pipe. We could probably improve the situation by changing the timer in Ruby to use Grand Central Dispatch (libdispatch) for its timer, but I haven't tested. Linux seems to be using |
Machine: Linux spin 5.4.120+ #1 SMP Tue Jun 22 14:53:20 PDT 2021 x86_64 x86_64 x86_64 GNU/Linux Modified the script to show differences between CPU and WALL on the above machine:
|
@fekadeabdejene I'm not seeing thread starvation in this case. When I run this on linux, both emojis are printed out mostly evenly: Without WALL:
With WALL:
Does it do the same thing for you? I want to figure out if this is a problem with thread starvation or if it's a problem with the reporter.
|
Hey, That is a good point! A problem with the reporting is possible. I also am able to see the emoji's. Whenever I get dumps using |
Hello again! π π
First the disclaimer (I guess it may be relevant): I work at @DataDog on profiling for the ddtrace gem, although we don't use
rb_profile_frames
(oh my god it's full of C π€£ ).While doing a few experiments with stackprof, I came upon this really really really weird behavior. Consider this simple test application:
Basically two threads are running as fast as they can this really simple but on-cpu workload. Ruby seems to distribute cpu time reasonably fairly:
But observe what happens if I turn on stackprof:
Cpu profiling does not seem to be affected.
It's really weird, but it looks like the main thread gets to run most of the time, and any other background thread gets massively starved for time.
I was able to observe this behavior on Ruby 3.0.1, 2.7.3 and 2.6.7 on macOS (10.15.7/i7-1068NG7), but not on Linux. I did spot after the fact that the README.md states that Linux is required, but I'm guessing that's outdated and that macOS is expected to work (...maybe?).
The text was updated successfully, but these errors were encountered: