具有并发分配器的空闲列表
空闲列表是通过重用已分配的现有内存来加速分配的常见方法。有没有一种方法可以在并发分配器中使用空闲列表,而不会产生每次分配的锁定开销(这会抵消空闲列表的预期性能增益)?
Freelists are a common way to speed up allocation by reusing existing memory that was already allocated. Is there a way to use free-lists in a concurrent allocator, without incurring the overhead of a lock for every allocation (which would neutralize the intended performance gain of the freelist)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用无锁链接列表。
Use a lock-free linked list.
您可以拥有特定于线程的空闲列表块。
基本上,有一些系统可以填充空闲列表(例如垃圾收集器)。然后每个线程都可以有自己的空闲列表块,其中包含少量条目。锁定将用于分配新块。对于包含 30 个条目的块,每 30 次分配只需锁定一次。相反,对于特定于线程的块,您可能必须更快地运行 GC,因为即使某些特定于线程的块仍然有一些空闲条目,共享列表也可能会变空。
You could have thread-specific free list chunks.
Basically, there is some system which populates the free lists (e.g. a garbage collector). Then each thread could have its own free list chunk, containing a small number of entries. Locking would be used to allocate a new chunk. With chunks with 30 entries, you would lock only once every 30 allocations. Conversely, with thread-specific chunks you may have to run the GC sooner, because the shared list could become empty even if some of the thread-specific chunks still have some free entries.