问题描述
我目前有大量多线程的服务器应用程序,我正在四处寻找一个好的多线程内存分配器.
I currently have heavily multi-threaded server application, and I'm shopping around for a good multi-threaded memory allocator.
到目前为止,我很纠结:
So far I'm torn between:
- 太阳的乌梅
- Google 的 tcmalloc
- 英特尔的线程构建块分配器
- Emery Berger 的宝藏
据我所知,hoard 可能是最快的,但我在今天之前没有听说过它,所以我怀疑它是否真的像看起来一样好.任何人都有尝试这些分配器的个人经验?
From what I've found hoard might be the fastest, but I hadn't heard of it before today, so I'm skeptical if its really as good as it seems. Anyone have personal experience trying out these allocators?
推荐答案
我使用过 tcmalloc 并阅读了有关 Hoard 的文章.两者都有类似的实现,并且都在线程/CPU 数量方面实现了大致线性的性能扩展(根据各自站点上的图表).
I've used tcmalloc and read about Hoard. Both have similar implementations and both achieve roughly linear performance scaling with respect to the number of threads/CPUs (according to the graphs on their respective sites).
所以:如果性能真的那么重要,那么做性能/负载测试.否则,只需掷骰子并选择列出的其中一个(根据在目标平台上的易用性进行加权).
So: if performance is really that incredibly crucial, then do performance/load testing. Otherwise, just roll a dice and pick one of the listed (weighted by ease of use on your target platform).
从 trshiv 的链接来看,它看起来像 Hoard、tcmalloc、和 ptmalloc 在速度上大致相当.总体而言,tt 看起来像 ptmalloc 是为了占用尽可能少的空间而优化的,Hoard 是为了速度 + 内存使用的权衡而优化的,而 tcmalloc 是为了纯粹的速度而优化的.
And from trshiv's link, it looks like Hoard, tcmalloc, and ptmalloc are all roughly comparable for speed. Overall, tt looks like ptmalloc is optimized for taking as little room as possible, Hoard is optimized for a trade-off of speed + memory usage, and tcmalloc is optimized for pure speed.
这篇关于C/C++ 的多线程内存分配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!