From owner-freebsd-toolchain@FreeBSD.ORG Sun Jan 13 13:32:02 2013 Return-Path: Delivered-To: toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D8D0A999; Sun, 13 Jan 2013 13:32:02 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 9E2C963E; Sun, 13 Jan 2013 13:32:02 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 386A5359315; Sun, 13 Jan 2013 14:32:00 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 197C72848C; Sun, 13 Jan 2013 14:32:00 +0100 (CET) Date: Sun, 13 Jan 2013 14:32:00 +0100 From: Jilles Tjoelker To: Konstantin Belousov , davidxu@freebsd.org Subject: Re: Fast sigblock (AKA rtld speedup) Message-ID: <20130113133159.GA72462@stack.nl> References: <20130107182235.GA65279@kib.kiev.ua> <20130111095459.GZ2561@kib.kiev.ua> <50EFE830.3030500@freebsd.org> <20130111204938.GD2561@kib.kiev.ua> <20130111232906.GA29017@stack.nl> <20130112053147.GH2561@kib.kiev.ua> <20130112162547.GA54954@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130112162547.GA54954@stack.nl> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: arch@freebsd.org, toolchain@freebsd.org X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jan 2013 13:32:02 -0000 On Sat, Jan 12, 2013 at 05:25:47PM +0100, Jilles Tjoelker wrote: > This suggests a different rather simpler change. Libthr can always use > its rtld lock implementation instead of only when multiple threads > exist. This avoids the sigprocmask() syscalls and should not be much > slower than the default implementation in rtld because that also > contains atomic operations (both the unpatched and the patched version). > People that care about performance of exceptions can then link in libthr > (in many cases, it is already linked in to allow for (the possibility > of) threading). > I have tested this and exceptions were indeed more than twice as fast in > my test program if I created an extra thread doing nothing than in the > fully single-threaded version (with or without libthr). Here is a patch. It is lightly tested. The function _thr_rtld_fini() can be removed afterwards because it is no longer used. Index: lib/libthr/thread/thr_init.c =================================================================== --- lib/libthr/thread/thr_init.c (revision 244639) +++ lib/libthr/thread/thr_init.c (working copy) @@ -363,6 +363,7 @@ _thr_signal_init(); if (_thread_event_mask & TD_CREATE) _thr_report_creation(curthread, curthread); + _thr_rtld_init(); } } Index: lib/libthr/thread/thr_kern.c =================================================================== --- lib/libthr/thread/thr_kern.c (revision 244639) +++ lib/libthr/thread/thr_kern.c (working copy) @@ -57,11 +57,6 @@ return (0); __isthreaded = threaded; - if (threaded != 0) { - _thr_rtld_init(); - } else { - _thr_rtld_fini(); - } return (0); } -- Jilles Tjoelker