TruffleでPHPぽい言語を実装したら爆速だった話 / truffle php at jjug night seminar

9e840766611f942c7c0a9ad6987a5d78?s=47 Naoki Kishida
February 27, 2019

TruffleでPHPぽい言語を実装したら爆速だった話 / truffle php at jjug night seminar

TruffleでPHPを実装したら爆速だった話です

9e840766611f942c7c0a9ad6987a5d78?s=128

Naoki Kishida

February 27, 2019
Tweet

Transcript

  1. TrufflePHP  JJUG    2019/2/27 LINE Fukuoka 

    
  2.  •   • LINE Fukuoka •  

     • @kis
  3. Truffle • 

  4. Truffle •  ()      

       
  5. Truffle

  6. PHP   • jparsec ( ) • https://github.com/jparsec/jparsec/ •

      • +-<>.(  ) •  •  • if • echo https://github.com/kishida/phpparser
  7.     <?php function fib($n) { if ($n

    < 2) { return $n; } return fib($n - 1) + fib($n - 2); } echo "fib:".fib(31); echo "¥n";
  8. (1/6) • Node

  9. (2/6) •    • (Specialization)

  10. (3/6) • CallNode 

  11. (4/6) •  

  12. (5/6) • NodeDirectCallNodeCompilerAssertsGraal • Java   

  13. (6/6) • 5; • 0:, 4 %)5210:,  69; •

    return=-2/   goto(JVM%)) jmp(*!' +) ReturnException #+&"$(87  resultObject <3.
  14.  <?php function fib($n) { if ($n < 2) {

    return $n; } return fib($n - 1) + fib($n - 2); } $start = microtime(1); echo "fib:".fib(31); echo "¥n"; echo "time:".(microtime(1) - $start); echo "¥n"; fib(31);fib(31);fib(31);fib(31);fib(31); $start = microtime(1); echo "fib:".fib(31); echo "¥n"; echo "time:".(microtime(1) - $start); echo "¥n";
  15.  •  (interpreter) on JDK 11 • Truffle 

    JDK 11 • Truffle  GraalVM CE • Truffle  GraalVM CE   • Truffle  GraalVM EE • Truffle  GraalVM EE   • PHP 5.6 • PHP 7.3
  16. (JIT) • PHP 7.3PHP5.63 •   PHP7.37 • Truffle+GraalVM

    CEPHP7.3 • Truffle+GraalVM EEPHP7.32 • GraalVM CE    PHP7.32 • GraalVM EE    PHP7.34
  17.  • JIT    •   •

     • EE PHP7.3   • CE PHP7.3  
  18.   • PHP  # &!"' •  %

    •  • EE$CE% <?php function fib($n) { if ($n < 2) { return $n; } return fib($n - 1) + fib($n - 2); } echo "fib:".fib(31); echo "¥n";
  19.  • Real$) "UserCPU! " • JVMUser" ' • 

    ( CPU" ' • GraalVMRealUser & • Graal#% ( CPU" 
  20.  • PHPPHP3PHP4PHP5PHP7 '5# !"(PHP6&8) • (0, +*:% PHP7941 

     •  "$!(03  • . '5# (0,6 -2 • 5/$7)#(Specialization) 
  21.  • GraalVM  • Truffle   • "

    # SimpleLanguage  • Writing a Language in Truffle •  gitter ! % • Graal&$