MultiCore Memory Management Technology in mortal kombat

来源:互联网 发布:html js图片轮播 编辑:程序博客网 时间:2024/06/01 07:42


gdc2011's paper.


UnealMemoryAllocator

上来先分析了unreal的memory allocator不给力,在于:

  • 不支持多个heap
  • 并不是native的面向MultiThread和MultiCore
    • 用一个全局lock来保证thread safe,这个性能很差
  • 的确是有些operation会有很大的stall
另外一个他们game里面用的mem mgr,也有一些问题,其实也就是这个paper要解决的一部分问题:
  • 线程安全
  • virtual memory aware
  • fragment
GlobalLock

这个可以说是最不好的多线程解决方式:
  • 所有的操作(无论多小)都会有不小的代价,
  • 某些类似realloc的操作代价尤其大
解决方案:
  • virtual memory aware dynamic backstore and large allocations
  • lock free
  • multiple heaps
  • tracking and debugging

使用混合的heap:

  • 大size的直接用os的heap
  • 中间的和小的各用不同的heap进行管理

其中各自占有的size和count的数据很重要:

分布:


小内存分配:
  • 使用bining allocator(分级allocator,link:http://g.oswego.edu/dl/html/malloc.html)
    • 使用lock striping(lock per bin, link:http://www.thinkingparallel.com/2007/07/31/10-ways-to-reduce-lock-contention-in-threaded-programs/)
  • lock free alloc
    • lookaside cache(http://g.oswego.edu/dl/html/malloc.html),
    • 是维护一个lock free的list(也就是dlmalloc里说的cache的一种),list耗光了之后再从chunk里分配一个list
    • 一些基本的lockfree做法就是典型的CAS这种
  • striping lock free:(lock striping[http://www.thinkingparallel.com/2007/07/31/10-ways-to-reduce-lock-contention-in-threaded-programs/] :use different lock for different data)

原创粉丝点击