金曜日 6 27, 2008

Learning "optimization of JRuby" with "Yaruo"

英語での最初の記事がこれっていうのも面白いですが、先日のRuby会議2008終了後のRejectKaigiで行われたの高井さんによる「やる夫で学ぶJRuby最適化」を英訳しました。
昨日の弊社セミナー後のビアバストでは、僕のつたない英訳でしたが、C・ナッターに伝えて大受け。
ということなので、以下英訳です。

Naoto Takai, JRuby Developer, had the "joke" presentation re the optimization of JRuby at Reject Kaigi, which was held after Ruby Kaigi 2008.
He used the following presentation  named "Learn the optimization of JRuby with Yaruo".
Yaruo is the Ascii-Art character come from Japanese huge BBS site "2ch".
It's very funny, so I translate it into English , surely with his permission.
And I say once more, It's a JJ!
Here we go!


         ____
       / \  /\  sharply
.     / (ー)  (ー)\
    /   ⌒(__人__)⌒ \
    |      |r┬-|    |  Ruby 1.9 will be realesed before Christmas.
     \     `ー'´   /
    ノ            \
  /´               ヽ
 |    l              \
 ヽ    -一''''''"~~``'ー--、   -一'''''''ー-、.
  ヽ ____(⌒)(⌒)⌒) )  (⌒_(⌒)⌒)⌒))

          ____
        /_ノ  ヽ、_\
 ミ ミ ミ  o゚((●)) ((●))゚o      ミ ミ ミ
/⌒)⌒)⌒. ::::::⌒(__人__)⌒:::\   /⌒)⌒)⌒)
| / / /     |r┬-|    | (⌒)/ / / //
| :::::::::::(⌒)    | |  |   /  ゝ  :::::::::::/    I hear:)
|     ノ     | |  |   \  /  )  /
ヽ    /     `ー'´      ヽ /    /
 |    |   l||l 从人 l||l      l||l 从人 l||l  
 ヽ    -一''''''"~~``'ー--、   -一'''''''ー-、
  ヽ ____(⌒)(⌒)⌒) )  (⌒_(⌒)⌒)⌒))


      +____
     /⌒  ⌒\
   /( ⌒)  (⌒)\ +
  /::::::⌒(__人__)⌒::::: \   You can use JRuby rather than 
    |     |r┬-|     |   Ruby 1.9 whose release date is unknown,
  \      `ー'´     /  +      in the enterprise field.
,,.....イ.ヽヽ、___ ーーノ゙-、.
:   |  '; \_____ ノ.| ヽ i
    |  \/゙(__)\,|  i |
    >   ヽ. ハ  |   ||

       ____
     /⌒  ⌒\
   /( ●)  (●)\
  /::::::⌒(__人__)⌒::::: \   Let's try to test for the benchmark!
  |     |r┬-|     |
  \      `ー'´     /

      ____
     /\  /\
   /( ●)  (●)\
  / :::::⌒(__人__)⌒:::::\   Run the bm_nbody.rb 3 times in the 
  |     |r┬-|       |    ruby-benchmark-suite ,
  \     ` ー'´     /       I can get the best result of them! 


yaruo@vip% time ruby bm_nbody.rb 10000
1.04s user 0.02s system 96% cpu 1.107 total

yaruo@vip% time jruby bm_nbody.rb 10000
2.72s user 0.38s system 117% cpu 2.645 total

         ____
       /      \
      /  ─    ─\
    /    (○)  (○) \
    |       (__人__)    | ________
     \      ` ⌒´   ,/ .| |          |
    ノ           \ | |          |
  /´                 | |          |
 |    l                | |          |
 ヽ    -一ー_~、⌒)\^),-、   | |_________|
  ヽ ____,ノγ⌒ヽ)ニニ- ̄   | |  |

       ____
     /⌒三 ⌒\
   /( ○)三(○)\
  /::::::⌒(__人__)⌒::::: \   JRuby runs more than twice slower than MRI....
  |     |r┬-|     |
  \      `ー'´     /

       ____
     /      \
   /  _ノ  ヽ、_  \
  /  o゚⌒   ⌒゚o  \        I confirmed that I fell for the the adoption of JRuby 
  |     (__人__)    |    in the enterprise field.......
  \     ` ⌒´     /


   / ̄ ̄\
 /   _ノ  \
 |    ( ●)(●)
. |     (__人__)      JRuby can not run fast without the optimization options
  |     ` ⌒´ノ      generally thinking......
.  |         }
.  ヽ        }
   ヽ     ノ        \
   /    く  \        \
   |     \   \         \
    |    |ヽ、二⌒)、          \


         |
     \  __  /
     _ (m) _
        |ミ|
      /  `´  \
       ____
     /⌒  ⌒\
   /( ●)  (●)\
  /::::::⌒(__人__)⌒::::: \ Yes! Run with the optimization options!!!
  |     |r┬-|     |
  \      `ー'´     /

       ____
     /⌒  ⌒\
   /( ●)  (●)\    Optimize with server VM!
  /::::::⌒(__人__)⌒::::: \   JRuby can interpret java option with -J option!
  |     |r┬-|     |
  \      `ー'´     /


yaruo@vip% time jruby -J-server bm_nbody.rb 10000
2.57s user 0.37s system 116% cpu 2.520 total

       ____
     /      \
   / ─    ─ \
  /   (●)  (●)   \   The result may be changed a little....
  |      (__人__)    |
  \     ` ⌒´     /

      ____
    /_ノ   ヽ_\
   /( ●) ( ●)\      Skip the processing required for Ruby,
 / ::::::⌒(__人__)⌒:::::\  not for generating Java Byte Code 
 |        ̄      |   by using jruby.compile.fastest option
 \              /

yaruo@vip% time jruby -J-server -J-Djruby.compile.fastest=true bm_nbody.rb 10000
2.72s user 0.38s system 124% cpu 2.498 total

       ____
     /   ノ( \
   /  _ノ  ヽ、_ \ Since it has come to this,
  / ノ( ●━━●   \   There is no way but forcing compiling to 
  |  ⌒ (__人__) ノ(  | the byte code with  JRuby's  running .
  \     ` ⌒´   ⌒/


% time jruby -J-server -J-Djruby.compile.fastest=true -J-Djruby.compile.mode=FORCE bm_nbody.rb 10000

       ______
      /  \    /\
    /  し (>)  (<)\
    | ∪    (__人__)  J | ________
    \  u   `⌒´   / | |          |
    ノ           \ | |          |


         ____
      /  \    ─\   a glance
    /  し (>)  (●)\
    | ∪    (__人__)  J | ________
    \  u   `⌒´   / | |          |
    ノ           \ | |          |

