~/talk

Exploring Internal Ruby Through C Extensions

Talkat RubyKaigi 2018 · 2018-05-31..06-02· [ruby, compilers-and-language-design]
speakerdeck:yuryu
slides:none on file

Reimplements Ruby Hash as a CRuby C extension, a thin C++ wrapper over abseil/ordermap, a pure C++ version and a Ruby-array-backed version, then benchmarks them on an 8‑vCPU Debian VM (Ruby 2.5.1, gcc 6.3.0). Results: pure C++ is fastest, CRuby’s native Hash matches C++ performance, the C++ wrapper is ~20–30% slower and the pure-Ruby reimplementation is ~2.5× slower. Memory measured with Valgrind. Covers VALUE internals, rb_data_type_t, custom mark/free hooks and how mark‑and‑sweep GC costs explain the wrapper’s overhead.

AI-written summary · about

  1. 0:00Introduction and speaker intro
  2. 1:04What are C extensions
  3. 2:31Hello World in C extension
  4. 3:33Reimplementing Ruby Hash in C
  5. 7:11Ruby’s memory management
  6. 10:26Garbage collection in Ruby
  7. 13:00Memory lifecycle in C extensions
  8. 15:15Ruby and C++ code comparison
  9. 18:13How Ruby values work
  10. 20:06Benchmark setup and results
  11. 24:14Why C++ wrapper was slower
  12. 26:30Benchmark pitfalls and string handling
  13. 27:37Key takeaways and best practices
  14. 30:08When to use C extensions
  15. 31:40Recommended resources
  16. 33:10Q&A session
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.