]> cat aescling's git repositories - mastodon.git/commitdiff
Preload libjemalloc.so for long-running Ruby (#16462)
authorAkihiko Odaki <akihiko.odaki@gmail.com>
Mon, 5 Jul 2021 17:16:35 +0000 (02:16 +0900)
committerGitHub <noreply@github.com>
Mon, 5 Jul 2021 17:16:35 +0000 (19:16 +0200)
Always mark jemalloc needed if jemalloc is enabled by akihikodaki · Pull Request #4627 · ruby/ruby
https://github.com/ruby/ruby/pull/4627
> Symbols exported by jemalloc is referred by the shared library but not
> by the executables when building Ruby as a shared library with
> jemalloc. It causes shared libraries such as the GNU C++ library
> occasionally rely on the memory allocator provided by the standard C
> library. Worse, the resolved symbols can later be replaced with
> jemalloc, and jemalloc may see pointers from the standard C library,
> which results in various failures.
> e.g. https://github.com/tootsuite/mastodon/issues/15751

As a workaround, do not rely on jemalloc enablement of Ruby, and
preload libjemalloc.so instead.

dist/mastodon-sidekiq.service
dist/mastodon-web.service

index 9dd21b8a005e8dc121b2a17ca27a39674030f6f2..35b121cd77ea6c83b8f146d0fab61b8427574d9d 100644 (file)
@@ -9,6 +9,7 @@ WorkingDirectory=/home/mastodon/live
 Environment="RAILS_ENV=production"
 Environment="DB_POOL=25"
 Environment="MALLOC_ARENA_MAX=2"
+Environment="LD_PRELOAD=libjemalloc.so"
 ExecStart=/home/mastodon/.rbenv/shims/bundle exec sidekiq -c 25
 TimeoutSec=15
 Restart=always
index c106a48608c663728911d2794c38d64bc33ba412..f41efd2b095d238bae688b04c0e38a3ca619ed8c 100644 (file)
@@ -8,6 +8,7 @@ User=mastodon
 WorkingDirectory=/home/mastodon/live
 Environment="RAILS_ENV=production"
 Environment="PORT=3000"
+Environment="LD_PRELOAD=libjemalloc.so"
 ExecStart=/home/mastodon/.rbenv/shims/bundle exec puma -C config/puma.rb
 ExecReload=/bin/kill -SIGUSR1 $MAINPID
 TimeoutSec=15