Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Rustでゴミ集め
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
monochrome
June 13, 2021
Programming
1
350
Rustでゴミ集め
プログラミング言語Slack 定期ミートアップ#2 2021/06/13
Rustでゴミ集め
monochrome
June 13, 2021
Tweet
Share
More Decks by monochrome
See All by monochrome
Improving my own Ruby thereafter
sisshiki1969
1
200
あなたとJIT, 今すぐアセンブ ル
sisshiki1969
1
950
Improve my own Ruby
sisshiki1969
1
440
My own Ruby, thereafter
sisshiki1969
0
370
Running Optcarrot (faster) on my own Ruby.
sisshiki1969
1
280
仮想マシンにおけるスタックの管理
sisshiki1969
0
220
RustでつくるRubyのFiber
sisshiki1969
0
300
Shinjuku.rs#15 Rustでつくるx86アセンブラ
sisshiki1969
0
1.7k
fukuoka.rb#202 RustでつくるRuby
sisshiki1969
1
850
Other Decks in Programming
See All in Programming
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
680
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
21
7.1k
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
170
CSC307 Lecture 06
javiergs
PRO
0
680
AtCoder Conference 2025
shindannin
0
1.1k
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
130
SourceGeneratorのススメ
htkym
0
190
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
4
270
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
430
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
260
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
5
400
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
89
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
64
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
120
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
57
50k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
Skip the Path - Find Your Career Trail
mkilby
0
53
Darren the Foodie - Storyboard
khoart
PRO
2
2.4k
The World Runs on Bad Software
bkeepers
PRO
72
12k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
0
3.4k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
230
Transcript
プログラミング言語Slack 定期ミートアップ#2 2021/06/13 Rustでゴミ集め monochrome twitter: @s_isshiki1969
ruruby (https://github.com/sisshiki1969/ruruby) • 純Rust製のRuby実装 • 仮想マシンインタプリタ • 他の既存実装・仮想マシンへの依存なし • Rubyの標準ライブラリはRustで実装
• ガーベジコレクタを独自実装 • 2万行ぐらい
参考文献 Richard Jones et al. 翻訳監修:前田敦司 鵜川始陽 小宮 常康 翔泳社, 2016 中村成洋 相川光
秀和システム, 2010 moppris 技術書典5, 2016
Garbage collector Mutator (VM) Allocator ヒープ割り当て Collector 不要なオブジェクトの回収 割り当て要求 GC起動
*mut RValue
Rubyオブジェクトの内部表現 struct Value(std::num::NonZeroU64); struct RValue { class: Module, var_table: Option<Box<ValueTable>>,
kind: ObjKind, } (56 bytes) struct GCBox<T: GC> { inner: T, next: Option<GCBoxRef<T>>, } (64 bytes)
Page 0 7 8 15 16 20 23 4031 0x4_0000
20 mark bitmap 0 7 64b x 4032 slot
Allocator Free list
Allocator Free list
Collector 起動 Free list
Garbage collection: Mark local variables method Array local variables method
Hash K V K V K V K V Object Instance variables Free list
Garbage collection: Sweep local variables method Array local variables method
Hash K V K V K V K V Object Instance variables Free list
Collector 処理終了 Free list mark bitmap
Allocator Free list
benchmark: aobench.rb (GC on / off)
バグりがちな点 var = [1, 2, 3].map { |x| x.to_s }
配列オブジェクトをイテレートし、 各要素を関数で処理して戻り値を集め 配列を作って返すRubyスクリプト
var = [1, 2, 3].map { |x| x.to_s }
①VM実行中にGCが起動すると… GC! ②作成中のオブジェクト が回収されてしまう ③VMは気づかず処理続行 → いつの間にか上書きされてバグる var = [1,
2, 3].map { |x| x.to_s }
まとめ • GCつくりました。 • GCバグるとつらい。