From owner-freebsd-threads@FreeBSD.ORG Mon Dec 21 15:18:09 2009 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B00F11065695 for ; Mon, 21 Dec 2009 15:18:09 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 853A78FC16 for ; Mon, 21 Dec 2009 15:18:09 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 4314346B03; Mon, 21 Dec 2009 10:18:09 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 2AA088A01F; Mon, 21 Dec 2009 10:18:08 -0500 (EST) From: John Baldwin To: freebsd-threads@freebsd.org Date: Mon, 21 Dec 2009 10:09:44 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.2-CBSD-20091103; KDE/4.3.1; amd64; ; ) References: <26d2cb010912202315g574353d9g872643d1717f4f86@mail.gmail.com> In-Reply-To: <26d2cb010912202315g574353d9g872643d1717f4f86@mail.gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912211009.44660.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Mon, 21 Dec 2009 10:18:08 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: Subject: Re: disable threads when recompiling libc X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Dec 2009 15:18:09 -0000 On Monday 21 December 2009 2:15:13 am leon zadorin wrote: > Hi, > > is it possible to configure libc to be recompiled in a single-threaded > model only (i.e. disable any additional overhead for handling > thread-safety). > > Basically what I'd like to do is to build a separate non-multithreaded > copy of libc and use it with the rest of "single threaded > environment": > > recompiled gcc (./configure --disable-threads), etc. > c++ boost libs in non-multithreaded mode and so on > > I would like to see if there are any additional performance-benefits > to this (my program does not need to be multi-threaded). > > I think compiler itself can produce more optimisations (various > speculative loads et al) if it is building code for single-threaded > model only... I wonder if there are also "single-threaded" performance > benefits to libc et al ? libc already conditionalizes all the extra multi-thread protection on __isthreaded which only gets set to 1 the first time pthread_create() is invoked, so all you would be able to test is removing several 'if (__isthreaded)' tests. You could perhaps make use of this to build a test libc though by #defining __isthreaded to 0 and relying on the compiler to eliminate all the conditional threading code as dead code. -- John Baldwin