~/talk

Why Hashes Will Be Faster in Ruby 2.0

Talkat GoRuCo 2012 · on Saturday, 2012-06-23· [ruby]
slides:none on file

Ruby 2.0 replaces the old st_table entries for small maps by packing keys and values into the hash’s pointer array so stores keys and values inline and up to six key/value pairs avoid separate allocations. The change eliminates per-entry mallocs for small inserts (no malloc for small inserts), makes the first few inserts measurably faster, and causes a performance spike when switching back at the seventh entry. Measured results: microsecond lookups, ~6% faster loading 10,000 AR rows, ~2.5% faster on a Rails spec; an instrumentation run counted 409 hashes created for three lines.

AI-written summary · about

  1. 0:00Introduction
  2. 0:44How Ruby hashes work
  3. 3:13Hash function and buckets
  4. 5:19Ruby 2.0 hash optimizations
  5. 7:22Performance impact
  6. 9:50Hashes in Rails internals
  7. 10:33Conclusion & Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 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
?
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.