🥳🎉 Meta's backtracking on #jemalloc is hailed as a #groundbreaking move! Because clearly, the world needed another deep dive into memory allocation strategies over their morning coffee. 🙄🔍 Who knew infrastructure updates could be so riveting?
https://engineering.fb.com/2026/03/02/data-infrastructure/investing-in-infrastructure-metas-renewed-commitment-to-jemalloc/ #Meta #memoryallocation #infrastructureupdates #technews #HackerNews #ngated
Investing in Infrastructure: Meta’s Renewed Commitment to jemalloc

Meta recognizes the long-term benefits of jemalloc, a high-performance memory allocator, in its software infrastructure. We are renewing focus on jemalloc, aiming to reduce maintenance needs and mo…

Engineering at Meta
Investing in Infrastructure: Meta’s Renewed Commitment to jemalloc

Meta recognizes the long-term benefits of jemalloc, a high-performance memory allocator, in its software infrastructure. We are renewing focus on jemalloc, aiming to reduce maintenance needs and mo…

Engineering at Meta
Meta 的 jemalloc 宣言

在 Lobsters 上看到「Investing in Infrastructure: Meta’s Renewed Commitment to jemalloc」這篇,這讓我馬上想到 Jason Evans (就是發明 jemalloc 的人,je 取自他的名字縮寫) 在去年寫的「jemalloc Postmortem」這篇,文章最後提到 Meta 的制度設計使得不會...

Gea-Suan Lin's BLOG

At $dayjob, we have an embedded #Linux device that is periodically running low on memory. It's using the default (#glibc) allocator.

No leaks, and lowering MALLOC_MMAP_THRESHOLD_ made the problem go away. So: memory fragmentation.

With glibc, I'm sure that's no surprise to anyone "Use #jemalloc", right?

Sure, some do, but I don't want to use a hammer that big without trying to understand the problem first. Jemalloc being effectively end of life also doesn't really thrill me.

1/5

Trying to further improve #swad, and as I'm still unhappy with the amount of memory needed ....

Well, this little and special custom #allocator (only dealing with equally sized objects on a single thread and actively preventing #fragmentation) reduces the resident set in my tests by 5 to 10 MiB, compared to "pooling" with linked lists in whatever #FreeBSD's #jemalloc serves me. At least something. 🙈

https://github.com/Zirias/poser/blob/master/src/lib/core/objectpool.c

The resident set now stabilizes at 79MiB after many runs of my somewhat heavy jmeter test simulating 1000 distinct clients.

poser/src/lib/core/objectpool.c at master · Zirias/poser

POsix SERvices framework for C. Contribute to Zirias/poser development by creating an account on GitHub.

GitHub
Пример типичной системно-прикладной разработки, реализация своей «очереди сообщений» (event loop).
Использованием
#epoll, вместо «традиционных» select & poll, для асинхронной работы через polling’а (и мультиплексирования).

Отслеживание файловых дескрипторов через
#epoll выглядит более современно, меньше копирования памяти между user space и kernel space. А при появлении ожидаемых данных можно напрямую переходить к объекту или структуре данных, что важно при наблюдении за несколькими файлами и\или соединениями. Устраняется поиск «сработавшего» файлового дескриптора в индексных массивах, полноценное О(1) во всех случаях. Можно сразу же работать с теми экземплярами объектов, которые оборачивают тот файл или udp-поток, tcp-, quic-соединение, где появились новые данные.

Есть несколько готовых к использованию «очередей сообщений» (event loop'ов) —
#libev, #libuv, #libevent. Для некоторых агент-серверные решений и брокера #RabbitMQ это подходит. Однако, в некоторых случаях AMQP-библиотеки не скрещиваются с уже готовыми «очередями сообщений». Потому что агентская часть может активно использовать асинхронно-реактивное программирование с хорошей и проверенной «горизонтальной масштабируемостью». Т.е. на агентской части выполняется много работы и реализация сделана через sharing nothing многопоточность. Это такая парадигма, когда не просто достигается не только горизонтальная масштабируемость через lock-free\wait-free, а так же исключается много вредного, как тот же cache ping-pong или false sharing. Внутри агентов идёт своё управление потоками с выделениями памяти. Не только в плане «динамической памяти» (heap, аллокаторы а-ля #jemalloc от #Facebook), но и приколами вокруг pinning страниц, учёта #NUMA и даже huge pages(меньше промахов в #TLB).

Почему бы не использовать epoll?
Библиотека не обязана вычитывает данные целиком из потока (сокета), а может забирает данные лишь до тех пор, пока не насытится автомат состояний (finite-state machine). Например, выполняется парсинг сущностей AMQP-протокола, которые, по мере накопления, передаются в обработчики указанные клиентом библиотеки.
И это плохо соотносится с тем, что используя
#epoll надо выбирать какой вариант оповещений использовать:
• «по уровню» (level-triggered),
• «по фронту» (edge-triggered).

Особенности поведения отдельно взятой библиотеки может не позволять использовать работу «по фронту» (edge-triggered), т.к. библиотека не вычитывает полностью все данные из файловых дескрипторов.

Можно быть хоть пять раз technical lead и всё это прекрасно знать, но следует помнить, что как только в коде появляется флаг EPOLLET, то необходимо проводить аудит работы с потоками данных. Это избавляет команду от многих заморочек вокруг тестирования и ковыряния с каким-то совершенно непонятным поведением кода.

Про
«Edge Triggered Vs Level Triggered interrupts»

#programming #linux #softdev #трудовыебудни
Edge Triggered Vs Level Triggered interrupts

Discussion: Level triggered: as long as the IRQ line is asserted, you get an interrupt request. When you serve the interrupt and return, ...

If you want to understand the life cycle of software, this history of jemalloc is not a bad start
https://alecmuffett.com/article/113513
#SoftwareEcosystems #SoftwareEngineering #jemalloc
If you want to understand the life cycle of software, this history of jemalloc is not a bad start

Remember: there is no bad or good here, and there is no intentionality. To assume there should have been a different outcome would be presumptuous. There just “is”. Not everybody unders…

Dropsafe

If you want to understand the life cycle of software, this history of jemalloc is not a bad start

Remember: there is no bad or good here, and there is no intentionality. To assume there should have been a different outcome would be presumptuous.

There just “is”. Not everybody understands this.

https://jasone.github.io/2025/06/12/jemalloc-postmortem/

#jemalloc #softwareEcosystems #softwareEngineering

Jason Evans

The jemalloc memory allocator was first conceived in early 2004, and hasbeen in public use for about 20 years now. Thanks to the nature of open source software licensing,jemalloc will remain publicly available indefinitely. But active upstream development has come to anend. This post briefly desc...

Jason Evans

The jemalloc memory allocator was first conceived in early 2004, and hasbeen in public use for about 20 years now. Thanks to the nature of open source software licensing,jemalloc will remain publicly available indefinitely. But active upstream development has come to anend. This post briefly desc...

jemalloc 收了?

在 Lobsters 上看到「jemalloc Postmortem」,jemalloc 的 Jason Evans (JEmalloc 的由來) 在關掉 jemalloc 的 GitHub repository 後,寫下了 jemalloc 的歷史 (以他的角度)。 他自己也把文章貼到 Hacker News 上:「Jemalloc Postmortem (jasone.github.

Gea-Suan Lin's BLOG