Hoard memory allocator

大城市里の小女人 提交于 2020-01-04 05:12:14

问题


Hoard memory allocator

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?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/9204354/hoard-memory-allocator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!