Search code examples
ruby-on-railsrubymultithreadingcelluloid

How to disable GIL in ruby?


I am pretty much new to Ruby and I was working on a project to run a multithreaded ruby program implemented using celluloid library.

It seems like when I try to run the program using the command:

ruby program_name.rb

The code don't run properly and it says GIL is stopping it from making use of multiple cores. I understand GIL is a locking mechanism used by ruby interpreter, but I was wondering if there is a way to diable it with a special command to make concurrent program run.

If this is something impossible, is there any other way to execute multithreaded program in ruby / with any online editor/IDE that supports such multithreading in Ruby?


Solution

  • Use jRuby or Rubinius

    I prefer rvm for this. See: http://rvm.io

    Then run:

    rvm get stable
    rvm install jruby 
    

    For jRuby. Change to rbx for Rubinius.

    Then you can switch between Ruby engines with:

    rvm use <jruby/rbx>
    

    Using Celluloid you ought to try both and compare them often.