r/ruby • u/myroon5 • Dec 25 '22
Ruby 3.2.0 Released
https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/17
13
u/jrochkind Dec 25 '22
This may be my favorite new feature, which I just noticed now:
A Struct class can also be initialized with keyword arguments without keyword_init: true on Struct.new [Feature #16806]
10
u/ekremkrc Dec 25 '22
Congratulations to those who is part of the release & make Ruby better but one thing is missing:
A message from u/schneems that this version of Ruby is available on Heroku...
13
u/schneems Puma maintainer Dec 26 '22
I’m on vacation in Hong Kong this year and Terence Lee is releasing but…
Now available on Heroku! https://devcenter.heroku.com/changelog-items/2515
18
u/flanger001 Dec 25 '22
That Struct auto-keyword initialization thing is something I have wanted in core Ruby forever and I hope that makes it all the way to the center of the language!
Data class is very anticipated.
Set being automatically loaded without requiring it is tight too.
5
5
2
u/schneems Puma maintainer Dec 26 '22
Set is a loose wrapper around Hash FWIW it’s pretty expensive to use.
7
u/jrochkind Dec 25 '22
I would love to hear more about YJIT. Who's using it in production? Should you expect increased RAM consumption, about how much?
11
u/f9ae8221b Dec 25 '22
Should you expect increased RAM consumption
Yes. All JIT (not just the ruby ones) necessarily increase memory usage as they need to store the compiled code as well as some runtime metadata used to compiled.
about how much?
That's configurable. By default YJIT will use up to 64MB of executable memory, but also use some space for runtime metadata, from our experience it's about 2 or 3x the executable memory.
So for a mid to large app I'd say about ~200MB per process, you can however configure it to use less, it just won't be able to optimize as much.
1
3
u/schneems Puma maintainer Dec 26 '22
Heroku compiled 3.2 with yjit support for anyone who wants to play with it in prod
1
u/brittballard Dec 30 '22
Is it enabled by default?
3
u/schneems Puma maintainer Dec 31 '22
You have to enable it with a flag or RUBYOPT env vars
heroku config:set RUBYOPT=’--enable-yjit’2
1
u/yeskia Oct 19 '23
Is there a difference between `--yjit` and `--enable-yjit`? `--enable-yjit` doesn't appear in the list when I run `ruby -h`
2
u/schneems Puma maintainer Oct 19 '23
I see it running locally and on Heroku:
$ ruby -v ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin22] $ ruby -h | grep jit --jit enable JIT for the platform, same as --yjit --mjit enable C compiler-based JIT compiler (experimental) --yjit enable in-process JIT compilerTo have it available your system needs rust when it compiles. Make sure you're using Ruby 3.2 and make sure rust is installed. Try uninstalling and reinstalling ruby. I use chruby + ruby-install.
1
u/yeskia Oct 19 '23
Whoa, appreciate the fast response!
Yeah - I see --yjit locally - I'm just not sure where `--enable-yjit` comes from or if there is a difference between the two. Does RUBYOPT need to be set to --enable-yjit or is just --yjit enough?
1
u/schneems Puma maintainer Oct 19 '23
The “enable” and “disable” are basically config variants of RUBYOPT https://stackoverflow.com/questions/59616020/what-are-the-options-for-rubyopt-env#59616442
6
3
1
u/jrochkind Dec 25 '22
Does anyone know if Rails 7.0.4 can be run on ruby 3.2?
With how Rails maintenance works, I don't think they'll ever add ruby 3.2 to CI for Rails 7.0? I'm not even sure when we can expect CI for ruby 3.2 passing for main/Rails 7.1, anyone know?
1
u/f9ae8221b Dec 25 '22 edited Dec 25 '22
Does anyone know if Rails 7.0.4 can be run on ruby 3.2?
Yes: https://twitter.com/yahonda/status/1606970580129185793
With how Rails maintenance works, I don't think they'll ever add ruby 3.2 to CI for Rails 7.0?
I have no clue what you are referring to, we test 7-0-stable against ruby-head, and we'll of course add 3.2: https://buildkite.com/rails/rails/builds/91968
I'm not even sure when we can expect CI for ruby 3.2 passing for main/Rails 7.1
I haven't looked at at Rails CI specifically, but our app CI pass with Ruby 3.2 and Rails main, so if there's any issue it's probably super easy to fix. That said, I don't know for others, but I'm in holiday, so I'll probably won't look at that for at least a week.
1
u/jrochkind Dec 25 '22
Sweet, thanks!
I misunderstood and did not think new ruby releases were added to not-most-recent Rails CI, based on what I thought I remembered from past versions but I may have been mistaken! (I don't believe there is any official written consistent policy on this (although I could be wrong again!), so it's possible it depends on the specific circumstances and decision in context by Rails team, and is not always the same, sure!)
I'm excited to upgrade my app to ruby 3.2! thanks for your work!
2
u/f9ae8221b Dec 25 '22
I don't believe there is any official written consistent policy on this
No, but but Rails isn't really bureaucratic. Just because something isn't written down doesn't mean we aren't gonna do it.
We always test the maintained versions against ruby-head and keep them compatible. Maybe we did need a last minute fix once or twice, but generally speaking if you are on latest Rails you can be on latest Ruby as well.
27
u/zverok_kha Dec 25 '22
Happy release day!
Annotated changes are expected to be ready somewhere before the New Year, hopefully.
(Next year, I plan to switch to following new features throughout the year instead of trying to manage everything in December.)