Jemalloc 5.4.0

(github.com)

277 points by gkfasdfasdf12 hours ago

9 comments

  • vocx2tx10 hours ago
    For some context on why this release is notable: Jemalloc Postmortem [0]<p>[0] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=44264958">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=44264958</a>
    • ezst5 hours ago
      &gt; I don’t want to dwell on drama, but it is perhaps worth mentioning that we reached a sad end for jemalloc in the hands of Facebook&#x2F;Meta even though most of the people involved were acting in good faith.<p>Far from the only case. Trillion dollar companies having sudden interest in your open source project is not necessarily a long term benefit.
    • eatonphil4 hours ago
      And some additional context from a few months ago, building off the postmortem.<p><a href="https:&#x2F;&#x2F;theconsensus.dev&#x2F;p&#x2F;2026&#x2F;04&#x2F;16&#x2F;who-even-uses-jemalloc-anyway.html" rel="nofollow">https:&#x2F;&#x2F;theconsensus.dev&#x2F;p&#x2F;2026&#x2F;04&#x2F;16&#x2F;who-even-uses-jemalloc...</a>
      • nextaccountic1 hour ago
        Also, 7 months ago, <a href="https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;jemalloc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;jemalloc</a> said<p>&gt; Development of Jemalloc will transition back to the original open source project: <a href="https:&#x2F;&#x2F;github.com&#x2F;jemalloc&#x2F;jemalloc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jemalloc&#x2F;jemalloc</a>. Meta’s fork of the Jemalloc project will be fully archived as part of the transition. We look forward to continuing the collaboration with the community to drive jemalloc.<p>&gt; See blog post for details: <a href="https:&#x2F;&#x2F;engineering.fb.com&#x2F;2026&#x2F;03&#x2F;02&#x2F;data-infrastructure&#x2F;investing-in-infrastructure-metas-renewed-commitment-to-jemalloc&#x2F;" rel="nofollow">https:&#x2F;&#x2F;engineering.fb.com&#x2F;2026&#x2F;03&#x2F;02&#x2F;data-infrastructure&#x2F;in...</a>
  • ggg0110128 minutes ago
    Nice to see jemalloc active again. The long-term health of the upstream project is probably just as important as the allocator improvements themselves.
  • lordnacho8 hours ago
    I always wondered, is it French? &quot;Je m&#x27;alloc du memory&quot;
    • sam_lowry_8 hours ago
      Rather a tradition to call a malloc by the initials of the implementer: Jason Evans malloc (jemalloc), Poul-Henning Kamp malloc (phkmalloc), Doug Lea (dlmalloc).<p>P.S. I also wondered whether systemd had any cultural reference to Système D aka Système Débrouillard, but Pottering does not seem to engage in word play on other occasions, so probably not.
      • justincormack6 hours ago
        It does<p>&gt; Systemd was launched in April 2010; it adopts various ideas from previous init systems and combines them with a uniform configuration and administration interface. Systemd operates as a background service (daemon) and controls important system configuration tasks including hardware initialisation and the starting of server processes. The developers thought that its name is suitably reminiscent of the French term &quot;système D&quot;, an expression that relates to &quot;thinking on your feet&quot; and describes high-speed technical problem-solving abilities such as those displayed by TV action hero MacGyver.<p><a href="https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20121014173559&#x2F;http:&#x2F;&#x2F;www.h-online.com&#x2F;open&#x2F;features&#x2F;Control-Centre-The-systemd-Linux-init-system-1565543.html" rel="nofollow">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20121014173559&#x2F;http:&#x2F;&#x2F;www.h-onli...</a>
      • tefkah7 hours ago
        damn i always thought it was a french thing, this is blowing my mind
        • eliaspro7 hours ago
          &quot;Yes, it is written systemd, not system D or System D, or even SystemD. And it isn&#x27;t system d either. Why? Because it&#x27;s a system daemon, and under Unix&#x2F;Linux those are in lower case, and get suffixed with a lower case d.&quot;<p>Source: <a href="https:&#x2F;&#x2F;brand.systemd.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;brand.systemd.io&#x2F;</a>
        • fizzbuzzbarbazz2 hours ago
          you were right, check siblings of your comment.
    • jibcage6 hours ago
      Fun grammatical fact that I only learned after years of speaking French: when borrowing words from other languages, you usually (not always) take the gender of the equivalent word in French, so technically it would be “de la memory” :)
      • thrance6 hours ago
        That&#x27;s the rule the old geezers at the Academy insist on. But then you have idiotic situations where everyone is using &quot;le&quot; for e.g. the COVID virus, while Academicians cry about the D meaning &quot;Disease&quot;, which is feminine, making it &quot;la COVID&quot; in their book. As for all languages, the most important rule is that usage prevails. And that&#x27;s something we in France still have a hard time integrating into public discourse.
        • progval6 hours ago
          An interesting case is &quot;WiFi&quot;, short for &quot;wireless fidelity&quot;. &quot;Fidélité sans fil&quot; in French should be feminine, but every technical person says &quot;le WiFi&quot; (masculine) while many (most?) non-technical people intuitively say &quot;la WiFi&quot; (feminine).
          • ButlerianJihad6 hours ago
            If you keep your access point secure and in good working order, or if you can flash any firmware into OpenWRT... make sure to publicly credit your excellent &quot;Wi-fu&quot;
            • hobo1235 hours ago
              Better keep the wifi working, or your waifu could get angry.
    • simonask8 hours ago
      Thanks, now my brain will forever read it like that. I&#x27;m not even a little bit French.
    • u80807 hours ago
      Memory je Srbia
  • atombender1 hour ago
    I use Jemalloc on a project because it has per-thread allocation counters. This lets me not only track what each thread is using, but also restrict workloads by enforcing a memory budget. Since my application is almost completely CPU-bound, I allocate one thread per core and then have some smart scheduling to route requests to the threads. I looked at tcmalloc and mimalloc, and neither had this feature at the time, nor did they seem to have any similar feature that could let me have per-thread heaps, which surprised me.
  • throw0101a5 hours ago
    Related, from three days ago, &quot;Comparison of Malloc() Algorithms&quot;:<p>* <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=49715318">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=49715318</a>
  • albertgoeswoof6 hours ago
    I switched to jemalloc on a sidekiq queue and memory dropped from 8gib to under 1gib<p>There’s a slow memory leak somewhere in my code but with jemalloc it no longer actually matters.<p>Thanks to jemalloc team for this!
    • nvartolomei3 hours ago
      <a href="https:&#x2F;&#x2F;devblogs.microsoft.com&#x2F;oldnewthing&#x2F;20180228-00&#x2F;?p=98125" rel="nofollow">https:&#x2F;&#x2F;devblogs.microsoft.com&#x2F;oldnewthing&#x2F;20180228-00&#x2F;?p=98...</a>
      • paper2d1 hour ago
        This is the most funny thing I read today!
  • skavi7 hours ago
    does anyone familiar with the art have thoughts on why only tcmalloc switched from thread caches to cpu caches? would it make linux behavior diverge too much from other platforms?
    • rwmj7 hours ago
      (Not an expert but ...) unless you pin threads to cores, which is not the default and somewhat awkward in Linux for user applications, having a per-thread cache doesn&#x27;t really make sense as your thread could be moved to another core and then your cache will no longer be local to the physical cache.
      • skavi5 hours ago
        i think we agree that per cpu caching seems superior. i’m looking for the other side of this. most allocators seem to have stuck with per thread.
        • Someone4 hours ago
          If you use a thread-local data structure, your allocator can pretend that it is running on a single-core, single-task system.<p>If you use a CPU-local data structure, you must handle the case where, mid-way through a call to your allocator, the CPU runs a second thread that makes another call to your allocator (and that, too, can get interrupted by another thread that allocates memory, etc.)<p>That makes thread-local easier to implement and likely faster (it doesn’t require any memory barriers in the fast path)<p>Also, good schedulers try to avoid moving threads between CPUs. The better they manage to do that, the lower the cost of having per thread data structures (there likely still is a price, as there most of the time are more threads than CPUs on a system)
          • skavi4 hours ago
            <a href="https:&#x2F;&#x2F;google.github.io&#x2F;tcmalloc&#x2F;rseq.html" rel="nofollow">https:&#x2F;&#x2F;google.github.io&#x2F;tcmalloc&#x2F;rseq.html</a><p>i don’t believe rseq based cpu local caches require memory barriers on the fast path.
            • Someone2 hours ago
              <a href="https:&#x2F;&#x2F;lwn.net&#x2F;Articles&#x2F;1033957&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lwn.net&#x2F;Articles&#x2F;1033957&#x2F;</a>:<p><pre><code> rseq_cs The rseq_cs field is a pointer to a struct rseq_cs. Is is NULL when no rseq assembly block critical section is active for the registered thread. Setting it to point to a critical section descriptor (struct rseq_cs) marks the beginning of the critical section. </code></pre> I’m not sure I fully understand that man page (it never seems to say callers have to clear that field at the end of a critical section, for example), but doesn’t that mean the caller has to guarantee setting <i>rseq_cs</i> happens_before any code in the critical section? That’s a memory barrier.
              • Veserv15 minutes ago
                That is because you do not need to clear the field at the end of a critical section. It contains the contiguous instruction range where it fires so there is no problem with leaving it active forever unless you have another critical section where you want to use it.<p>No explicit memory barrier is required anywhere as the value is only read in supervisor mode and a privilege switch implicitly issues a LS-LS barrier on all major architectures. Even if you did not want to rely on that, you would only need a single S-LS barrier when you store the control structure the very first time.
            • fc417fc8023 hours ago
              Setting aside whether or not you can pull off a lock free approach here we can be certain of a couple things. There will be at least some overhead that must be paid <i>somewhere</i> even if that&#x27;s on a separate management thread. And there will be a lot of additional complexity because that&#x27;s just how concurrency always is.<p>Meanwhile the better the scheduler performs the more competitive the thread local approach becomes.
      • jeffbee43 minutes ago
        Exactly. You want memory arenas that are hot in <i>this CPU&#x27;s</i> caches. If your thread moves, its per-thread caches are now elsewhere. Original TCMalloc was developed in the days of 2-4 core servers. Current TCMalloc was an evolution in the context of 32+ core servers.
    • enduku7 hours ago
      I think tcmalloc gains on thread churn and oversubscription by going the cpu-cache route on Linux. on other platforms, I am not so sure but that can be offset by say a treiber-stack like setup for cross-thread frees&#x2F;teardowns. So lesser code for Linux for similar fastpath design I guess.
      • jeffbee42 minutes ago
        &gt; on other platforms, I am not so sure<p>tcmalloc only works on Linux.
  • ksec8 hours ago
    Ok. Why both the homepage and its Github repo doesn&#x27;t make a single mention of Jason Evans? I know he stepped down but surely it is at least worst mentioning it?<p>Is Meta still using it and developing it? If not who are the driving force behind it now? I just checked there wasn&#x27;t a release since 2022 and then we have this now. Something changed?<p>Just wish we have a little bit of context. But it is also great it is continue being maintained. It makes a huge difference for Ruby on Rails Apps.
    • aktenlage8 hours ago
      &gt; Just wish we have a little bit of context<p>See the comment of vocx2tx
      • throw0101a5 hours ago
        &gt; <i>See the comment of vocx2tx</i><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=49750698">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=49750698</a><p>To:<p>* <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=44264958">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=44264958</a><p>* <a href="https:&#x2F;&#x2F;jasone.github.io&#x2F;2025&#x2F;06&#x2F;12&#x2F;jemalloc-postmortem&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jasone.github.io&#x2F;2025&#x2F;06&#x2F;12&#x2F;jemalloc-postmortem&#x2F;</a>
    • feldrim7 hours ago
      It&#x27;s only mentioned in history: <a href="https:&#x2F;&#x2F;github.com&#x2F;jemalloc&#x2F;jemalloc&#x2F;wiki&#x2F;Background#history" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jemalloc&#x2F;jemalloc&#x2F;wiki&#x2F;Background#history</a>
  • ZenoArrow10 hours ago
    Why is this on the HN front page? Is there something particularly noteworthy about this release?
    • imhoguy8 hours ago
      I upvoted it because I benefit from jemalloc in my stack (RoR) and I am tired of AI taking over HN front page. Let the hacker spirit be back!
      • adityapatadia7 hours ago
        Upvoted for the same reason. We would not be able to run our workloads without Jemalloc. Kudos to this awesome piece of software.
      • smartmic7 hours ago
        You are not alone - my first thought was &#x27;oh, HN is trying to bring back the disappointed hackers&#x27;. All this AI hype over every little model update fart is so exhausting and boring …
    • aktenlage10 hours ago
      They resumed development on jemalloc only recently, after years of no releases.
      • charcircuit8 hours ago
        Development was never stopped for jemalloc. This is a common misconception. There just were not releases being tagged and packaged against the ongoing development.
    • defrost10 hours ago
      The noted resumption <i>and</i> likely a small amount of halo effect from the <i>Comparison of Malloc() Algorithms</i> thread two &#x2F; three days ago.<p>- <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=49715318">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=49715318</a>
    • ck4510 hours ago
      I just checked whether it&#x27;s the first release after Jason Evans stepped down as maintainer, but it isn&#x27;t. That was the previous release, 5.3.1
    • baq9 hours ago
      jemalloc is something you should be aware of if you do software for a living
      • stackghost8 hours ago
        In the Before Times, the vast majority of software was written in garbage collected language where a working knowledge of the relative merits of C memory allocators is not useful or particularly relevant.<p>Why would the scads of people writing JavaScript, Java, python, go, rails, etc need to be aware of jemalloc?
        • nh27 hours ago
          Memory allocation behaviour has visible impact also for users of managed languages, and the behaviour of software for end users.<p>In our Python program, a bit of numpy processing of large pictures led to 100 GB not being returned to the OS by glibc&#x27;s default allocator and the machine running out of memory shortly after. With jemalloc&#x27;s reliable memory return settings, those problems disappear.
          • majora20074 hours ago
            I&#x27;m in the same boat, I just switched to using it for Kavita, which only does some basic open Image -&gt; Thumbnail to smaller size -&gt; write to disk when importing new comics&#x2F;books and on linux, memory could swell to 10GB and never get released. Switched to jemalloc and instantly memory stayed well below 1GB.
            • nh22 hours ago
              Generally yes, but the wording of &quot;instantly&quot; begs for the following pedantic remark:<p>This is controlled by jemalloc settings `dirty_decay_ms`, `muzzy_decay_ms`, and their interaction with `background_thread`.<p>`dirty_decay_ms` currently defaults to 10 seconds, so it&#x27;s not that instant.<p>That is important e.g. for single-threaded programs that start other programs, such as my Python example: If it starts a subprocess before the 10 seconds elapse after `free()`, Python (and jemalloc) do not run, and get no chance to return memory to the OS.<p>In such cases, either enable `background_thread`, or set the `_decay_` values to `0` to ensure immediate return to the OS upon `free()`. (This costs some performance.)<p>See e.g. <a href="https:&#x2F;&#x2F;github.com&#x2F;jemalloc&#x2F;jemalloc&#x2F;issues&#x2F;2688" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jemalloc&#x2F;jemalloc&#x2F;issues&#x2F;2688</a>
          • stackghost1 hour ago
            Okay but do you think the hordes of JavaScript developers at FANG can just change the browser’s allocator?<p>The number of programmers who are in positions to care about jemalloc vs other malloc is minuscule
        • xxs7 hours ago
          &gt;...the vast majority of software was written in garbage collected language<p>and even then recently it costed (us) quite a few months to blame JVM and later the default glibc memory allocator for running out native (not java heap memory) - had to exclude all possible native libs (zlib, zstd via jna), direct buffers, sockets, thread stacks and so on. Changing the malloc to jemalloc solved the issue, even though initially it was done for its debugging capabilities.<p>It&#x27;s just a great memory allocator.
          • fc417fc8026 hours ago
            I&#x27;m never sure if I should be upset or happy when I&#x27;ve been debugging a problem for long enough that I finally decide to switch something out in order to improve visibility and that immediately solves the problem for entirely unexpected reasons. Particularly all the times when I couldn&#x27;t readily discern <i>why</i>.
        • yxhuvud4 hours ago
          Because unfortunately, the runtimes belonging to all or at least most of those languages perform a lot better with jemalloc than with the system default.<p>I wish that wasn&#x27;t the case, but it is.
        • iam-da-author8 hours ago
          TL;DR: Because the runtime of most GC:d languages uses malloc for its internal data structures.<p>I work for the runtime team of JPG @ Oracle. We use malloc in Hotspot, quite a lot actually! Providing your JVM with a good malloc can improve the performance of the runtime, both in terms of CPU and memory, by quite a bit.<p>I don&#x27;t think you need the details, but it&#x27;s good to be aware that some mallocs are better than others, and there are multiple of them. Being aware of jemalloc is a good way of being aware of the facts I just mentioned :-).
          • stackghost18 minutes ago
            The vast majority of professional developers are not in a position where they can just swap out allocators willy-nilly. They take what they get, and write the code they&#x27;re assigned to write on the platform the CTO or their product lead or whoever has decided upon.
            • iam-da-author8 minutes ago
              Okay, well, I guess all I can say is that if you strive to be one of the developers who do get the chance to care about this stuff, then you should know this stuff :-).
      • rfgplk9 hours ago
        Why? Writing a memory allocator is quite simple, and I&#x27;d argue that _everyone_ should write one from scratch for any kind of high performance application. It&#x27;s also trivial to outperform general purpose allocators that have to satisfy countless constraints. I&#x27;ve written numerous special purpose mallocs that are a) both provably (formally) safer than the standard armada and b) significantly faster (&gt;10x throughput).
        • groomlake9 hours ago
          Your experience writing memory allocators is irrelevant. The point is that jemalloc is widely used and that’s why it makes sense to be aware of it.
        • stackghost8 hours ago
          Writing an allocator is simple, you’re correct, but writing an allocator that doesn’t suck is not simple.
        • HackerThemAll9 hours ago
          I&#x27;d happily see performance, latency and stability of your allocators in massively multithreaded, long-living programs with workloads where hundreds or thousands of parallel threads continuously create and destroy short-lived small and medium objects.<p>Writing allocators for domain-specific access patterns is easy. Writing a general-purpose high performing, stable allocator with bounded P99 latency is hard.<p>Give your friend, Dunning–Kruger, some better pills to keep him from speaking through you.
          • Pannoniae8 hours ago
            You&#x27;re correct, but his point is that you don&#x27;t need to solve the <i>generic</i> problem. Solving the generic problem is very hard. Grug doesn&#x27;t like solving hard problem. What does grug do? Solve five easy problems. Make an arena for the short-lived objects, reuse the objects, use generic multithreaded malloc for the rest. Grug happy.
          • Mikhail_Edoshin6 hours ago
            I guess the point was that before you consider using a different allocator you should rule out a custom one.<p>And that&#x27;s rather hard, because a general purpose allocator makes all decisions based only on the requested size. This is a very simple interface and such a tool is worth having. But a custom allocator can both bake in a specific scenario and provide more nuanced interaction.
          • jonkerz6 hours ago
            &gt;massively multithreaded, long-living programs with workloads where hundreds or thousands of parallel threads continuously create and destroy short-lived small and medium objects.<p>My first thought would be to use per thread pool allocators.
          • cv50056 hours ago
            &gt;where hundreds or thousands of parallel threads continuously create and destroy short-lived small and medium objects.<p>Should one even want a global, general purpose heap allocator for that? Seems like a crazy idea to even consider.
          • matheusmoreira8 hours ago
            Not everything needs to be general purpose. Allocation can be as easy as bumping a pointer, and it&#x27;s hard to beat that.
    • kreco7 hours ago
      &gt; Why is this on the HN front page?<p>This question was not necessary. You know the answer, because people upvoted this.
    • gjvc7 hours ago
      because people like you are too busy whining about it to put up something more interesting