Archive

Posts Tagged ‘min_bin_vheap_size’

Erlang vheap刨析和注意事项

October 19th, 2013 Comments off

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: Erlang vheap刨析和注意事项

Erlang从R13B03开始引入了vheap的概念,具体参见这篇文章:R13B03 binary vheap有助减少binary内存压力
官方的release note里面简单的解释了下:

OTP-8202 A new garbage collecting strategy for binaries which is more
aggressive than the previous implementation. Binaries now has
a virtual binary heap tied to each process. When binaries are
created or received to a process it will check if the heap
limit has been reached and if a reclaim should be done. This
imitates the behavior of ordinary Erlang terms. The virtual
heaps are grown and shrunk like ordinary heaps. This will
lessen the memory footprint of binaries in a system.

但除此之外,无法找到更细的文档。最近在做的服务器程序里面用到了大量的binary, 需要对binary的行为做详细的分析,所以就顺便把vheap好好整理下。

我们首先看下如何控制vheap.
首先看下全局的设置, 参见这里

+hmbs Size
Sets the default binary virtual heap size of processes to the size Size.

如果不设定的话,这个值默认是:

./erl_vm.h:62:#define VH_DEFAULT_SIZE 32768 /* default virtual (bin) heap min size (words) */

我们来验证下我们的设置:

Erlang R16B03 (erts-5.10.4) [source-73d1b4a] [64-bit] [smp:16:16] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.4  (abort with ^G)
1>  erlang:system_info(min_bin_vheap_size).
{min_bin_vheap_size,46422}

oops, 怎么对不起来呢?
看下代码,原来在erl_init里面会对这个值再进行调整:
Read more…

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