Preload libjemalloc.so for long-running Ruby (#16462)
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.
This commit is contained in:
		
							parent
							
								
									67226acf7e
								
							
						
					
					
						commit
						8af7f3b063
					
				
					 2 changed files with 2 additions and 0 deletions
				
			
		
							
								
								
									
										1
									
								
								dist/mastodon-sidekiq.service
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								dist/mastodon-sidekiq.service
									
									
									
									
										vendored
									
									
								
							|  | @ -9,6 +9,7 @@ WorkingDirectory=/home/mastodon/live | ||||||
| Environment="RAILS_ENV=production" | Environment="RAILS_ENV=production" | ||||||
| Environment="DB_POOL=25" | Environment="DB_POOL=25" | ||||||
| Environment="MALLOC_ARENA_MAX=2" | Environment="MALLOC_ARENA_MAX=2" | ||||||
|  | Environment="LD_PRELOAD=libjemalloc.so" | ||||||
| ExecStart=/home/mastodon/.rbenv/shims/bundle exec sidekiq -c 25 | ExecStart=/home/mastodon/.rbenv/shims/bundle exec sidekiq -c 25 | ||||||
| TimeoutSec=15 | TimeoutSec=15 | ||||||
| Restart=always | Restart=always | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								dist/mastodon-web.service
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								dist/mastodon-web.service
									
									
									
									
										vendored
									
									
								
							|  | @ -8,6 +8,7 @@ User=mastodon | ||||||
| WorkingDirectory=/home/mastodon/live | WorkingDirectory=/home/mastodon/live | ||||||
| Environment="RAILS_ENV=production" | Environment="RAILS_ENV=production" | ||||||
| Environment="PORT=3000" | Environment="PORT=3000" | ||||||
|  | Environment="LD_PRELOAD=libjemalloc.so" | ||||||
| ExecStart=/home/mastodon/.rbenv/shims/bundle exec puma -C config/puma.rb | ExecStart=/home/mastodon/.rbenv/shims/bundle exec puma -C config/puma.rb | ||||||
| ExecReload=/bin/kill -SIGUSR1 $MAINPID | ExecReload=/bin/kill -SIGUSR1 $MAINPID | ||||||
| TimeoutSec=15 | TimeoutSec=15 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue