<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Nick Sieger: RubyConf: YARV on Rails</title>
  <id>tag:blog.nicksieger.com,2005:Typo</id>
  <generator uri="http://www.typosphere.org" version="4.0">Typo</generator>
  <link rel="self" type="application/atom+xml" href="http://blog.nicksieger.com/xml/atom10/article/96/feed.xml"/>
  <link rel="alternate" type="text/html" href="http://blog.nicksieger.com/articles/2006/10/23/rubyconf-yarv-on-rails"/>
  <updated>2007-08-31T16:57:20+00:00</updated>
  <entry>
    <author>
      <name>Nick Sieger</name>
    </author>
    <id>urn:uuid:b15da1fc-f69e-4ff2-899b-0a141f61ab21</id>
    <published>2006-10-23T14:15:00+00:00</published>
    <updated>2007-08-31T16:57:20+00:00</updated>
    <title>RubyConf: YARV on Rails</title>
    <link rel="alternate" type="text/html" href="http://blog.nicksieger.com/articles/2006/10/23/rubyconf-yarv-on-rails"/>
    <category term="ruby" label="ruby" scheme="http://blog.nicksieger.com/articles/category/ruby"/>
    <category term="rubyconf" scheme="http://blog.nicksieger.com/articles/tag/rubyconf"/>
    <category term="rubyconf2006" scheme="http://blog.nicksieger.com/articles/tag/rubyconf2006"/>
    <content type="html">&lt;h2&gt;Koichi SASADA&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Update: corrected performance numbers &amp;#8211; 20x, not 20%!&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Got a job developing YARV at the University of Tokyo!  He&amp;#8217;s now employed at Akhihabara, Otaku City.&lt;/li&gt;
&lt;li&gt;Member of Nihon-Ruby-no-Kai&lt;/li&gt;
&lt;li&gt;Present at RubyKaigi 2006 (200 tickets sold in 3 hours).  RubyKaigi 2007 will be June 9-10 (Saturday and Sunday).&lt;/li&gt;
&lt;li&gt;Member of Nihon-Perl-no-Kai&lt;/li&gt;
&lt;li&gt;Co-author of Perl book on Parrot in Japanese&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;DEMO&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Demo creating Rails app]&lt;/li&gt;
&lt;li&gt;Create app with YARV (&lt;code&gt;rails foobar&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Edit config/boot.rb, add a &lt;code&gt;GC.disable&lt;/code&gt; line (there&amp;#8217;s a bug to be fixed when he gets back to Japan).&lt;/li&gt;
&lt;li&gt;Start up WEBrick, and it works!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Glossary&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Rite: code name of Ruby 2.0 (a.k.a. vaporware!)&lt;/li&gt;
&lt;li&gt;YARV: Yet Another Ruby VM&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;YARV&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Supported by funds from IPA (now finished)&lt;/li&gt;
&lt;li&gt;Simple stack machine, with VM instructions, a compiler and interpreter&lt;/li&gt;
&lt;li&gt;Optimization techniques to improve performance&lt;/li&gt;
&lt;li&gt;Open source&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Optimizations include compile-time optimization, native threading, specialized instructions, instruction unification, inline method cache, and stack caching.  YARV can build with configure/make, but doesn&amp;#8217;t work with AC 2.6 (maybe you know why?).  It passes most of the Ruby tests, but misses a few due to implementation differences.&lt;/p&gt;

&lt;p&gt;[Koichi showed a demo controlling iTunes on Windows with Win32/OLE with YARV, and a native-threaded scenario in IRB.]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Myths of YARV&lt;/strong&gt;:  YARV is great!  YARV will solve all problems!  It makes Ruby programs go 50 times faster!  It solves character issues!  It finds your girlfriend!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Truths&lt;/strong&gt;: YARV is for running Ruby programs, fast.  It provides up to a 20x speed up for some algorithm benchmarks (Ackermann, Fib), but not for others [graphs shown].  You assemble and disassemble YARV instruction sequences, or serialize and de-serialize them.  They are just Ruby literals, so they can be packed in YAML or some other human-readable format.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;yasm&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;yaml&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="ident"&gt;iseq&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;YASM&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;toplevel&lt;/span&gt;&lt;span class="punct"&gt;([&lt;/span&gt;&lt;span class="symbol"&gt;:a&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="symbol"&gt;:b&lt;/span&gt;&lt;span class="punct"&gt;])&lt;/span&gt; &lt;span class="punct"&gt;{|&lt;/span&gt;&lt;span class="ident"&gt;ib&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;
    &lt;span class="ident"&gt;ib&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;answer&lt;/span&gt;
    &lt;span class="ident"&gt;ib&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;leave&lt;/span&gt;
&lt;span class="punct"&gt;}&lt;/span&gt;

&lt;span class="ident"&gt;p&lt;/span&gt; &lt;span class="ident"&gt;iseq&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;to_a&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;to_yaml&lt;/span&gt; &lt;span class="comment"&gt;# =&amp;gt; (gave a readable YAML view of the assembly)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Threading&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Ruby thread is mapped 1:1 to a native thread&lt;/li&gt;
&lt;li&gt;Supports POSIX and Win32&lt;/li&gt;
&lt;li&gt;Many existing Ruby libraries are not synchronized at the C level, so many C libraries need synchronization added to them&lt;/li&gt;
&lt;li&gt;Thread model 2: 1:1 mapping, with a Giant Lock (GL).  Only the thread that has the lock can run.  No need for sync, but no parallelism&lt;/li&gt;
&lt;li&gt;Thread model 3: Ruby threads in parallel, but when thread-unsafe code is executing, GL needs to be obtained&lt;/li&gt;
&lt;li&gt;Mutex class will become builtin&lt;/li&gt;
&lt;li&gt;Thread.critical will vanish (not obsolete, but unsupported) [this was a controversial point for some &amp;#8211; the comment was that it&amp;#8217;s a near impossibility to keep it with a native threading model though, the two are in compatible]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Matz: 1.9.1 in 2007 Christmas, but Ruby 1.9.1 is also to be merged with YARV, so Koichi hopes to complete the merge by spring or summer 2007.  Thread model 2 will need to be used to begin with.&lt;/p&gt;

&lt;h2&gt;Future&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;set_trace_func&lt;/code&gt; hook functions &amp;#8211; what to do here?  [It was suggested by Charles Nutter to remove it, to which Matz replied that we could as long as we have a good replacement debugging API.]&lt;/li&gt;
&lt;li&gt;Catch up with Ruby 1.9&lt;/li&gt;
&lt;li&gt;JIT/AOT compiler (AOT compiler started but incomplete)&lt;/li&gt;
&lt;li&gt;Koichi also has a side project: high-performance Ruby, with the goal of making it easy to write performant code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Links&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.atdot.net/yarv/"&gt;http://www.atdot.net/yarv/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;ML: yarv-dev and yarv-dev-en &amp;#8211; Bug tracking with &amp;#8220;Subject: [BUG] foo bar&amp;#8221;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.atdot.net/~ko1/yarvbugs"&gt;http://www.atdot.net/~ko1/yarvbugs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://i.loveruby.net/autobuild/yarv"&gt;http://i.loveruby.net/autobuild/yarv&lt;/a&gt; &amp;#8211; YARV build process&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More developers and testers are welcomed to the project!&lt;/p&gt;</content>
  </entry>
</feed>
