Notes from RubyConf 2017 AU talks
Reinvesting in Ruby by Tim Riley
Video
- Rails was defining the Ruby ecosystem, time to explore other alternatives
- Introduces dry-rb gems on a blog post example
- Minimalistic, single-responsibility, composable gems for common tasks
- dry-validation, dry-monads, dry-matcher - pattern matching
Actors in Ruby! Why let Elixir have all the fun by Marcos Matos
Video
- Threads vs. forks (forks heavy - even with CoW optimisations).
- Forking does not have built-in way to communicate - some form of IPC is required, e.g. message queues.
- GIL is not a problem for IO workloads - it is not held during IO (network calls or file reads).
- Core issue is sharing mutable state and managing threads
- Introduction to Celluloid
- async programming, actors -> OO + message passing
- message passing, actors mutate their own, isolated state, process messages from mailbox
- actors - thread based workers
- managed worker pool
- supervision of workers, composable to hierarchies
- linking -> ‘running/dead’ dependency
- Dcell (distributed actors, ZeroMQ)
Defragging Ruby by Aaron Patterson
Video
- Ruby heap layout (pages, slots)
- Memory alignment - objects on 40 byte boundary, pages 16k (407, 408 objects on a page)
- Certain objects do not get allocated on the heap (pointer tagging - alignment frees lower bits for tagging)
- Idea: defragment heap, to free pages after they get fragmented after GC - improve locality, performance. Run GC.compact after app startup, before forking new Unicorn workers.
ObjectSpace.dump_all
+ determining page address => heap fragmentation map
- An algorithm to compact heap (two finger compaction, or Cheneys GC algoithm )
- Obstacles (memory address dependent code - e.g.
object_id
, C extensions).
- Certain pages still cannot get freed, only compacted.
- Solution - keep a hash table of un-relocatable objects. Sounds hacky, maybe no other way to keep backwards-compat?
- Code in a public repo
Video
- Have a benchmarking suite - benchmark-ips, method_profiler
- Profile methods, find out the bottleneck - memory, CPU, IO bound workload?
- Upgrade MRI Ruby - constant perf improvements in newer versions
- Try multithreading
- Try alternative implementations JRuby, Rubinius - might be better for certain workloads, benchmarks required
Ruby, HTTP2 by Hiro Asari
Video
- Intro to how H2 works
- There’s no proper support in Ruby/Rack yet, apart from a few H2 clients. Rack is solely request/response oriented.