[ruby-core:62555] [ruby-trunk - Feature #9113] Ship Ruby for Linux with jemalloc out-of-the-box

From: normalperson@...
Date: 2014-05-13 04:09:49 UTC
List: ruby-core #62555
Issue #9113 has been updated by Eric Wong.


 nobu@ruby-lang.org wrote:
 > "linux-gnu" in "target_os" is substituted by "linux", so your AS_CASE never match.
 > You should check for libjemalloc availability instead, I think.
 
 I used $target, not $target_os.  An early version of my patch used
 $target_os, but I noticed it was a noop so I changed it to use $target.
 
 I've tested this with bare "./configure" and also --without-jemalloc.
 Both work as expected on my GNU/Linux systems.
 
 I worry this leads to platform-specific problems on non-GNU/Linux
 systems.  It seems varnish/redis only tries jemalloc on Linux, too.
 
 Also, I get one failure on both 32-bit and 64-bit:
 
 [1/1] Test_StringModifyExpand#test_modify_expand_memory_leak = 0.02 s
   1) Failure:
   Test_StringModifyExpand#test_modify_expand_memory_leak
   [/home/ew/ruby/test/-ext-/string/test_modify_expand.rb:7]:
   rb_str_modify_expand().
   size: 14307328 => 31084544..
   Expected 2.1726309762381906 to be < 1.5.
 
 It looks like certain allocation patterns are worse with jemalloc, but
 I think real-world apps use less memory.

----------------------------------------
Feature #9113: Ship Ruby for Linux with jemalloc out-of-the-box
https://bugs.ruby-lang.org/issues/9113#change-46707

* Author: Sam Saffron
* Status: Feedback
* Priority: Normal
* Assignee: 
* Category: build
* Target version: 
----------------------------------------
libc's malloc is a problem, it fragments badly meaning forks share less memory and is slow compared to tcmalloc or jemalloc. 

both jemalloc and tcmalloc are heavily battle tested and stable. 

2 years ago redis picked up the jemalloc dependency see: http://oldblog.antirez.com/post/everything-about-redis-24.html 

To quote antirez:
``
But an allocator is a serious thing. Since we introduced the specially encoded data types Redis started suffering from fragmentation. We tried different things to fix the problem, but basically the Linux default allocator in glibc sucks really, really hard. 
``

--- 

I recently benched Discourse with tcmalloc / jemalloc and default and noticed 2 very important thing: 

median request time reduce by up to 10% (under both)
PSS (proportional share size) is reduced by 10% under jemalloc and 8% under tcmalloc.

We can always use LD_PRELOAD to yank these in, but my concern is that standard distributions are using a far from optimal memory allocator. It would be awesome if the build, out-of-the-box, just checked if it was on Linux  (eg: https://github.com/antirez/redis/blob/unstable/src/Makefile#L30-L34 ) and then used jemalloc instead. 

---Files--------------------------------
0001-configure.in-add-with-jemalloc-option.patch (1.29 KB)


-- 
https://bugs.ruby-lang.org/

In This Thread