zoukankan      html  css  js  c++  java
  • 实验性质的JIT compiler(Ruby2.6)

    Ruby2.6的一个新的功能:Just in time complier

    特点:

    和传统的JIT编译器不一样之处:把代码写成C并存储在磁盘,并使用一个C编译器来生成native code。这样就节省了运行时间。改善了Ruby程序的执行效率。

    传统的编译器如bootsnap会在第一次运行一个Ruby Script时,把YARV instruciton存到disk。之后还运行这个脚本就省略了parse和complie的过程,直接使用YARV instruction。这会提升大概30%的运行速度。

    使用MJIT编译YARN instruction

    (M是开发者的名字)它会对已存在的YARV instruction进行操作,以提升运行速度。

    当YARV instruction 存在后,RubyVM会在运行时把那些instruction转化成native code(用于操作系统和cpu)。

    一个Ruby程序运行的70%的时间都是这个process花费的。这是一笔很大的时间占用。

    所以JIT编译器出现了。它的作用是把YARV instruction转化成的C语言代码存在disk上。当一个YARV instruction再次出现,直接使用对应的C代码和C编译器来生成native code。这样就节省了时间。

    注意:⚠️

    实验性质的功能。Rails不会从中受益。

    many other memory-intensive workloads like Rails applications might not benefit from it at the moment. 

    使用:

    $ruby -v 
    //是2.6.0以上版本
    $ruby --git test.rb
    //使用--git-verbose=1 在terminal上打印出additional information。
    //或者用环境变量
    $RUBYOPT="--jit" rails s
  • 相关阅读:
    Kafka架构
    MapReduce执行流程解析
    ZooKeeper选举机制
    Zookeeper全局一致性
    HDFS的快照
    在CentOS 6.5上安装NodeJS
    Node v0.12.5 稳定版发布
    CentOS6.5手动升级gcc4.8.2
    centos6 yum 安装 install c++4.8 gcc4.8
    Linux CentOS6系统安装最新版本Node.js环境及相关文件配置
  • 原文地址:https://www.cnblogs.com/chentianwei/p/10755264.html
Copyright © 2011-2022 走看看