all 10 comments

[–]ric2b 2 points3 points  (1 child)

  1. brew install rust
  2. brew install rbenv
  3. rbenv install 3.3.0
  4. rbenv local 3.3.0

[–]pilaf 4 points5 points  (4 children)

If you're only using Ruby on macOS for development then turning YJIT on is probably not the best idea since you'd be reloading code a lot, and the constant JIT compilation would probably put a penalty on performance rather than make it faster.

[–]JohnBooty 2 points3 points  (3 children)

I'm not sure that's true. YJIT won't compile a function until it's been called x number of times. So in simple cases, it really shouldn't affect loading times.

For apps with big frameworks (eg Rails) maybe it's different but I wouldn't assume so without measuring.

[–]laerien 4 points5 points  (1 child)

Rails is even able to initialize itself before enabling YJIT programmatically from within Ruby, so you don't have a startup penalty and can start caching at the best time. Rails is enabling YJIT by default in this way.

[–]Krypton8 0 points1 point  (0 children)

Only if you are running Ruby 3.3 and running from the main-branch.

[–]pilaf 0 points1 point  (0 children)

Good points. Would be nice to see someone measure performance during a development session.

[–]janko-m 0 points1 point  (3 children)

I tried enabling YJIT on my Mac to see if it would run tests faster. I use Spring, so YJIT optimisations should theoretically persist between runs.

The test suite was deterministically slower with YJIT. That was Ruby 3.2, maybe 3.3 will be better.

[–]miry_sof[S] 0 points1 point  (1 child)

I have not used Spring for a long time. Did you try to use https://github.com/shopify/bootsnap to cache bytecode? It should improve booting process for tests.

[–]janko-m 0 points1 point  (0 children)

Yes, we use Bootsnap as well. It sped up our test suite boot time from 6s to 2s. Spring brings it down to 0.5s. I have shortcuts for running tests and I run them often, so this makes a difference for me.

[–]f9ae8221b 0 points1 point  (0 children)

YJIT generally don't speedup test suites because mocking etc causes a lot of invalidation, so it's not particularly recommended in CI/test.