RVM install Ruby with jemalloc and YJIT
mouse 1099 · person cloud · link
Last update
2024-11-25
2024
11-25
« — »

Note: YJIT is only available on arm64 and aarch64.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
apt install rustc           # needed by YJIT
apt install libjemalloc-dev # needed by jemalloc

# install
rvm install ruby-3.3.0 -C --with-jemalloc --enable-yjit

# jemalloc test 1
MALLOC_CONF=stats_print:true rvm 3.3.0 do ruby -e "exit"

# jemalloc test 2
ldd `which ruby` | grep jemalloc
#   => libjemalloc.so.2 => /lib/aarch64-linux-gnu/libjemalloc.so.2

# YJIT test
ruby --yjit -v
#   => ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +YJIT [aarch64-linux]

# YJIT lazy loading:
ruby --yjit --yjit-disable -e "... ; RubyVM::YJIT.enable ; ..."

It's also possibile to apply jemalloc to a vanilla ruby:

1
2
# enable and test
LD_PRELOAD="libjemalloc.so.2" MALLOC_CONF=stats_print:true rvm 3.3.0 do ruby -e "exit"

Source: jemalloc @ stackoverflow.com, YJIT docs and RVM howto