From owner-freebsd-bugs@FreeBSD.ORG Wed Feb 11 21:50:03 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EE88F106567D for ; Wed, 11 Feb 2009 21:50:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id C70948FC1B for ; Wed, 11 Feb 2009 21:50:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n1BLo3Ru044466 for ; Wed, 11 Feb 2009 21:50:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n1BLo3QH044462; Wed, 11 Feb 2009 21:50:03 GMT (envelope-from gnats) Resent-Date: Wed, 11 Feb 2009 21:50:03 GMT Resent-Message-Id: <200902112150.n1BLo3QH044462@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Guillaume Morin Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9022C106566C for ; Wed, 11 Feb 2009 21:43:15 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 638118FC13 for ; Wed, 11 Feb 2009 21:43:15 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n1BLhE8j083947 for ; Wed, 11 Feb 2009 21:43:14 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n1BLhEtL083946; Wed, 11 Feb 2009 21:43:14 GMT (envelope-from nobody) Message-Id: <200902112143.n1BLhEtL083946@www.freebsd.org> Date: Wed, 11 Feb 2009 21:43:14 GMT From: Guillaume Morin To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/131597: c++ exceptions very slow on FreeBSD 7.1/amd64 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Feb 2009 21:50:06 -0000 >Number: 131597 >Category: misc >Synopsis: c++ exceptions very slow on FreeBSD 7.1/amd64 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Feb 11 21:50:03 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Guillaume Morin >Release: 7.1-RELEASE >Organization: >Environment: FreeBSD freebsd 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan 1 08:58:24 UTC 2009 root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: I have a very simple C++ program that simply throws 100,000 exceptions. Compiled on my Core 2 Duo running FreeBSD, it takes 4 secs to run. On my linux box running a 4 year old Athlon 64, it takes 0.4 secs. It looks like the FreeBSD implementation makes a *lot* of syscalls. We found this problem while running test code for our libraries which is very exception heavy. Here is the program: $cat testexcept.cpp int main(void) { int i = 0; while(1) { ++i; try { if(i == 100000) { break; } throw 0; } catch(...) { } } return 0; } $g++ -v Using built-in specs. Target: amd64-undermydesk-freebsd Configured with: FreeBSD/amd64 system compiler Thread model: posix gcc version 4.2.1 20070719 [FreeBSD] $g++ -o t testexcept.cpp $time ./t real 0m4.436s user 0m4.292s sys 0m0.144s $truss -oout ./t $wc -l out 1000072 out $grep sigprocmask out | sort | uniq -c 499999 sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0) = 0 (0x0) 499999 sigprocmask(SIG_SETMASK,0x0,0x0) = 0 (0x0) Same program on the linux box ============================= linux $g++-4.2 -v Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.2.4 (Debian 4.2.4-6) linux $g++-4.2 -m64 -o t testexcept.cpp linux $time ./t real 0m0.421s user 0m0.404s sys 0m0.000s linux $strace -oout ./t linux $wc -l out 54 out linux $ Both machines have a similar frequency (around 2Ghz) but the Core 2 Duo should be faster. Both boxes were very lightly loaded >How-To-Repeat: Compile and run the program :) >Fix: >Release-Note: >Audit-Trail: >Unformatted: