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
Support Ruby 3.3's Process.warmup
before fork
#3304
Comments
Is it possible to find out? Can we construct benchmarks? |
One of the reasons we removed nakayoshi fork was it's tendency to surface extremely difficult to debug problems in C-extensions due to compaction. I'm not sure that will have really improved since the time that the feature was considered. |
That is indeed a problem. I (and others) fixed many compaction issues in popular extensions, but there is a long tail of potential problems in less popular ones. I'm always happy to help debug and fix these, but as you mention, often the problem is to identify the extension responsible for it. In most case it's not too hard, but sometimes it's super tricky. |
I guess it's not much practical difference to do this: before_fork { ::Process.warmup } ...versus having in the Puma DSL something like this: ruby_process_warmup Probably the vast majority of the value is having it officially documented and visible in Puma as something one could or should do. Though I totally understand if it creates an untenable support burden by surfacing other issues (though maybe something that could be addressed through documentation, though I also recognize that doesn't redirect everyone who might open an issue). |
I have tested this in our pretty complex Rails application with Puma running in clustered mode and it led to segfaults. There's risk in making it a default. At the very least my suggestion is to keep it configurable unlike Sidekiq. |
No problem with
|
I know it's not always easy, but it would be very valuable to figure out which gems are impacted and report the issue upstream. If you have trouble identifying which gem, I'd be happy to look at your crash reports to try to help.
Doing this would entirely defeat the benefits of |
I had some time to dig into this, I was able to reproduce with our codebase locally, but could not narrow down it entirely. It crashes right on the
In our before_fork do
StartupWarmup.warmup_puma
ApplicationRecord.connection.disconnect!
Process.warmup
end Skipping I think for simple Rails apps this is not an issue, and if your |
That's 100% a bug in a C extension. The hard part is to track which one. A start is to grep with something like: $ rg -F rb_str_ %(bundle show --paths) There is a couple C API that allow creating such broken string, the most common is If you share the result of that search in a gist, I'd be happy to see if I can figure out which one it is. |
Thanks to your tip I managed to narrow it down and find the gem with the issue. It's memcached. This gem is abandoned and we use our own fork with extra fixes. We're not on dalli because we have an mcrouter cluster of memcached instances, and unfortunately it only works with the text protocol of Memcached. So the good news is that most likely no one else is using this gem and shouldn't encounter this issue. 😄 |
Ah, that rings a bell. 99% sure I fixed that bug not so long ago, let me look. |
Alright, I'm bad at writing commit messages, so I can't be fully certain, but I think this was the fix: Shopify/memcached@28b5840 But overall you can use this branch, we use it with |
@byroot I can confirm that with your fork there is no issue. 👍 |
Is your feature request related to a problem? Please describe.
Ruby 3.3 introduces
Process.warmup
which does the following:The functionality is somewhat similar to the removed nakayoshi fork functionality, but (hopefully) performs better.
I'm imagining this would be exposed/implemented in a similar manner to the
nakayoshi_fork
DSL directive.The text was updated successfully, but these errors were encountered: