【测试报告】【小于 5usec】有关 Erlang 派生进程的性能问题
关键词:
Erlang,SMP
五万个进程
每进程耗时 4微秒
CPU <17%
内存小于 80M
前段时间按照《Erlang 程序设计》上所讲,
在我的机器上做了一个测试,结果如下(括号里是墙上时间):
- 11> processes:max(50000).
- Process spawn time=4.0 (4.54) microseconds
- ok
- 12> processes:max(50000).
- Maximum allowed processes:60000
- Process spawn time=4.0 (4.82) microseconds
- ok
- 13> processes:max(50000).
- Maximum allowed processes:60000
- Process spawn time=3.2 (4.66) microseconds
- ok
- 14> processes:max(50000).
- Maximum allowed processes:60000
- Process spawn time=3.8 (4.48) microseconds
- ok
- 代码是用的《Erlang 程序设计》上的:
- $ cat processes.erl
- %% ---
- %% Excerpted from "Programming Erlang",
- %% published by The Pragmatic Bookshelf.
- %% Copyrights apply to this code. It may not be used to create training material,
- %% courses, books, articles, and the like. Contact us if you are in doubt.
- %% We make no guarantees that this code is fit for any purpose.
- %% Visit [url]http://www.pragmaticprogrammer.com/titles/jaerlang[/url] for more book information.
- %%---
- -module(processes).
- -export([max/1]).
- %% max(N)
- %% Create N processes then destroy them
- %% See how much time this takes
- max(N) ->
- Max = erlang:system_info(process_limit),
- io:format("Maximum allowed processes:~p~n",[Max]),
- statistics(runtime),
- statistics(wall_clock),
- L = for(1, N, fun() -> spawn(fun() -> wait() end) end),
- {_, Time1} = statistics(runtime),
- {_, Time2} = statistics(wall_clock),
- lists:foreach(fun(Pid) -> Pid ! die end, L),
- U1 = Time1 * 1000 / N,
- U2 = Time2 * 1000 / N,
- io:format("Process spawn time=~p (~p) microseconds~n",
- [U1, U2]).
- wait() ->
- receive
- die -> void
- end.
- for(N, N, F) -> [F()];
- for(I, N, F) -> [F()|for(I+1, N, F)].
- 4G 内存(其实和内存关系不大,因为占的内存很少,只有几十兆),CPU 信息:
- $ cat /proc/cpuinfo
- processor : 0
- vendor_id : GenuineIntel
- cpu family : 6
- model : 15
- model name : Intel(R) Xeon(R) CPU 5110 @ 1.60GHz
- stepping : 6
- cpu MHz : 1595.944
- cache size : 4096 KB
- physical id : 0
- siblings : 2
- core id : 0
- cpu cores : 2
- fdiv_bug : no
- hlt_bug : no
- f00f_bug : no
- coma_bug : no
- fpu : yes
- fpu_exception : yes
- cpuid level : 10
- wp : yes
- flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts pni monitor ds_cpl vmx tm2 ssse3 cx16 xtpr dca lahf_lm
- bogomips : 3194.88
- clflush size : 64
- processor : 1
- vendor_id : GenuineIntel
- cpu family : 6
- model : 15
- model name : Intel(R) Xeon(R) CPU 5110 @ 1.60GHz
- stepping : 6
- cpu MHz : 1595.944
- cache size : 4096 KB
- physical id : 0
- siblings : 2
- core id : 1
- cpu cores : 2
- fdiv_bug : no
- hlt_bug : no
- f00f_bug : no
- coma_bug : no
- fpu : yes
- fpu_exception : yes
- cpuid level : 10
- wp : yes
- flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts pni monitor ds_cpl vmx tm2 ssse3 cx16 xtpr dca lahf_lm
- bogomips : 3192.09
- clflush size : 64
复制代码
[ 本帖最后由 flw 于 2008-12-19 14:02 编辑 ]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
good,能再仔细深入下去最好.
good
我也试过,50000*10也没有太大的性能下降
在Linux下还可以调节吧 !