Yjit in hanami app

Hello there!

I’m new to the community, just created my first hanami new app and started discovering the conventions and caracteristics of the framework.
Quick question, does Hanami uses Yjit by default? didn’t found anything about it.

Also, I’ve seen that max_threads default is set to 5, as rails used to be. Is there some benchmark on overall performance? The recommended default in rails from the 7.2 on is 3 threads, and I’ve seen that single threaded apps could handle even more load.

I’m planning to do some tests too

Thanks!

Hey Chris. So Hanami doesn’t support YJIT by default but if you use Hanamismith to generate your application, you’ll get YJIT enabled by default. It’s configured as a provider. See here as an example.

1 Like

Thanks for the info!

1 Like

A provider is not really necessary for that, though. I just have this line in my Dockerfile:

ENV RUBYOPT=--yjit

Adam, yeah, that works too if you want YJIT at boot. With the provider, the idea was to lazy load (or slightly delay enablement for a faster boot).

To be clear, Hanami does support YJIT — like @alassek shared, it can be activated from outside the app’s Ruby code and everything will still run fine. What we don’t do right now is enable it by default. At this stage we are choosing not to make too many assumptions about how people want to configure their Ruby runtime.


If I were setting this up personally, I’d probably go the approach of the env var or adding RubyVM::YJIT.enable to the top of config/app.rb. My reasoning here would be that this ensures consistent behaviour regardless of the boot approach, plus YJIT itself is not really part of the app’s internal “state” (the setting up of which is the main intention for providers). It’s cool to see how you’ve put providers to use in this case, though!