-
Notifications
You must be signed in to change notification settings - Fork 142
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
development env, high CPU usage #482
Comments
I don't see anything like this in my machine 😕 Could yo provide more details? For example, Solid Queue version, OS..? |
SQ 1.1.2. Tried with ruby 3.1.6 and 3.0.6 (similar to my production versions for now). OS is Ubuntu 22.04 (technically, it's WSL in Windows 11). Ruby, Rails, Mysql see in my first message I tried setting up a new Rails app from scratch, then simple SQ config according to installation guide, but I got the same results. Looks like mysql experiences some load too, so probably SQ makes a lot of requests? I cannot see anything in |
tried with this queue.yml config
to make it really slooow - but I still get the same huge load. |
Could you try with Solid Queue <= v1.0.2? Just to rule out some changes around worker/dispatcher polling and the interruptible sleep? |
"wasn't me".... 😏 (at least I really hope so 🤞 ) All kidding aside, I did spin up my dev env to reconfirm that see almost zero CPU resources when SQ is quiescent. For comparisons and to keep the information flowing: M3 Mac, OSX 15.2, Postgres@17(primary, I test across all 3 databases at the latest release), ruby 3.4, Rails 7.2.2. Before pushing up my PRs, I did test across Ruby 3.1 - 3.6 and on Rails 7.1. |
@rosa nicely spotted! I only have mysql5.7 to test with, though I set the recommended |
A little bit more info on SQ 1.1.2 tests: I'm currently upgrading my app to 3.2.6 so it might be not that important for me any longer, but still probably worth noticing. |
Huh, interesting! I wonder if it's something specific to
since @hms couldn't reproduce this in Ruby 3.1.2 🤔 |
I can confirm the same problem with high CPU usage and many queries to DB. queue_dispatcher.yml
queue_default.yml
queue_heavy.yml
My wild guess is that this is related to this change https://github.com/rails/solid_queue/pull/444/files#diff-bef5b458db8bc17c1a7cdf1b6f2f1508f8ad3c57f8c04139d7ff0ad4ad8d822bR28 in #444 |
Would it be possible for you to post more info on the SolidQueue queries that are running? From the screen shot you posted, all I can see is there are two different queries labeled "delete from solid_queue". |
Can also share your deployed Ruby and Rails versions, and what database and version? |
@hms sure, here is more detailed graph |
@rosa, @markivancho, @alex29ua I tracked problem down. In above referenced PR, Interruptible.rb was reimplemented using Thread::Queue and Queue.pop(timeout:). Ruby 3.1.* does not support the Queue.pop method with a keyword argument of timeout and that results in the queue pop call raising an exception, effectively returning immediately. This explains the high CPU utilization since Workers and Dispatchers effectively never sleep between poll loops. The timeout argument is supported in Ruby 3.2 which is why everything worked when @alex29ua upgraded to Ruby 3.2. What made this issue a little harder to track down is Queue.pop is called inside of a Concurrent::Promises.future, which swallowed the exception because I "cleverly" failed to add an exception handler because "such simple code could never fail" (hangs head in shame 😳 ). When I initially responded that I tested Ruby 3.1 - 3.6, that was because I transposed 3.1.3 with 3.3.1 (which was the earliest version I did test with). Sorry for the delay that this caused in resolving the issue. |
Oooh! Amazing find, @hms! 👏 Is this something you could open a PR to fix? Otherwise, I'll prepare a fix. |
I already have a PR to fix another small, zero impact bug (but a bug never the less) that I had found during my debugging this issue. I'm happy to address the Interruptible issue in that PR. I do need some guidance on the SQ team's preferred solution. If SQ is going to support Ruby 3.1, then I have to replace the current version of Interruptible.rb with the original version -- there is no ruby 3.1 work around with the Thread::Queue based implementation. The catch is: Ruby 3.1 hits EOL (for security patches -- which I assume is an effective EOL for 99%+ of users) in 2 months. If we're really only considering supporting 3.1 for 2 to X months, then I would propose to craft an initializer that includes the correct version of Interruptible based on the Ruby version. Please let me know your preferences and I'll supply a PR. Also, if SQ is going to support multiple versions of Ruby, would you be open to me creating a PR for the GitHub actions to test across supported rubies? When I created the original interruptible PR, I made the assumption that 3.3.1 was the baseline ruby because it was set in .ruby_version and the GitHub actions as the only tested ruby. |
Thanks so much, @hms!
Yeah, you're totally right about this, that's my bad, sorry! I think to drop support for Ruby 3.1, which is supported by the minimum Rails version required by Solid Queue (Rails 7.1) we'd need to release a major version as that'd be a breaking change 🤔 I'm not ready yet to ship a major version (I'd like to get batches and sharding support done before that, and I'm not quite sure when that'll happen) so I think the approach with the two versions of interruptible based on
That'd be super, super helpful!! Thank you so much! |
The current Thread::Queue based Interruptible can not work with Ruby version earlier than 3.2. Given that SQ sets it's minimum supported version of Ruby is derived from "full support of Rails 7.1", this in theory mandates support for Ruby 2.7.8. However, other dependencies force the minimum version of Ruby to: 3.1.6 This commit adds a boot time check of the Ruby version and selects either the current or original implementation of Interruptible.
PR submitted as committed. Hopefully it's acceptable. @rosa -- the one failure in test run is because of a timing problem based on container load rather than a real issue. |
Trying a default install of solid_queue 1.1.2, with a still empty queue DB.
Ruby 3.1.6, Rails 7.1.5.1, Ubuntu 22.04, MySQL 5.7. No Puma.
When I run
rails solid_queue:start
, CPU usage goes crazy. It looks like this:and it never goes down. I tried changing the polling to 500/50 or even slower, but it doesn't change anything at all in usage.
Is it some misconfiguration issue?
Nothing suspicious in the logs as I can see.
The text was updated successfully, but these errors were encountered: