<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>time to bleed by Joe Damato - Latest Comments in Ruby threading bugfix: small fix goes a long way.</title><link>http://timetobleed.disqus.com/</link><description></description><atom:link href="https://timetobleed.disqus.com/ruby_threading_bugfix_small_fix_goes_a_long_way/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 22 Apr 2010 15:08:02 -0000</lastBuildDate><item><title>Re: Ruby threading bugfix: small fix goes a long way.</title><link>http://timetobleed.com/ruby-threading-bugfix-small-fix-goes-a-long-way/#comment-46085314</link><description>&lt;p&gt;Appears the patch has been accepted upstream.&lt;br&gt;&lt;a href="http://blog.phusion.nl/2010/01/20/ruby-enterprise-edition-1-8-7-2010-01-released/" rel="nofollow noopener" target="_blank" title="http://blog.phusion.nl/2010/01/20/ruby-enterprise-edition-1-8-7-2010-01-released/"&gt;http://blog.phusion.nl/2010...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">rogerpack</dc:creator><pubDate>Thu, 22 Apr 2010 15:08:02 -0000</pubDate></item><item><title>Re: Ruby threading bugfix: small fix goes a long way.</title><link>http://timetobleed.com/ruby-threading-bugfix-small-fix-goes-a-long-way/#comment-12653969</link><description>&lt;p&gt;do you have a thread called "shrinking thread"...happened to see a quilting show on TV...guest was showing a pillow she had covered and one of the swatches was made w/shrinking thread...made the surface look like it was wrinkled....very atractive....&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Georgia Sewall</dc:creator><pubDate>Tue, 14 Jul 2009 17:57:58 -0000</pubDate></item><item><title>Re: Ruby threading bugfix: small fix goes a long way.</title><link>http://timetobleed.com/ruby-threading-bugfix-small-fix-goes-a-long-way/#comment-8721670</link><description>&lt;p&gt;We're using 1.8.5 p115 and are running into this SIGVTALRM weirdness with Phusion Passenger.  I tried adapting the patch for 1.8.5 and came up with the following:&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.elliterate.com/files/ruby_1.8.5_sigvtalrm_fix.patch" rel="nofollow noopener" target="_blank" title="http://www.elliterate.com/files/ruby_1.8.5_sigvtalrm_fix.patch"&gt;http://www.elliterate.com/f...&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Any reason why this couldn't work?  It doesn't seem to be causing any problems (yet) on our staging server.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ian Lesperance</dc:creator><pubDate>Wed, 04 Feb 2009 23:20:01 -0000</pubDate></item><item><title>Re: Ruby threading bugfix: small fix goes a long way.</title><link>http://timetobleed.com/ruby-threading-bugfix-small-fix-goes-a-long-way/#comment-8721669</link><description>&lt;p&gt;Thanks for the patch, it finally fixed that SIGVTALRM weirdness that I was experiencing. Too bad that I ran in circles trying to understand what I'm doing wrong, when in fact it was a VM bug. But it seems that your fix is not even in the latest 1.8.7 snapshot. Perhaps you need to bug ruby-core again in order to include it.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Roman</dc:creator><pubDate>Tue, 09 Dec 2008 10:11:36 -0000</pubDate></item><item><title>Re: Ruby threading bugfix: small fix goes a long way.</title><link>http://timetobleed.com/ruby-threading-bugfix-small-fix-goes-a-long-way/#comment-8721668</link><description>&lt;p&gt;@roger - This patch has been submit to ruby-core. Also, ruby uses asynchronous blocking I/O.&lt;/p&gt;&lt;p&gt;Stay tuned for a new timetobleed article about different I/O models.&lt;/p&gt;&lt;p&gt;Thanks for reading!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">joe</dc:creator><pubDate>Sat, 25 Oct 2008 04:39:49 -0000</pubDate></item><item><title>Re: Ruby threading bugfix: small fix goes a long way.</title><link>http://timetobleed.com/ruby-threading-bugfix-small-fix-goes-a-long-way/#comment-8721667</link><description>&lt;p&gt;@hongli the mysqlplus library doesn't block if you use async_query :) [oh wait, you probably already knew that].&lt;/p&gt;&lt;p&gt;MRI 1.8.x does use a "non blocking" internal IO--kind of slow [1] but it works.&lt;/p&gt;&lt;p&gt;I'd say definitely submit a patch to core for this one -- others may benefit :) -- wonder if 1.9 is affected [though know nothing about it].&lt;/p&gt;&lt;p&gt;Maybe somebody should actually buy something from software verify :)&lt;/p&gt;&lt;p&gt;Thanks for doing these.&lt;/p&gt;&lt;p&gt;-=R&lt;/p&gt;&lt;p&gt;[1] &lt;a href="http://www.ruby-forum.com/topic/164329#new" rel="nofollow noopener" target="_blank" title="http://www.ruby-forum.com/topic/164329#new"&gt;http://www.ruby-forum.com/t...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">rogerdpack</dc:creator><pubDate>Fri, 24 Oct 2008 12:53:18 -0000</pubDate></item><item><title>Re: Ruby threading bugfix: small fix goes a long way.</title><link>http://timetobleed.com/ruby-threading-bugfix-small-fix-goes-a-long-way/#comment-8721666</link><description>&lt;p&gt;@Hongli Lai: Thanks for the comments - I will try to make my posts more clear in the future.&lt;/p&gt;&lt;p&gt;You are correct that ruby attempts to do non-blocking I/O whenever possible, but it cannot control what the ruby extensions do. So if your ruby extension does blocking I/O, your Ruby process blocks.&lt;/p&gt;&lt;p&gt;I also want to point out that when the actual I/O is occurring (in your example, when there is data for read) that I/O operation WILL block all of Ruby and all green threads.&lt;/p&gt;&lt;p&gt;I plan on writing a blog post or two soon that will talk about different I/O models (blocking vs nonblocking vs async) and I'll touch more on these details there.&lt;/p&gt;&lt;p&gt;Again, thanks for reading and I'll make some corrections to my post to make it more clear.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">joe</dc:creator><pubDate>Mon, 06 Oct 2008 13:45:17 -0000</pubDate></item><item><title>Re: Ruby threading bugfix: small fix goes a long way.</title><link>http://timetobleed.com/ruby-threading-bugfix-small-fix-goes-a-long-way/#comment-8721665</link><description>&lt;p&gt;My phone interview question at YouTube was "How would you build a thread scheduler?"&lt;/p&gt;&lt;p&gt;A stupid question for a phone interview (and the interviewer was entirely too please with himself), but I'm interested in seeing the answer from someone who knows what they're talking about, i.e., not me.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jesse</dc:creator><pubDate>Mon, 06 Oct 2008 12:18:14 -0000</pubDate></item><item><title>Re: Ruby threading bugfix: small fix goes a long way.</title><link>http://timetobleed.com/ruby-threading-bugfix-small-fix-goes-a-long-way/#comment-8721664</link><description>&lt;p&gt;Nice! Have you considered submitting this patch to upstream?&lt;/p&gt;&lt;p&gt;&lt;i&gt;"What this means for the Ruby developer is that any thread which does I/O will cause the entire ruby process (the ruby interpretter and all ruby green threads) to block."&lt;/i&gt;&lt;/p&gt;&lt;p&gt;Sorry, gotta disagree with you here. The MRI core I/O implementation is essentially non-blocking. If it detects that an I/O operation will block, it will simply set the thread's state to 'blocking on I/O' and schedule another green thread instead.&lt;/p&gt;&lt;p&gt;Consider this:&lt;br&gt;require 'thread'&lt;br&gt;require 'socket'&lt;/p&gt;&lt;p&gt;thread = &lt;a href="http://Thread.new" rel="nofollow noopener" target="_blank" title="Thread.new"&gt;Thread.new&lt;/a&gt; do&lt;br&gt;	while true&lt;br&gt;		puts rand&lt;br&gt;		sleep 1&lt;br&gt;	end&lt;br&gt;end&lt;/p&gt;&lt;p&gt;&lt;a href="http://TCPSocket.new" rel="nofollow noopener" target="_blank" title="TCPSocket.new"&gt;TCPSocket.new&lt;/a&gt;('&lt;a href="http://www.google.com" rel="nofollow noopener" target="_blank" title="www.google.com"&gt;www.google.com&lt;/a&gt;', 80).read&lt;/p&gt;&lt;p&gt;Look! The thread keeps running even though we're blocked on a read operation.&lt;/p&gt;&lt;p&gt;What is true however, is that native extensions that:&lt;br&gt;1. use blocking I/O&lt;br&gt;and&lt;br&gt;2. aren't explicitly programmed to support green threads (i.e. to cause a context switch when it detects a potentially blocking condition)&lt;br&gt;will block all green threads. The MySQL library is one such example.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Hongli Lai</dc:creator><pubDate>Mon, 06 Oct 2008 04:33:24 -0000</pubDate></item></channel></rss>