Skip to content

Commit 0add5db

Browse files
authored
Merge pull request rails#50943 from northeastprince/jemalloc
Setup jemalloc in default Dockerfile to optimize memory allocation
2 parents 3d132b8 + 8e98b61 commit 0add5db

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

railties/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Setup jemalloc in the default Dockerfile for memory optimization.
2+
3+
*Matt Almeida*, *Jean Boussier*
4+
15
* Commented out lines in .railsrc file should not be treated as arguments when using
26
rails new generator command. Update ARGVScrubber to ignore text after # symbols.
37

railties/lib/rails/generators/app_base.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,9 @@ def dockerfile_deploy_packages
595595
# ActiveStorage preview support
596596
packages << "libvips" unless skip_active_storage?
597597

598+
# jemalloc for memory optimization
599+
packages << "libjemalloc2"
600+
598601
packages.compact.sort
599602
end
600603

railties/lib/rails/generators/rails/app/templates/docker-entrypoint.tt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash -e
22

3+
# Enable jemalloc for reduced memory usage and reduce latency.
4+
if [ -f /usr/lib/*/libjemalloc.so.2 ]; then
5+
LD_PRELOAD="$(echo /usr/lib/*/libjemalloc.so.2) $LD_PRELOAD"
6+
fi
7+
38
<% unless skip_active_record? -%>
49
# If running the rails server then create or migrate existing database
510
if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then

0 commit comments

Comments
 (0)