ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: dennisb55@hotmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:88223] [Ruby trunk Feature#14718] Use jemalloc by default?
Date: Tue, 31 Jul 2018 00:31:02 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-73242.20180731003101.6519ba9d2e288b09@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-14718.20180427161410@ruby-lang.org

Issue #14718 has been updated by bluz71 (Dennis B).


davidtgoldblatt (David Goldblatt) wrote:
> I don't think this benchmark is a useful way to compare performance between versions 3 and 5 of jemalloc. In between them was the advent of time-based purging, where the allocator waits for a while (by default, around 10 seconds) before returning memory to the OS. That purging occurs (well, in the default but not recommended case where background threads are disabled) on an operation counter tick. By having low activity for a short program lifetime, it effectively disables returning memory to the OS, in a way that wouldn't actually persist if you were running a more realistic program. Even outside of that, we've started using MADV_FREE, which gives the kernel the right to reclaim memory, but in such a way that it will only do so if the machine is actually under memory pressure; this won't show up in test runs unless you're trying to make it happen.
> 
> You could verify this by setting dirty decay and muzzy decay to 0 in the MALLOC_CONF environment variable (i.e. MALLOC_CONF="dirty_decay_ms:0,muzzy_decay_ms:0", unless I've typoed something).

Very interesting indeed.

I suspect many of us were not aware of that, I certainly wasn't. All the micro-testing conducted here and at [#14759](https://bugs.ruby-lang.org/issues/14759) indicated a large regression in jemalloc RSS behaviour post 3.X series.

This is a difficult one. I wonder if we need to transistion across to Noah Gibbs Rails benchmark?

Nevertheless this usage graph posted by Micke Perham is indicative of what many users experience with long-lived production Ruby applications on Linux:

![jemalloc](https://www.mikeperham.com/images/jemalloc.jpg)


----------------------------------------
Feature #14718: Use jemalloc by default?
https://bugs.ruby-lang.org/issues/14718#change-73242

* Author: mperham (Mike Perham)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I know Sam opened #9113 4 years ago to suggest this but I'm revisiting the topic to see if there's any movement here for Ruby 2.6 or 2.7.  I supply a major piece of Ruby infrastructure (Sidekiq) and I keep hearing over and over how Ruby is terrible with memory, a huge memory hog with their Rails apps.  My users switch to jemalloc and a miracle occurs: their memory usage drops massively.  Some data points:

https://twitter.com/brandonhilkert/status/987400365627801601
https://twitter.com/d_jones/status/989866391787335680
https://github.com/mperham/sidekiq/issues/3824#issuecomment-383072469

Redis moved to jemalloc many years ago and it solved all of their memory issues too.  Their conclusion: the glibc allocator "sucks really really hard". http://oldblog.antirez.com/post/everything-about-redis-24.html

This is a real pain point for the entire Rails community and would improve Ruby's reputation immensely if we can solve this problem.

---Files--------------------------------
glibc_arena_2.png (7.23 KB)
jemalloc.png (21.1 KB)
glibc-arena-2.log (60.3 KB)
glibc.log (62.3 KB)
jemalloc-3-5.log (58.5 KB)
glibc.png (9.03 KB)


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

  parent reply	other threads:[~2018-07-31  0:31 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-14718.20180427161410@ruby-lang.org>
2018-04-27 16:14 ` [ruby-core:86725] [Ruby trunk Feature#14718] Use jemalloc by default? mperham
2018-04-27 18:12   ` [ruby-core:86731] " Eric Wong
2018-04-27 18:13     ` [ruby-core:86732] " Koichi Sasada
2018-04-27 16:30 ` [ruby-core:86726] " merch-redmine
2018-04-27 16:38 ` [ruby-core:86728] " mperham
2018-04-27 18:50 ` [ruby-core:86734] " shevegen
2018-04-27 19:28 ` [ruby-core:86735] " rr.rosas
2018-04-27 19:59 ` [ruby-core:86736] " rr.rosas
2018-04-27 21:59 ` [ruby-core:86738] " mperham
2018-04-28  4:36 ` [ruby-core:86742] " the.codefolio.guy
2018-04-28 19:52 ` [ruby-core:86752] " nobu
2018-04-28 20:33 ` [ruby-core:86753] " mperham
2018-04-29  8:21 ` [ruby-core:86760] " shyouhei
2018-04-30 15:57 ` [ruby-core:86777] " mperham
2018-05-01  1:46 ` [ruby-core:86786] " shyouhei
2018-05-02 17:31 ` [ruby-core:86843] " mperham
2018-05-02 21:00   ` [ruby-core:86844] " Eric Wong
2018-05-15  8:33     ` [ruby-core:87036] " Eric Wong
2018-05-08  2:27 ` [ruby-core:86936] " davidtgoldblatt
2018-05-08  3:34 ` [ruby-core:86938] " mame
2018-05-10  5:11 ` [ruby-core:86962] " dennisb55
2018-05-10  5:37 ` [ruby-core:86964] " dennisb55
2018-05-10  5:55 ` [ruby-core:86965] " merch-redmine
2018-05-10  6:26 ` [ruby-core:86966] " dennisb55
2018-05-10 17:20 ` [ruby-core:86971] " merch-redmine
2018-05-11  1:31 ` [ruby-core:86975] " shyouhei
2018-05-11  2:19   ` [ruby-core:86978] " Eric Wong
2018-05-11  3:01 ` [ruby-core:86979] " mame
2018-05-11  3:28 ` [ruby-core:86982] " dennisb55
2018-05-11  3:38 ` [ruby-core:86984] " dennisb55
2018-05-11  4:00 ` [ruby-core:86985] " dennisb55
2018-05-11  4:07 ` [ruby-core:86986] " dennisb55
2018-05-11 16:23 ` [ruby-core:86999] " mperham
2018-05-12  0:58 ` [ruby-core:87003] " dennisb55
2018-05-14  0:09 ` [ruby-core:87012] " shyouhei
2018-05-14  2:14 ` [ruby-core:87014] " dennisb55
2018-05-14  3:16 ` [ruby-core:87015] " shyouhei
2018-05-14  6:42 ` [ruby-core:87016] " dennisb55
2018-05-14  7:33 ` [ruby-core:87017] " sam.saffron
2018-05-14  7:53 ` [ruby-core:87020] " shyouhei
2018-05-14  8:30 ` [ruby-core:87023] " dennisb55
2018-05-14 15:58 ` [ruby-core:87027] " mperham
2018-05-14 16:31 ` [ruby-core:87028] " wyhaines
2018-05-15  3:49 ` [ruby-core:87031] " mame
2018-05-15  7:17 ` [ruby-core:87033] " sam.saffron
2018-05-15 23:16 ` [ruby-core:87048] " mperham
2018-05-16  5:11 ` [ruby-core:87060] " dennisb55
2018-05-16  5:14 ` [ruby-core:87061] " dennisb55
2018-05-16  5:29 ` [ruby-core:87064] " mperham
2018-05-16  5:54 ` [ruby-core:87065] " dennisb55
2018-05-16  9:09   ` [ruby-core:87071] " Eric Wong
2018-05-16 18:45 ` [ruby-core:87086] " mperham
2018-05-16 19:22 ` [ruby-core:87087] " merch-redmine
2018-05-16 20:12 ` [ruby-core:87088] " mperham
2018-05-16 23:54 ` [ruby-core:87090] " mame
2018-05-17 17:31 ` [ruby-core:87145] " mperham
2018-05-18  3:10 ` [ruby-core:87154] " dennisb55
2018-05-18  3:13 ` [ruby-core:87155] " dennisb55
2018-05-18  3:19 ` [ruby-core:87156] " dennisb55
2018-05-18  3:49 ` [ruby-core:87159] " mperham
2018-05-18  4:10 ` [ruby-core:87160] " dennisb55
2018-05-18  7:59   ` [ruby-core:87164] " Eric Wong
2018-05-19  2:55 ` [ruby-core:87186] " dennisb55
2018-05-22  1:12   ` [ruby-core:87216] " Vladimir Makarov
2018-05-23  2:57   ` [ruby-core:87230] " Eric Wong
2018-05-22 16:25 ` [ruby-core:87224] " mperham
2018-05-22 20:22 ` [ruby-core:87225] " mperham
2018-05-23  0:38 ` [ruby-core:87229] " dennisb55
2018-05-23  4:22 ` [ruby-core:87231] " mperham
2018-05-29 20:34 ` [ruby-core:87299] " edchick
2018-06-23 18:39 ` [ruby-core:87616] " v.ondruch
2018-06-25  0:36 ` [ruby-core:87626] " nobu
2018-07-26 18:51 ` [ruby-core:88127] " carlos
2018-07-29  1:18 ` [ruby-core:88156] " andregsakata
2018-07-29  4:27 ` [ruby-core:88161] " dennisb55
2018-07-29  4:31 ` [ruby-core:88162] " dennisb55
2018-07-29  7:45 ` [ruby-core:88163] " fweimer
2018-07-30 10:16   ` [ruby-core:88192] " Eric Wong
2018-08-01  1:00     ` [ruby-core:88244] " Eric Wong
2018-07-29  8:38 ` [ruby-core:88164] " fweimer
2018-07-29 15:16 ` [ruby-core:88165] " andregsakata
2018-07-29 16:34 ` [ruby-core:88166] " andregsakata
2018-07-29 17:39 ` [ruby-core:88168] " andregsakata
2018-07-30 12:16 ` [ruby-core:88195] " fweimer
2018-07-30 13:16 ` [ruby-core:88196] " andregsakata
2018-07-30 13:20 ` [ruby-core:88197] " fweimer
2018-07-30 16:16 ` [ruby-core:88208] " andregsakata
2018-07-30 20:27 ` [ruby-core:88216] " davidtgoldblatt
2018-07-30 22:46 ` [ruby-core:88220] " andregsakata
2018-07-31  0:31 ` dennisb55 [this message]
2018-08-01  0:14 ` [ruby-core:88238] " sam.saffron
2018-08-01  9:55   ` [ruby-core:88256] " Eric Wong
2018-08-01  0:55 ` [ruby-core:88243] " mperham
2018-08-01  2:12 ` [ruby-core:88245] " sam.saffron
2018-08-01  3:41 ` [ruby-core:88247] " dennisb55
2018-08-02  0:04 ` [ruby-core:88266] " sam.saffron
2019-02-07  3:53 ` [ruby-core:91445] " mame
2019-02-09  4:42 ` [ruby-core:91499] " dennisb55
2019-03-14 16:52 ` [ruby-core:91832] " msiegel
2019-03-14 20:02 ` [ruby-core:91836] " fredngo
2019-03-14 20:35 ` [ruby-core:91838] " sam.saffron
2019-03-15  6:50 ` [ruby-core:91843] " dennisb55

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-73242.20180731003101.6519ba9d2e288b09@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).