erlang的hipe支持(高级)

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] [color=red][hipe] [/color][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过去。

进一步阅读请参考 [url]http://www.it.uu.se/research/group/hipe/documents/hipe_manual.pdf[/url]
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值