From owner-freebsd-questions@FreeBSD.ORG Thu Apr 29 19:49:35 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8CE64106564A for ; Thu, 29 Apr 2010 19:49:35 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email1.allantgroup.com (email1.emsphone.com [199.67.51.115]) by mx1.freebsd.org (Postfix) with ESMTP id 500738FC13 for ; Thu, 29 Apr 2010 19:49:35 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email1.allantgroup.com (8.14.0/8.14.0) with ESMTP id o3TJnYJ3094851 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 29 Apr 2010 14:49:34 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.4/8.14.3) with ESMTP id o3TJnXEp021349 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 29 Apr 2010 14:49:34 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.4/8.14.3/Submit) id o3TJnWIZ021347; Thu, 29 Apr 2010 14:49:32 -0500 (CDT) (envelope-from dan) Date: Thu, 29 Apr 2010 14:49:32 -0500 From: Dan Nelson To: Joerg Bruehe Message-ID: <20100429194932.GI14572@dan.emsphone.com> References: <4BD9D098.8010201@mysql.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4BD9D098.8010201@mysql.com> X-OS: FreeBSD 8.0-STABLE User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: clamav-milter 0.96 at email1.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (email1.allantgroup.com [199.67.51.78]); Thu, 29 Apr 2010 14:49:34 -0500 (CDT) X-Scanned-By: MIMEDefang 2.45 Cc: Greg 'groggy' Lehey , FreeBSD-Questions Subject: Re: Need info about FreeBSD and interrupted system calls for MySQL code X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Apr 2010 19:49:35 -0000 In the last episode (Apr 29), Joerg Bruehe said: > For some long, unknown time, the MySQL code contains a variable > "net_retry_count" which is by default set to 10 (ten) for all platforms, > but to 1000000 (1 million) for FreeBSD (during configure phase). > > The source code comment about this variable reads > If a read on a communication port is interrupted, retry this many > times before giving up. > > The documentation (manual) has this sentence in addition: > This value should be set quite high on FreeBSD because internal > interrupts are sent to all threads. > > I read that as > "On FreeBSD, a thread may receive many more interrupts than on other > platforms, so an operation which may take some time (like network I/O) > may be interrupted much more often than on other platforms, and hence > the retry count should be higher." > > I trust that this comment was valid at the time it was written - > is it still true for current versions of FreeBSD, or did things change? I'm pretty sure this is a holdover from when FreeBSD only had a user pthreads package (libc_r). libc calls that would normally block got converted into non-blocking versions and a select() loop would execute threads as the events they were waiting on occurred. Incoming signals would cause all threads waiting on read() to return EINTR. If you have other threads doing work and sending/receiving signals, this can add up to a lot of extra EINTR's. FreeBSD 5.0 (released in 2003) was the first version to have kernel-based pthread support, so the original reason for raising net_retry_count has long since disappeared. A related question might be, though: Should that variable even exist? EINTR isn't technically a failure, and most programs that read from sockets simply wrap their read()s in a loop that retries when EINTR is received. Only mysql actually counts the number of times through the loop. -- Dan Nelson dnelson@allantgroup.com