Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade ruby to 2.7 and jemalloc to v5 #4027

Merged
merged 6 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run_tests_CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- Gemfile
- Gemfile.next
ruby:
- 2.6
- 2.7
spec-commands:
- 'spec/controllers/api/v1/[a-m]*.rb spec/counters spec/operations spec/serializers spec/workers'
- 'spec/controllers/api/v1/[n-s]*.rb'
Expand Down
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# debian stretch has libjemalloc1 https://packages.debian.org/stretch/libjemalloc1
FROM ruby:2.6-slim-stretch
FROM ruby:2.7-slim

WORKDIR /rails_app

Expand All @@ -8,15 +7,19 @@ RUN apt-get update && apt-get -y upgrade && \
build-essential \
# git is required for installing gems from git repos
git \
# libjemalloc1 (v3) provides big memory savings vs jemalloc v5+ (default on debian buster)
libjemalloc1 \
# install jemalloc (v5) for memory savings
libjemalloc2 \
libpq-dev \
nodejs \
tmpreaper \
&& \
apt-get clean

ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1
# configure jemalloc v5 with v3 behaviours (trade ram usage over performance)
# https://twitter.com/nateberkopec/status/1442894624935137288
# https://github.com/code-dot-org/code-dot-org/blob/5c8b24674d1c2f7e51e85dd32124e113dc423d84/cookbooks/cdo-jemalloc/attributes/default.rb#L10
ENV MALLOC_CONF="narenas:2,background_thread:true,thp:never,dirty_decay_ms:1000,muzzy_decay_ms:0"
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2

# set a default RAILS_ENV for the build scripts
# this is required for the `rake assets:precompile` script
Expand All @@ -28,6 +31,7 @@ ADD ./Gemfile /rails_app/
ADD ./Gemfile.lock /rails_app/

RUN bundle config --global jobs `cat /proc/cpuinfo | grep processor | wc -l | xargs -I % expr % - 1`
RUN gem update --system
RUN bundle install --without development test

ADD ./ /rails_app
Expand Down
8 changes: 6 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:2.6-slim-buster
FROM ruby:2.7-slim-buster

WORKDIR /rails_app

Expand All @@ -8,14 +8,18 @@ RUN apt-get update && apt-get -y upgrade && \
# git is required for installing gems from git repos
git \
libpq-dev \
# debian buster has v11 by default
# debian buster and comes with pg client v11 by default
postgresql-client-11 \
tmpreaper

# set MRI memory allocator to mimic jemalloc memory savings
ENV MALLOC_ARENA_MAX=2

ADD ./Gemfile /rails_app/
ADD ./Gemfile.lock /rails_app/

RUN bundle config --global jobs `cat /proc/cpuinfo | grep processor | wc -l | xargs -I % expr % - 1`
RUN gem update --system
RUN bundle install

ADD ./ /rails_app
Expand Down