CircleCI-Public / cimg-ruby

The CircleCI Ruby Docker Convenience Image.
https://circleci.com/developer/images/image/cimg/ruby
MIT License
33 stars 39 forks source link

Ruby 3.2 with YJIT Enabled #108

Closed gremerritt closed 1 year ago

gremerritt commented 1 year ago

Are there plans to offer an image for an yjit-enabled ruby 3.2? Or to enable yjit on the standard 3.2 image?

krzyczak commented 1 year ago

Isn't it enough to either set RUBY_YJIT_ENABLE=1 or RUBYOPT="--yjit"?

gremerritt commented 1 year ago

No, ruby needs to be compiled with support to enable the runtime setting:

circleci@c7c638735d36:~/project$ export RUBY_YJIT_ENABLE=1
circleci@c7c638735d36:~/project$ export RUBYOPT=1
circleci@c7c638735d36:~/project$ ruby --yjit --version
ruby: warning: Ruby was built without YJIT support. You may need to install rustc to build Ruby with YJIT.
ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]
gremerritt commented 1 year ago

Perhaps poor phrasing in my initial report. I'm not suggesting the runtime setting be enabled by default, just that the ruby build support it.

glaucocustodio commented 1 year ago

I've migrated to https://github.com/docker-library/ruby, it already supports YJIT, this is the relevant part of my Dockerfile now:

# use  `docker build --platform linux/amd64 -t my_app .` to build on Apple Silicon if getting amd64 error
FROM ruby:3.2-bullseye

USER root

# install Rails deps
RUN apt-get update && apt-get install -y \
  ffmpeg \
  libxml2-dev \
  memcached \
  mupdf \
  mupdf-tools \
  imagemagick \
  libpq-dev

# install Chrome
RUN apt-get update && apt-get install curl gnupg -y \
  && curl --location --silent https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
  && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
  && apt-get update \
  && apt-get install google-chrome-stable -y --no-install-recommends \
  && rm -rf /var/lib/apt/lists/*

# enable YJIT
ENV RUBYOPT --yjit
sebaherrera07 commented 1 year ago

I wonder if there are any plans to support YJIT in cimg-ruby soon?