A lot of people talk about the GIL (global interpreter lock) in Ruby 1.9 as a death knell for concurrency. For the uninitiated, the GIL disallows multiple CPU cores from running Ruby code simultaneously. That does mean that you'll need one Ruby process (or thereabouts) per CPU core, but it also means that if your multithreaded code is running correctly, you should need only one process per CPU core. I've heard tales of six or more processes per core. Since it's possible …
Developers hankering for more performance from their Rack and Rails applications are using Ruby 1.9 fibers and event-based EventMachine -driven libraries as a way to boost the performance of their applications - in opposition to scaling by merely running multiple processes or using threads.
It's no secret that thread-based development can be Hard™, even if you didn't have to deal with Ruby quirks like autoloading not working properly and the GIL ( Global Interpreter Lock…
Rails and MySQL go hand in hand. ActiveRecord is perfectly capable of using a number of different databases but MySQL is by far the most popular choice for production deployments. And therein lies a dirty secret: when it comes to performance and 'scalability' of the framework, the Ruby MySQL gem is a serious offender. The presence of the GIL means that concurrency is already somewhat of a myth in the Ruby VM , but the architecture of the driver makes the problem even worse. Let's take a look under the hood.
…simply broken and Ruby's thread implementation does not scale at all due to the GIL.
Here's a sample action which uses memcached and the database. There's nothing odd here - it's the same old Rails API and codebase we are used to as Ruby developers, it just executes differently under the covers.
class HelloController < ApplicationController def world site_ids = Rails. cache . fetch 'site_ids' , :expires_in => 1. minute do Site. …
Getting concurrency in Ruby is tough: Ruby 1.8 threads are green so they don't execute concurrently. Ruby 1.9 threads are native but they don't execute concurrently due to the GIL (global interpreter lock) necessary to ensure thread-safety with native extensions. Only JRuby provides a stable, concurrent Ruby VM today. On top of that, writing thread-safe code is tough - code execution is non-deterministic and so everyone gets it wrong, the code is hard to test and bugs painful to track down.
…0.5 beta 1 ), and the benefits are numerous: machine code compilation, true concurrency (no GIL), a working JIT, and even ahead of time compilation ( AOT)!
In other words, MacRuby is now a true Ruby compiler. You can write a HotCocoa app, leverage native POSIX threads, or even take advantage of Apple's Grand Central Dispatch ( GCD) and then compile your program and distribute it as a binary to any OSX user.
With 7 members on the team and a growing community …
…still incomplete version of Ruby), which brings JIT, removal of the dreaded GIL ( Global Interpreter Lock), native threads, GCD ( Grand Central Dispatch) for multicore computing, and a whole new set of features found in the release announcement to the table.
The most important new feature is the presence of a compiler. That's right, thanks to this release, Ruby code can now become highly optimized executable code. How awesome is that? I can sense that you're pumped …