囤积内存分配器 [英] Hoard memory allocator

查看:255
本文介绍了囤积内存分配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存储区分配器

我正在阅读关于Hoard内存分配器的文章,一切都是可以理解的,但有一点不是,它如何减少多个线程分配或释放内存时引起的堆争用,避免了可能由内存分配器引入,同时,它对分段应用严格的边界。他们是如何实现的?

I'm reading papers about Hoard memory allocator, and everything is understandable, but one thing not, how it reduces contention for the heap caused when multiple threads allocate or free memory, after avoids the false sharing that can be introduced by memory allocators and at the same time, it applies strict bounds on fragmentation. How did they achieve it?

推荐答案

从文章中,Hoard根据每处理器堆。当这些堆需要超级块时,他们要求全局堆为空。因为超级块完全由每个处理器的堆释放,所以它们被释放到全局堆以在其他地方重用,从而对分配的内存进行约束。

From the paper, Hoard allocates memory internally in superblocks as required by the per-processor heaps. When these heaps need a superblock they ask the global heap for an empty one. As superblocks are freed entirely by a per-processor heap, they are released to the global heap for reuse elsewhere, thus putting a bound on the memory allocated.

线程争用,超级块每次仅在一个每处理器堆中被主动使用。然后,Hoard只能从一个超级块到一个线程提供内存 使用这个策略Hoard能够避免最主动的假共享:

In terms of thread contention, the superblocks are only actively used in one per-processor heap at a time. Hoard then works to only serve memory from one superblock to one thread. Using this strategy Hoard is able to avoid most active false sharing:


当多个线程同时请求内存时,请求总是满足来自不同的超级块,避免主动诱发假共享。

When multiple threads make simultaneous requests for memory, the requests will always be satisfied from different superblocks, avoiding actively induced false sharing.

存在这样的可能性:当超级块变得相对空),它将可用于另一个堆,这可能导致被动假共享,因为另一个线程仍然可以保留对超级块的引用。然而,考虑到超级块的大小,他们没有发现这在实践中是常见的:

There exists the possibility that when a superblock becomes relatively empty (determined by an internal factor) it will be made available to another heap, which could result in passive false sharing as another thread may still retain references into the superblock. However, given the size of the superblocks, they've not found this to be common in practice:


此外,实践中,发布到全局堆的超级块通常是完全空的,消除了假共享的可能性。

Further, we have observed that in practice, superblocks released to the global heap are often completely empty, eliminating the possibility of false sharing.

分配共同分配大小和合并释放空间的分配器策略。

Hoard handles fragmentation by a fairly common allocator strategy of pooling common allocation sizes and coalescing freed space.

这篇关于囤积内存分配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