4 ms·
I'm a little unclear about threads in ruby 1.9. I've been told in the past that threads in ruby were problematic. Can anyone illuminate the current state of a
by tedsuo 15y ago
I'm a little unclear about threads in ruby 1.9. I've been told in the past that threads in ruby were problematic. Can anyone illuminate the current state of affairs?
- riffraff 15y ago1.8 had green threads and when the interpreter blocked on some operations it would block all the threads. 1.9 uses native threads but it has a global interpreter lock which has known issues. I am not sure what the improvements to locking in 1.9.3, as the changelog has quite a few commits related to that.
- wycats 15y agoIn both Ruby 1.8 and 1.9, Ruby code will not cause all threads to block when the CPU is idle. However, poorly coded C libraries that blocked on IO without providing Ruby a file descriptor (via rb_thread_select) could cause all threads to block. Those libraries have largely been fixed or replaced (e.g. mysql with mysql2). Ruby 1.9.2 also provides a mechanism for C code to release the GIL if it does not involve any Ruby code, which is used Blythe typecasting code in mysql2, for instance.
- mperham 15y agoThe threading change for 1.9.3 is a scheduler change that just lessens the chance of thread starvation. It's nothing to get excited about.