Skip to content

Commit d2c0d69

Browse files
authored
[rails] Enable YJIT after boot (#9163)
There is no need to run the JIT on code that is only used during boot. This is also the new default in newer Rails applications.
1 parent b76dbf5 commit d2c0d69

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Automatically enable YJIT as of Ruby 3.3, as it bring very
2+
# sizeable performance improvements.
3+
4+
# If you are deploying to a memory constrained environment
5+
# you may want to delete this file, but otherwise it's free
6+
# performance.
7+
if defined? RubyVM::YJIT.enable
8+
Rails.application.config.after_initialize do
9+
RubyVM::YJIT.enable
10+
end
11+
end

frameworks/Ruby/rails/rails-mysql.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends redis-se
55
EXPOSE 8080
66
WORKDIR /rails
77

8-
ENV RUBY_YJIT_ENABLE=1
8+
# ENV RUBY_YJIT_ENABLE=1 YJIT is enabled in config/initializers/enable_yjit.rb
99

1010
# Use Jemalloc
1111
RUN apt-get update && \

frameworks/Ruby/rails/rails.dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends redis-se
55
EXPOSE 8080
66
WORKDIR /rails
77

8-
ENV RUBY_YJIT_ENABLE=1
8+
# ENV RUBY_YJIT_ENABLE=1 YJIT is enabled in config/initializers/enable_yjit.rb
9+
910
# Use Jemalloc
1011
RUN apt-get update && \
1112
apt-get install -y --no-install-recommends libjemalloc2

0 commit comments

Comments
 (0)