Eric Eilebrecht's blog

ThreadPool bug in CLR 2.0 SP1

Shortly after the release of CLR 2.0 SP1 (a.k.a. Orcas or .NET 3.5), several customers noticed some very odd behavior in the ThreadPool.  The ThreadPool is supposed to create threads as fast as possible, up to the current setting for MinThreads - but it turns out that if you queue workitems very quickly (like in a tight loop that just calls QueueUserWorkitem), the pool will expand very slowly - we'll only create one thread every half second (which is the normal behavior once we've reached MinThreads).

Michael C. Kennedy's blog has sample code and some perfmon graphs demonstrating this behavior.  He also posted our suggested workaround, which unfortunately boils down to "don't queue the work items so quickly." 

We plan to fix this in CLR 2.0 SP2 (i.e., .NET 3.5 SP1).  In the meantime, if you should encounter this, please try the workaround.

Published Friday, March 14, 2008 8:13 AM by ericeil
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Michael Kennedy said:

Hi Eric,

Thanks for summing up the issue for everyone. I'm glad to hear that you guys are on top of the problem. We should emphasize that for "real" server applications like ASP.NET and WCF this problem is unlikely to manifest itself. I''m planning a follow up post on the details of the problem and why it won't affect ASP.NET.

March 17, 2008 9:48 AM
 

Michael Kennedy said:

Here's a little more info on this issue:

More on the ThreadPool Bug in .NET 2.0 SP1

http://www.michaelckennedy.net/blog/PermaLink,guid,859d9d70-e822-418f-820c-ca91bed78dcf.aspx

- Michael

April 17, 2008 1:35 PM
 

Eric Eilebrecht's blog said:

SP1 of .NET 3.5 is now available as a Beta release. This beta release has the fix for the ThreadPool

May 12, 2008 3:45 PM

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required
Submit

About ericeil

I have been working for Microsoft since 1997. I started as a test developer in the Windows team, then moved on to develop backend storage services for Hotmail (now Windows Live). I am currently a developer on the Common Language Runtime team, where I work on threading.

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker