Download - Small eigen collider ruby kaigi 2011
![Page 1: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/1.jpg)
Andrew GrimmUniversity of New South Wales
ニューサウスウェールズ大学 (UNSW)RubyKaigi 2011
日本 Ruby 会議 2011
Finding Black Holes in Ruby with the Small Eigen Collider
小型特異衝突型加速器で Ruby内のブラックホールの特異点を見つけ
る方法
![Page 2: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/2.jpg)
tl;drToo Long, Didn't Read(長過ぎてよん
でられない ) Creates random code. Metaprogramming magic! ランダムなコードを作成します。メタプログラミングマジック!
![Page 3: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/3.jpg)
Why?なんで?
Why did I create the Small Eigen Collider? なぜ私は小型特異衝突型加速器を作成した ?
![Page 4: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/4.jpg)
Background背景
Bioinformatician at UNSW UNSW のバイオインフォマティクス Looking at mutations in HIV HIV感染の変異を見て
![Page 5: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/5.jpg)
Looking at mutations私は突然変異で探しています
Start with viruses with identical DNA sequence 同一の DNA配列を持つウイルスで始まります Allow to reproduce for one generation in laboratory 実験室内の 1つの世代のために再現することができます
Determine DNA sequence of new viruses 新しいウイルスの DNA配列を決定する Differences are mutations 違いは突然変異です
![Page 6: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/6.jpg)
Big dataビッグデータ
Looking at approximately 500,000 sequences 約 50万シーケンスを見て Approx. 150,000,000 DNA letters (A, C, G, T) 約。 1.5億 DNAの文字( A、 C、 G、 T) For comparison, human genome is 3,000,000,000
letters 比較のために、ヒトゲノムは 30億文字です
![Page 7: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/7.jpg)
Problem
Ruby is too slowXKCD 303
問題
Rubyは遅すぎる
![Page 8: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/8.jpg)
How slow is my application?私のアプリのスピード
Currently using YARV Ruby 1.9.1 My application looks at 500,000 sequences 50万件のルックアップ An analysis takes 20 minutes 解析には20分かかる
![Page 9: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/9.jpg)
That's after some optimizing!ちなみにこれはチューニングの
後の数字です
![Page 10: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/10.jpg)
Other Rubies might be fasterほかの Ruby実装はもっと速いかも
![Page 11: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/11.jpg)
JRuby Faster at some tasks Real multithreading (no GIL) 特定の処理は高速で真のマルチスレッド
![Page 12: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/12.jpg)
Rubinius Faster at some tasks Real multithreading Real Soon Now 特定の処理は高速で真のマルチスレッドも近日リリース
![Page 13: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/13.jpg)
Ruby Enterprise Edition Mainly better at garbage collection GCが良い。 More relevant to Rails developers than me Rails開発者向き
![Page 14: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/14.jpg)
How do I know it'll give the correct results? どのように私はそれが正しい結果を与えているか知ることができる?
Should I switch to a faster Ruby?もっと早い Ruby実装に乗り換える
べき?
![Page 15: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/15.jpg)
What kind of errors worry me?どういうエラーが心配?
Large, obvious bugs that cause an exception are fine エラーを生じる明らかなバグはあまり心配なし
Small, subtle bugs that give an incorrect result are bad
些細でまちがった結果を生じるバグがやばめ
![Page 16: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/16.jpg)
Other implementations are wrong他の実装が間違っている
Ran my project against Rubinius – 1 unit test failed Rubiniusで自分のプロジェクトを走らせてみた -テストが一つ失敗した
![Page 17: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/17.jpg)
Other implementations are wrongerer他の実装では、さらに間違ってい
る Ran BioRuby with Rubinius – 1 unit test failed Rubiniusで BioRubyを走らせてみた -テストが一つが失敗した
![Page 18: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/18.jpg)
Even JRuby is not immuneJRubyも例に漏れず
Made mistakes in the complicated task of splitting a file into lines
ファイルを行に分割する複雑な作業でミス
![Page 19: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/19.jpg)
How many bugs cause 0 failures?Failしないバグはいくつ?
3 bugs caused 1 unit test failure each 3つのバグがそれぞれ一つの Fail テストを生じる
How many bugs caused 0 unit test failures each? では Failしてない時のバグはいくつ?
![Page 20: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/20.jpg)
How can I be sure there weren't others?どのように他のエラーがないことを確認することができる?
Rubinius and JRuby had failed me. RubySpec had failed me.
Rubiniusでも JRuby でも RubySpecでもうまくいかなかった
![Page 21: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/21.jpg)
What could I do? 私には何ができる?
XKCD 386
![Page 22: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/22.jpg)
What assumptions can I make about the problem?
問題に対してどういった想定をすれば良い?
![Page 23: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/23.jpg)
Bugs are simpleソフトウェアのバグは簡単
Isolate them to a single failure, not several failures 、複数のフェイルがでているコードを単一のフェイルがでているところまで分離
![Page 24: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/24.jpg)
Bugs are simple to fixバグの修正は簡単
Rubinius folk fixed bugs promptly Rubinius 開発者で 1日以内にバグを修正
String#split 1 day (1日 ) StringIO#gets 1 day (1日 ) String#casecmp 3 days (3日 )
![Page 25: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/25.jpg)
Unexplored territory未踏の領域
Bugs are from trying something not done before バグというのは今まで行われていなかった領域に足を踏み込む前に現れる
![Page 26: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/26.jpg)
I'm happy to report that this is the first ever "Rubinius doesn't support flipflop" bug. I've been waiting for this day.
「 Rubiniusがほげほげをサポートしてない」的なバグリポートをする日をずっと待っていた
I'll go ahead and implement it now, I was waiting for someone to report it. It only took 5 years.
今すぐ実装するよ。だれかがリポートしてくれるのを5年間待ってたし
![Page 27: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/27.jpg)
What is the Small Eigen Collider?
小型特異衝突型加速器って何?
![Page 28: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/28.jpg)
How Small Eigen Collider Works小型特異衝突型加速器はどう動く? Create same tasks, run on different Rubies, compare
results 別のルビーで同じタスクを実行し、結果を比較。
![Page 29: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/29.jpg)
Comparing results比較結果
Me: What is the result of "a".casecmp("b")? YARV: -1 JRuby: -1 Rubinius: +1
![Page 30: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/30.jpg)
Task executionタスクの実行
receiver.send(method_name, *parameters, &block) "a".send(:casecmp, ["b"], &:inspect)
![Page 31: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/31.jpg)
Task creation – objects タスクの作成 - オブジェクト
Receiver and parameters are objects chosen at random, with a random number of parameters
レシーバとパラメータはランダムに作成されたオブジェクト
![Page 32: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/32.jpg)
Task creation – method タスクの作成 - メソッド
Potential methods based on reflection リフレクションによるメソッド候補作成 "a".methods # => [:upcase, :zip, ..., :casecmp, …] Method chosen at random 最後はランダムに選ばれる
![Page 33: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/33.jpg)
Result comparison
Receiver object: “a”Method: “casecmp”Parameters: [“b”]Result: -1
diff MRI_output.txt rubinius_output.txt 180c180< Result: -1---> Result: 1
結果の比較
![Page 34: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/34.jpg)
Task serializationタスクのシリアル化
Required for consistency これは、一貫性のために必要
![Page 35: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/35.jpg)
Segmentation faultsセグメンテーションフォールト
CRuby and Rubinius can crash, so need tasks saved CRubyと Rubiniusはクラッシュする可能性があるので、タスクを保存する必要あり
![Page 36: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/36.jpg)
Discoveries発見
![Page 37: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/37.jpg)
Bugsのバグ
String#casecmp bug in Rubinius String#casecmp Rubiniusのバグ
![Page 38: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/38.jpg)
Segmentation faultsセグメンテーションフォールト
Found in CRuby and Rubinius CRuby と Rubinius で検出 Thread.kill(nil) caused a segfault in YARV Thread.kill(nil) が YARV でセグフォールとを
引き起こした
![Page 39: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/39.jpg)
Current difficulties現在の課題
![Page 40: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/40.jpg)
Inconsistencies in inspectinspectの結果が実装ごとに異なる
inspect has different results between implementations
Default: #<StringIO:0x10169cfd8> Rubinius: #<StringIO:0xf7c @string=""
@lineno=0 @append=false @readable=true @writable=true @pos=0>
![Page 41: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/41.jpg)
False alarms誤報
Is giving nil rather than false a problem? "false"でなく "nil"を与える事は問題? "\n".is_binary_data?
Rbx, MRI 1.8: false JRuby 1.8: nil
![Page 42: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/42.jpg)
Future directions将来の方向性
![Page 43: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/43.jpg)
Faster高速化
Faster is often better 速ければより良い Move it to the cloud? クラウドに移行?
![Page 44: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/44.jpg)
Questions? 質問?
![Page 45: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/45.jpg)
Extra material!補足資料
![Page 46: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/46.jpg)
String#casecmp testing
describe "String#casecmp" do it "is a case-insensitive version of String#<=>" do "abcdef".casecmp("abcde").should == 1 "aBcDeF".casecmp("abcdef").should == 0 "abcdef".casecmp("abcdefg").should == -1 "abcdef".casecmp("ABCDEF").should == 0 end # Snipped I18N testsend
Testing everything except “happy path”! エッジケースのみテスト
![Page 47: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/47.jpg)
Other bugs found by SECSECで見つかったバグ
YAML.load(YAML.dump(Regexp.new('',0,'n'))) ''.unpack('d') { true } ObjectSpace.undefine_finalizer(:symbol) Fixnum.set_superclass Object ; 42.to_int YAML.try_implicit(0)
![Page 48: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/48.jpg)
Other bugs independent of SECSECとは別に見つかったバグ
"XabXcd".split("X", 2) # => ["ab"] but no "cd" StringIO.new("phone").gets("on") # => gives "pho"
when it should give "phon"
![Page 49: Small eigen collider ruby kaigi 2011](https://reader035.vdocuments.mx/reader035/viewer/2022062905/5555a8ebd8b42a52568b47e4/html5/thumbnails/49.jpg)
Thankyou!Domo arigato!
どうもありがとう Translations:
Makoto Inoue-san mame2-san Google Translate-san