Here's the quiz of the day: Can you find the exclusive lock in this code?
(hint: it begins on line 2, and ends on line 36)
It seemed reasonable that ActiveRecord.allow_currency would make my application be able to run concurrent queries. Well, that's what I thought :) Until I had discovered my 6 threads (which properly formed 6 new connections to the database) were still executing queries serially, instead of in parallel! When investigating what the hold up was, I found my culprit: Ruby 1.8's green threads lose control when you run native C functions, well at least Mysql#query anyways.
So, note to self and world: any time you run a native function that takes a long time, look forward to a big, exclusive lock down.
All the more reason I'm excited for Ruby 1.9's native threads
So, web, do you know if there's a way to "poll" ruby's thread scheduler while in a native C function while waiting for some other task to finish?
Subscribe to Post Comments [Atom]
March 2008 April 2008 May 2008 June 2008 July 2008 August 2008 October 2008 November 2008 February 2009 June 2009 December 2009 January 2010 February 2010 May 2010 June 2010 November 2010
Subscribe to Posts [Atom]