Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

1.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.



In 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.


rb_thread_select is marked deprecated in 1.9.3... so what's the alternative?


ok... replying to myself here... I think if you're using rb_thread_select the answer may be... use select(2) in an rb_thread_blocking_region callback... still not convinced this is better...


The 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: