Just-In-Time Compiler for MRI

Just-In-Time Compiler for MRI

RubyConf 2017 New Orleans

08d5432a5bc31e6d9edec87b94cb1db1?s=128

Takashi Kokubun

November 17, 2017
Tweet

Transcript

  1. 4.
  2. 6.
  3. 8.
  4. 9.

    DPNQJMFEDPEF`TSFOEFSJOHUJNFTQFSTFDPOE OP)5.-FTDBQF 3FOEFSJOHUJNFTQFSTFDPOE JT      ERB

    Ruby 2.5.0 Erubis 2.7.0 Ruby 2.5.0 Erubi 1.7.0 Ruby 2.5.0 ERB Ruby 2.4.2            IUUQTHJTUHJUIVCDPNLLVCVOFEEDDCEFGDGBDEGGE *NBEF&3#YGBTUFS
  5. 14.

    5PEBZ*`MMUFMMZPVIPX*BDIJFWFEUIJTXJUIJU 0QUDBSSPUXJUI-BO@.BTUFS GQT      Ruby 2.0

    Ruby 2.5 YARV-MJIT    IUUQTHJUIVCDPNLLVCVOZBSWNKJUPQUDBSSPUCFODINBSL
  6. 19.

    )PXDVSSFOU.3*XPSLT EFGSVCZ   FOE 3VCZDPEF "CTUSBDU 4ZOUBY5SFF /0%&@$"-- NFUIPE

    SFDFJWFS BSHT 1BSTF QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF #ZUFDPEF GPS3VCZ7. $PNQJMF
  7. 33.

    #ZUFDPEF GPS3VCZ7. QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF 5ISFBE 3VCZ7. 5ISFBE +*5DPNQJMFS

    $BMMDPVOU /BUJWFDPEF $BMM 0QUJNJ[F )PXEPFT+*5XPSL *OUFSQSFU
  8. 38.

    'JSTUPGBMM EPFT3VCZOFFEUPCFGBTUFS 3VCZJTGBTUFOPVHIGPSNBOZVTFDBTFT CVUJUTIPVMECFGBTUFS w 'PSNPOFZ w 5IFGBTUFS3VCZJT UIFGFXFSDPNQVUFSFTPVSDFTBSFSFRVJSFE w

    'PSFOEVTFSFYQFSJFODF w FH'BTUXFCBQQMJDBUJPOJTDPNGPSUBCMFUPVTF w 5PBMXBZTVTF3VCZ❤ w /PMPOHFSOFFEUPDIPPTFBOPUIFSMBOHVBHFEVFUPQFSGPSNBODF
  9. 39.

    0LBZ UIFOXIZ+*5GPS3VCZQFSGPSNBODF w +*5+VTU*O5JNF"05"IFBE0G5JNF w "05DPNQJMFTQSPHSBNUPOBUJWFDPEFCFGPSFJUTFYFDVUJPO w 8IZOPU"05CVU+*5  w

    5PLFFQCPPUUJNFTIPSU DPNQJMBUJPOTIPVMECFGVMMZBTZODISPOPVT w 4PNFPQUJNJ[BUJPOTOFFESVOUJNFJOGPSNBUJPO FYQMBJOFEMBUFS
  10. 41.

    1FSGPSNBODFPGTPNF+*5DPNQJMFSJNQMFNFOUBUJPOT 0QUDBSSPUXJUI-BO@.BTUFS GQT      Ruby 2.0

    Ruby 2.5 YARV-MJIT MJIT     IUUQTHJUIVCDPNLLVCVOZBSWNKJUPQUDBSSPUCFODINBSL
  11. 46.
  12. 52.

    #ZUFDPEF QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF 5ISFBE 3VCZ7. )PX--3#XPSLT *OUFSQSFU .FUIPE`T

    --7.*3 $PNQJMF $PNCJOFE --7.*3 -JOL*3 .3*`T QSFDPNQJMFE --7.CJUDPEF
  13. 53.

    #ZUFDPEF QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF 5ISFBE 3VCZ7. )PX--3#XPSLT *OUFSQSFU .FUIPE`T

    --7.*3 $PNQJMF /BUJWF$PEF $PNCJOFE --7.*3 -JOL*3 0QUJNJ[BUJPO CZ--7.1BTT $PEFHFO .3*`T QSFDPNQJMFE --7.CJUDPEF
  14. 54.

    #ZUFDPEF QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF 5ISFBE 3VCZ7. )PX--3#XPSLT *OUFSQSFU .FUIPE`T

    --7.*3 $PNQJMF .3*`T QSFDPNQJMFE --7.CJUDPEF /BUJWF$PEF $PNCJOFE --7.*3 -JOL*3 $PEFHFO $BMM 0QUJNJ[BUJPO CZ--7.1BTT
  15. 57.
  16. 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3FHJTUFS 1SPHSBN$PVOUFS 3FHJTUFS $IBOHFJOTUSVDUJPO EFQFOEJOHPO SFDFJWFSUZQF NVMUJ 0CKFDU *OUFHFS JNVMUJ *OUFHFS *OUFHFS
  20. 79.
  21. 82.

    -PDBMpMFT $BMMDPVOU 35-#ZUFDPEF WBMUFNQ  JNVMUJ   UFNQ@SFU 5ISFBE3VCZ7.

    5ISFBE+*5DPNQJMFS )PX.+*5XPSLT *OUFSQSFU $DPEFPGNFUIPE $PNQJMF 4IBSFE0CKFDUpMF HDD DMBOH
  22. 83.

    -PDBMpMFT $BMMDPVOU 35-#ZUFDPEF WBMUFNQ  JNVMUJ   UFNQ@SFU 5ISFBE3VCZ7.

    5ISFBE+*5DPNQJMFS )PX.+*5XPSLT *OUFSQSFU $DPEFPGNFUIPE $PNQJMF 4IBSFE0CKFDUpMF HDD DMBOH .FNPSZ /BUJWFDPEF EMTZN
  23. 84.

    -PDBMpMFT $BMMDPVOU 35-#ZUFDPEF WBMUFNQ  JNVMUJ   UFNQ@SFU 5ISFBE3VCZ7.

    5ISFBE+*5DPNQJMFS )PX.+*5XPSLT *OUFSQSFU $DPEFPGNFUIPE $PNQJMF 4IBSFE0CKFDUpMF HDD DMBOH .FNPSZ EMTZN $BMM /BUJWFDPEF
  24. 92.

    8FOFFEUPDIFDLNFUIPESFEFpOJUJPO QVUPCKFDU MFBWF DMBTT*OUFHFS EFG PCK  PCK FOE FOE

      $VSSFOU3VCZDPNQJMFSEPFTO`UQSPWJEFTVDIPQUJNJ[BUJPO :"37CZUFDPEF
  25. 96.

    QVUPCKFDU QVUPCKFDU PQU@NVMU MFBWF $BMMDPVOU (FOFSBUF$DPEF 7"-6&PQU@NVMU B C \

    *G OPU@SFEFpOFE JOU@NVMU \ SFUVSOB C ^FMTF\ SFUVSOWN@FYFD  ^ ^ 7"-6&OBUJWF@DPEF \ SFUVSOPQU@NVMU    ^ :"37CZUFDPEF )PXEPFT:"37.+*5PQUJNJ[FUIJT 5ISFBE3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