short time until first deploy • Fast startup: good response cycle at command line • Straight-line performance, many operations per second • Parallelism: utilize many cores to get more done
• Important parts of standard library • Runs typical Ruby applications and libraries • Healthy extension ecosystem • CRuby, JRuby are the only real options right now
bytecode VM introduced for 1.9.0 • GC and performance improvements through 2.x series • Ruby 2.3 is latest, released in December • Future work on JIT, GC, happening now
interpreter until 2007 • Simple AST-to-bytecode JIT until JRuby 9000 • Optimizing compiler with JIT for 9k • JRuby 9.0.5 is current, 9.1 in a couple weeks • Next-gen Truffle runtime in the works
threads prevented from running in parallel • Extensions, IO can opt to release lock • On JRuby, usually thread-level • Ruby thread == JVM thread == OS thread • Single-process, shared memory
For each job, construct an email to send • Some computation added to make processing heavier • "Ruby Concurrency and Parallelism: A Practical Tutorial" https://www.toptal.com/ruby/ruby-concurrency-and-parallelism-a- practical-primer
(ARGV[1] || 10_000).to_i.times{|i| jobs.push i} workers = (POOL_SIZE).times.map do Thread.new do begin while x = jobs.pop(true) Mailer.deliver do ... end end rescue ThreadError end end end workers.map(&:join)
slower than method calls • case/when is an O(n) cascade of calls • Singleton classes/methods are costly and hurt method cache • Literal arrays, hashes, strings have to be constructed, GCed • Flow-control exceptions can be very expensive and hard to find
pauseless • Built-in tools for analyzing GC, JIT, thread, IO, heap • Built-in remote monitoring via JMX • Dozens of tools out there for profiling, management, and more