Home > Erlang探索, 调优 > Erlang R15的内存delayed dealloc特性对消息密集型程序的影响

Erlang R15的内存delayed dealloc特性对消息密集型程序的影响

November 21st, 2011 Leave a comment Go to comments

在新的NUMA体系结构下,每个CPU都有自己的本地内存,如果要访问其他CPU的内存,那算remote了,要走CPU之间的QPI通道,通常这样速度会有40%的下降。
那么对于多线程的程序来讲,这个硬件的变化对软件也有很大的影响。在多线程程序里面,通常一个线程会为一个对象分配内存,然后把这个对象传递到不同的线程去使用,最后由其他线程释放内存。而这二个线程可能在不同的CPU上运行,这个场景很普遍,比如说Erlang的消息机制。如果谁创建谁释放对象,提高内存倒腾的效率,那么对于消息密集型程序会有很多帮助。

R15的最大的运行期优化见: 这里
这个特性也就是之前声称的delayed dealloc特性
对照下OTP团队之前的规划:

目前规划里面的1,2,3,4在R15里面都已经实现了。

Optimize memory allocation

A number of memory allocation optimizations have been implemented. Most
optimizations reduce contention caused by synchronization between
threads during allocation and deallocation of memory. Most notably:
* Synchronization of memory management in scheduler specific allocator
instances has been rewritten to use lock-free synchronization.
* Synchronization of memory management in scheduler specific
pre-allocators has been rewritten to use lock-free synchronization.
* The ‘mseg_alloc’ memory segment allocator now use scheduler specific
instances instead of one instance. Apart from reducing contention
this also ensures that memory allocators always create memory
segments on the local NUMA node on a NUMA system.

我们来尝鲜演示下,首先设计个消息密集型的程序:

抱歉由于刚才的POST测试案例设计不合理,重新设计过,敬请期待。。。

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: Erlang探索, 调优 Tags: ,
  1. March 28th, 2012 at 18:45 | #1

    期待老大的测试案例!

    [Reply]

  1. No trackbacks yet.