Ruby multithreaded program uses only 100% processor

I am using ruby-head and Debian wheezy x64. When I run a multi-threaded ruby ​​script, htop shows that it uses several cores visually with bars at the top and that it uses 100% CPU in the process list, but uses only 100% of the capacity of one core. I assume that you can use several cores at 100%, and this number seems too convenient for bottle drying either by program logic or other hardware aspect. Is the OS limiting the number of instructions that I use, if so, how can I stop this?

EDIT more:

When I mean the visual use of several cores, for example: 47% of core 1, 29% of core 2 and 24% of core 3. These percentages constantly shift up and down to different sets of cores, but always together make up to 100% -102% . More than 3 (/ 8) cores are used, but any cores except the three most loaded ones use only 2% or less. I think I should also mention that this is a linear VPS.

EDIT:

Well, it looks like I read promises that 2.0 will contain true parallel threads, and not the actual release information. Time to switch to Jruby ...

+4
source share
2 answers

You did not specify which version of Ruby you are using. Not all Ruby implementations are capable of scheduling Ruby threads for multiple processors.

In particular:

  • MRI Ruby- ; .
  • YARV Ruby ( POSIX Windows) , Giant VM Lock (GVL), Ruby
  • Rubinius Ruby ( POSIX Windows) , Global Interpreter Lock (GIL), Ruby ; Rubinius 2.0 , Ruby .
  • JRuby Ruby- JVM , ; , , , JVM, ,
  • IronRuby Ruby CLI , ; , , , VES, ,
  • MacRuby Ruby , .

, , , .

+10

MRI Ruby Threads . , , .

.

+4

All Articles