% time jruby -J-server -J-Djruby.compile.fastest=true -J-Djruby.compile.mode=FORCE bm_nbody.rb 10000
2.90s user 0.40s system 122% cpu 2.689 total

         ____
      /::::::─三三─\
    /:::::::: ( ○)三(○)\  It runs much slower!!!
    |::::::::::::::::::::(__人__)::::  | ________
     \:::::::::   |r┬-|  / | |          |
    ノ::::::::::::  `ー'´   \ | |          |


        ノ L____
       ⌒ \ / \
      / (○) (○)\
     /    (__人__)   \  It's useless to compile to the byte code!!
     |       |::::::|     |
     \       l;;;;;;l    /l!| !
     /     `ー'    \ |i
   /          ヽ !l ヽi
   (   丶- 、       しE |そ  ドンッ!!
    `ー、_ノ       ∑ l、E ノ <
               レY\^V\^ヽl
 

  / ̄ ̄\
 /   _ノ  \
 |    ( ●)(●)
. |     (__人__)      You must consider the time of compilation,
  |     ` ⌒´ノ      generally thinking.
.  |         }
.  ヽ        }
   ヽ     ノ        \
   /    く  \        \
   |     \   \         \
    |    |ヽ、二⌒)、          \


       ____
     /ノ   ヽ、_\
   /( ○)}liil{(○)\
  /    (__人__)   \ Give up JRuby !!!
  |   ヽ |!!il|!|!l| /   |
  \    |ェェェェ|     /


      / ̄ ̄\   
    /ノ( _ノ  \
    | ⌒(( ●)(●)    
    .|     (__人__) /⌒l
     |     ` ⌒´ノ |`'''|
    / ⌒ヽ     }  |  |              
   /  へ  \   }__/ /             / ̄ ̄\
 / / |      ノ   ノ           / ●)) ((●\', ・
( _ ノ    |      \´       _    (   (_人_)'∴ ),  '
       |       \_,, -‐ ''"   ̄ ゙̄''-----└'´ ̄`ヽ   て
       .|                  ______ ノ    (
       ヽ           _,, -‐ ''"  ノ       ヽ   r'" ̄
         \       , '´        し/.. >>@ | J
          \     (           /      |
            \    \         し-  '\^`-J


  / ̄ ̄\
 /   _ノ  \
 |    ( ●)(●)
. |     (__人__)      The more time you will try, The faster JRuby runs, 
  |     ` ⌒´ノ       because it run with JVM optimization,
.  |         }              generally thinking....
.  ヽ        }
   ヽ     ノ        \
   /    く  \        \
   |     \   \         \
    |    |ヽ、二⌒)、          \

yaranaio@vip% time ruby bm_nbody.rb 50000
5.19s user 0.08s system 96% cpu 5.457 total

yaranaio@vip% time jruby -J-server bm_nbody.rb 50000
4.07s user 0.40s system 115% cpu 3.877 total


       ____
     /⌒  ⌒\
   /( >)  (<)\
  /::::::⌒(__人__)⌒::::: \  giggle
  |    /| | | | |     |
  \  (、`ー―'´,    /
       ̄ ̄ ̄  

       ____
     /⌒  ⌒\
   /( ―)  (―)\ JRuby works with "threads" well, 
  /::::::⌒(__人__)⌒::::: \ It can fit for the "multi-core" era !!!
  |              |
  \               /


       ____
     /⌒  ⌒\
   /( ●)  (●)\      JRuby can work parallelly with the native threads, but
  /::::::⌒(__人__)⌒::::: \   MRI can only run with "green threads"!
  |     |r┬-|     |
  \      `ー'´     /


       . ... .
       :____:
     :/_ノ  ー、\:
   :/( ●) (●)。\:
  :/:::::: r(__人__) 、::::\:  ウッ・・・p...
  :|    { l/⌒ヽ    |:
  :\   /   /   /:


       ____
     /-‐  ‐-\
   / ( ⌒) (● )\
  /::::::⌒(__人__)⌒:::::\
  |     l/⌒ヽ    |  Excuse me..
  \   /   /   /

       ____
     /⌒  ⌒\
   /( ●)  (●)\    O.K. Let's try to test bionic merge sort
  /::::::⌒(__人__)⌒::::: \   with JRuby parallelly running! 
  |     |r┬-|     |
  \      `ー'´     /

yaruo@vip% time ruby bitonic_sorting.rb
0.14s user 0.12s system 70% cpu 0.368 total

yaruo@vip% time jruby bitonic_sorting.rb
1.69s user 0.44s system 28% cpu 7.527 total

       ____

     /ノ   ヽ、_\
   /( ○)}liil{(○)\
  /    (__人__)   \ 20 times slower!!!
  |   ヽ |!!il|!|!l| /   |
  \    |ェェェェ|     /


   / ̄ ̄\
 /   _ノ  \
 |    ( ●)(●)
. |     (__人__)  Then you should use thread pool with 
  |     ` ⌒´ノ   jruby.thread.pool.enabled options,
.  |         }     generally thinking....
.  ヽ        }
   ヽ     ノ        \
   /    く  \        \
   |     \   \         \
    |    |ヽ、二⌒)、          \ 
       ____
     /      \
   /  _ノ  ヽ、_  \
  / o゚((●)) ((●))゚o \ O.K. O.K. I'll try that...
  |     (__人__)    |
  \     ` ⌒´     /


% time jruby -J-Djruby.thread.pool.enabled=true bitonic_sorting.rb 
1.80s user 0.45s system 38% cpu 5.828 total

       ____
     /      \
   /  _ノ  ヽ、_  \
  /  o゚⌒   ⌒゚o  \  However, it improve a little...
  |     (__人__)    |
  \     ` ⌒´     /

      ._
       \ヽ, ,、
        `''|/ノ
         .|
     _   |
     \`ヽ、|
      \, V
         `L,,_
         |ヽ、)  ,、
        /    ヽYノ
       /    r''ヽ、.|
      |     `ー-ヽ|ヮ
      |       `|
      |.        |
      ヽ、      |
        ヽ____ノ      
        /_ノ ' ヽ_\
      /(≡)   (≡)\
     /::::::⌒(__人__)⌒::::: \      
     |     |r┬-|     |      
     \      `ー'´     /
     /          \
     (  |          |  )
     \|    э    |/
       (    ,,,,    ,ノ
       \  、(U)ノ ノ
         \/  /            ┼ヽ  -|r‐、. レ |
         /  /\            d⌒) ./| _ノ  __ノ    end..
      ⊂⌒__)__)

About

Tomo

Search

Archives
« 4月 2014
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
今日