hipe

来源:互联网 发布:java合并两个json对象 编辑:程序博客网 时间:2024/06/05 09:23
erlang的hipe相当于jit, 根据语言评测有hipe支持在纯erlang的运算上会快2-3倍,这个性能的提升对于计算密集型的应用还是比较可观的。以下是如何启用hipe:

先看下erl的版本:
root@nd-desktop:~# erl
Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.2  (abort with ^G)
1> hipe:version().
"3.7.2
2> hipe:help_options().
HiPE Compiler Options
Boolean-valued options generally have corresponding aliases `no_...',
and can also be specified as `{Option, true}' or `{Option, false}.

General boolean options:
   [debug,load,pp_asm,pp_beam,pp_icode,pp_native,pp_rtl,time,timeout,verbose].

Non-boolean options:
   o#, where 0 =< # =< 3:
     Select optimization level (the default is 2).

Further options can be found below; use `hipe:help_option(Name)' for details.

Aliases:
   pp_all = [pp_beam,pp_icode,pp_rtl,pp_native],
   pp_sparc = pp_native,
   pp_x86 = pp_native,
   pp_amd64 = pp_native,
   pp_ppc = pp_native,
   o0,
   o1 = [x87,inline_fp,pmatch,peephole],
   o2 = [icode_ssa_const_prop,icode_ssa_copy_prop,icode_type,
         icode_inline_bifs,rtl_lcm,rtl_ssa,rtl_ssa_const_prop,spillmin_color,
         use_indexing,remove_comments,concurrent_comp,binary_opt] ++ o1,
   o3 = [icode_range,{regalloc,coalescing}] ++ o2.
ok

默认是emulator启用hipe支持的。

但是.erl 编译成 .beam的时候 也要采用native模式编译才可以:
erlc  +native +"{hipe, [o3]}"  xxx.erl

erlang的最基础的几个模块是preloaded的, 也是用erl编写的,发布版默认不是native编译的,自己可以修改下Makefile.

经过以上2个步骤 hipe支持就可以了。

缺点: hipe是第3方维护的,所以在一些未公开的特性如模块偏特化等支持上会有问题, 而且不是非常的稳定,要多测试才靠谱, 最好是100%cover过去。

进一步阅读请参考 http://www.it.uu.se/research/group/hipe/documents/hipe_manual.pdf
原创粉丝点击