Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rustでゴミ集め
Search
monochrome
June 13, 2021
Programming
390
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rustでゴミ集め
プログラミング言語Slack 定期ミートアップ#2 2021/06/13
Rustでゴミ集め
monochrome
June 13, 2021
More Decks by monochrome
See All by monochrome
RubyKaigi2026: Invariants in my own Ruby
sisshiki1969
0
31
Improving my own Ruby thereafter
sisshiki1969
1
260
あなたとJIT, 今すぐアセンブ ル
sisshiki1969
1
1.1k
Improve my own Ruby
sisshiki1969
1
610
My own Ruby, thereafter
sisshiki1969
0
430
Running Optcarrot (faster) on my own Ruby.
sisshiki1969
1
340
仮想マシンにおけるスタックの管理
sisshiki1969
0
250
RustでつくるRubyのFiber
sisshiki1969
0
340
Shinjuku.rs#15 Rustでつくるx86アセンブラ
sisshiki1969
0
1.8k
Other Decks in Programming
See All in Programming
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
130
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
180
Snowflakeで業務アプリを作ろう。 Snowflakeのアプリ機能解説&実践ガイド
ayumu_yamaguchi
2
300
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
270
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.8k
海上で動くGoサーバー: goroutineとchannelでさばく航行データストリーム
atsuki_seo
0
910
SREの越境 / SRE Collaboration
y0hgi
2
270
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
190
Workers Cache を知る
syumai
0
210
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
4.9k
一人だけ、Kiroが静止する日
hideg
0
130
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
120
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1369
210k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.9k
What's in a price? How to price your products and services
michaelherold
247
13k
Designing Experiences People Love
moore
143
24k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
530
Discover your Explorer Soul
emna__ayadi
2
1.3k
Balancing Empowerment & Direction
lara
6
1.3k
Navigating Weather and Climate Data
rabernat
0
530
Agile that works and the tools we love
rasmusluckow
331
22k
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バグるとつらい。