jemalloc: upgrade from 3.6.0 to 5.3.1 - #1096
Conversation
03bf43c to
815684f
Compare
|
Another aspects : ref fluent/fluentd#1657
|
|
in_tail with 1 GB file (rake benchmark:run:in_tail with fluent-package-builder master) It seems that total execution time takes a bit longer for jemalloc 5.3.1+MALLOC_CONF. jemalloc 3.6.0 jemalloc 5.3.1 vanilla jemalloc 5.3.1 + MALLOC_CONF tuning |
|
With dirty_decay_ms:0, it behaves similar to 3.6.0, but you must pay |
In the historical reasons, there are memory consumption issue between 4.x and 5.2.x for fluent-package. There are trade off about memory usage and performance, see MALLOC_CONF parameters in details: https://gist.github.com/jjb/9ff0d3f622c8bbe904fe7a82e35152fc With dirty_decay_ms:0, it behaves similar to 3.6.0, but you must pay performance penalty. dirty_decay_ms:1000 might be conservative approach for performance and memory usage, but it tends to use more memory in contrast to 3.6.0. dirty_decay_ms:400 strikes a well-balanced between memory usage and performance. (That situation might be changed in future jemalloc release or other practical benchmarks) Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
|
fluent-package-builder/fluent-package/Rakefile Lines 703 to 710 in d0be2a0 It looks like |
It supports 4k kernel and kernel-64 runtime. There is no need to apply only el7 and el8. Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
|
jemalloc 5.3 adds an unnecessary libstdc++ dependency to the package. Comparing the released 6.0.4 rpm with a 6.1.0 build: libjemalloc.so.2 is the only object in the package that gains a libstdc++.so.6 NEEDED entry. The shim only replaces the global operator new / operator delete. Disabling it does not take C++ allocations away from jemalloc — It seems we need to add the --disable-cxx option when configuring jemalloc: configure_opts = [
"--prefix=#{install_prefix}",
"--disable-cxx",
]fluent-package-builder/fluent-package/Rakefile Lines 699 to 701 in d0be2a0 |
Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
|
That situation was fixed: |
| Environment=FLUENT_PLUGIN=/etc/<%= package_dir %>/plugin | ||
| Environment=FLUENT_SOCKET=/var/run/<%= package_dir %>/<%= service_name %>.sock | ||
| Environment=FLUENT_PACKAGE_LOG_FILE=/var/log/<%= package_dir %>/<%= service_name %>.log | ||
| Environment=MALLOC_CONF="dirty_decay_ms:400,muzzy_decay_ms:0,narenas:2,background_thread:true,thp:never,abort_conf:true" |
There was a problem hiding this comment.
| Environment=MALLOC_CONF="dirty_decay_ms:400,muzzy_decay_ms:0,narenas:2,background_thread:true,thp:never,abort_conf:true" | |
| Environment=MALLOC_CONF="dirty_decay_ms:400,muzzy_decay_ms:0,narenas:2,background_thread:true,thp:never" |
Could we drop abort_conf:true from the shipped MALLOC_CONF?
jemalloc's default is to warn and ignore a bad conf entry; abort_conf:true turns it into abort(). And "bad" is broader than a misspelled option — a stray trailing comma is enough:
$ MALLOC_CONF="abort_conf:true,narenas:2," LD_PRELOAD=./libjemalloc.so.2 /bin/echo ok
<jemalloc>: Conf string ends with comma -- narenas:2,
<jemalloc>: Abort (abort_conf:true) on invalid conf value (see above).
exit=134 # SIGABRT, /bin/echo never runs
That matters here because EnvironmentFile=-/etc/sysconfig/fluentd comes after Environment=MALLOC_CONF=..., so overriding it is the intended path for operators. A small typo there would now kill fluentd during malloc init — before it opens its log file, so nothing appears in fluentd.log. LD_PRELOAD also applies to ExecStop=/bin/kill, so systemctl stop would fail as well.
Dropping it doesn't change any of the other five settings.
There was a problem hiding this comment.
I believe it is better not to allow configuration errors about MALLOC_CONF.
For example, if a typo exists about dirty_decay_ms, it fallback to default.
Thus it changes the behavior about memory usage a lot.
Of course, there is a merit not to abort, but it might be critical in production.


In the historical reasons, there are memory consumption issue between 4.x and 5.2.x for fluent-package.
Since 5.3.x, the situation seems changed about that issue, upgrade it from 3.6.0.
There are trade of about memory and performance, adopted already tuned MALLOC_CONF parameters from here:
https://gist.github.com/jjb/9ff0d3f622c8bbe904fe7a82e35152fc