What is New in Ruby 3.3
Ruby 3.3 brings significant performance gains, especially through YJIT improvements, a new parser with Prism, an experimental M:N thread scheduler, and many updates to the garbage collector and standard libraries. It focuses on speed, concurrency, and better tooling while maintaining compatibility.
Performance Improvements
YJIT has been greatly enhanced compared to Ruby 3.2:
- Support for splat/rest arguments and better handling of calls with optional parameters.
- Register allocation improvements and optimized handling of exception handlers.
- Special optimizations for common methods like
#blank?,#present?,Integer#*,String#getbyte,Kernel#block_given?, and others. - Faster compilation and much lower memory usage.
- New command-line options such as
--yjit-call-threshold=120,--yjit-cold-threshold, and--yjit-exec-mem-size. - Runtime enabling with
RubyVM::YJIT.enable. - More detailed statistics available by default.
Other general optimizations include:
- Faster
defined?(@ivar)using Object Shapes. - Interruptible
Socket.getaddrinfo. - Garbage Collector changes to reduce major collections by delaying promotion of young objects.
- Variable Width Allocation for most core classes, leading to faster object creation and less memory fragmentation.
- Support for weak references in more scenarios.
Parser Changes
Prism is introduced as a new default gem and serves as an alternative parser:
- A portable, error-tolerant, and maintainable recursive descent parser written in Ruby.
- Provides methods like
Prism.parse(source)for AST,Prism.parse_comments, andPrism.parse_success?. - Can be activated with
--parser=prismflag for debugging.
Lrama replaces Bison as the parser generator, and the internal parser now uses an LR parser generated by Racc with support for parameterized rules.
Ractor and Concurrency Enhancements
An experimental M:N thread scheduler is added:
- Maps multiple Ruby threads to fewer native threads for lower overhead.
- Enabled with
RUBY_MN_THREADS=1(disabled by default on the main Ractor for C-extension compatibility). - Limited by
RUBY_MAX_CPUenvironment variable (default 8). - Always active on non-main Ractors.
Standard Library Updates
New default gem: prism 0.19.0.
Many default and bundled gems have been updated to newer versions, including:
bigdecimal 3.1.5irb 1.11.0psych 5.1.2rdoc 6.6.2rake 13.1.0- And many others like
rexml,debug, andopenssl.
racc 1.7.3 is promoted to default gem status.
Warnings are now shown when requiring certain bundled gems without declaring them in Gemfile or gemspec (can be suppressed with Bootsnap).
IRB receives major improvements:
- Deep integration with the debugger (
irb:rdbgfor stepping and breakpoints). - Better output paging and accurate method/source listing.
- Experimental type-based autocompletion.
- Customizable colors and styles.
Compatibility and Deprecation Notes
- The
ext/readlineextension is retired; use the pure-Rubyrelineinstead (compatible API). itwithout arguments in blocks with no parameters is deprecated.Regexp.newaccepts only up to two arguments.- Some environment variables like
RUBY_GC_HEAP_INIT_SLOTSare removed or ignored.
Other Notable Changes
- RJIT is introduced as a new experimental pure-Ruby JIT compiler (replaces MJIT), supporting x86-64 on Unix platforms without needing a C compiler at runtime.
- Enhanced profiling and tracing options for YJIT.
- Overall focus on better performance, modern tooling, and preparation for future concurrency improvements.