From owner-freebsd-questions@FreeBSD.ORG Fri Mar 12 03:45:02 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 00D2216A4CE for ; Fri, 12 Mar 2004 03:45:02 -0800 (PST) Received: from smtp.infracaninophile.co.uk (ns0.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8C06C43D1F for ; Fri, 12 Mar 2004 03:45:00 -0800 (PST) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost.infracaninophile.co.uk [IPv6:::1])i2CBitLZ033239 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 12 Mar 2004 11:44:55 GMT (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id i2CBiteS033238; Fri, 12 Mar 2004 11:44:55 GMT (envelope-from matthew) Date: Fri, 12 Mar 2004 11:44:55 +0000 From: Matthew Seaman To: Donald Burr Message-ID: <20040312114454.GA33032@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Donald Burr , List FreeBSD Questions References: <101C5248-740D-11D8-B665-000A95B9AE7E@borg-cube.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline In-Reply-To: <101C5248-740D-11D8-B665-000A95B9AE7E@borg-cube.com> User-Agent: Mutt/1.5.6i X-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on happy-idiot-talk.infracaninophile.co.uk X-Virus-Scanned: clamd / ClamAV version devel-20040304, clamav-milter version 0.67j cc: List FreeBSD Questions Subject: Re: How much difference does 'gcc -O' make? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Mar 2004 11:45:02 -0000 --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 12, 2004 at 02:07:26AM -0800, Donald Burr wrote: > A question occurred to me today. How much difference does 'gcc -O'=20 > make in the speed of my system? Usually the higher levels of -Ox optimisation make a lot less difference than most people expect. It depends very much on the particular code that is being compiled exactly how much difference those optimizations will make. It's also the case that sometimes the extreme optimizations will actually make the code run slower, and in other cases it will cause the compiler to emit broken results -- that's particularly true of the FreeBSD kernel, for reasons I don't profess to understand. =20 > I notice some ports that claim to not work properly if compiled with=20 > -O (the one that comes to mind right away is XFree86 4.x, but I've=20 > seen others) and I am thinking of just turning OFF -O option in my=20 > /etc/make.conf. I'm just wondering how much of an impact this will=20 > have on system performance. It always used to be said that the first rule of optimization was "don't". gcc(1) has modified that to be more like "don't use anything higher than -O1" -- which is what the default setting is on FreeBSD. "-O1" will get you the majority of the improvement in performance that you can get by optimization, pretty much without the risks of bad results. If you're looking for the best improvement in performance you can get, the sensible thing to do is set the CPUTYPE variable correctly in /etc/make.conf. This effectively gives the compiler free reign to exploit all of the capabilities of your CPU. Plus it works very effectively and without the problems of broken results that jacking up the '-Ox' level has. =20 > FYI, my box is a Via C3 @ 800MHz with 128 MB RAM, and it basically=20 > lives its life as an e-mail and Web server and gateway for my home=20 > network. (in other words it doesn't do any computing intensive stuff=20 > like sequencing DNA or searching for aliens. :) ) Quite so. Most of the processes you run will spend the vast majority of the time waiting for IO requests to be fulfilled. The most perfect optimization immaginable can't make them run any faster. Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --jRHKVT23PllUwdXP Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAUaK2dtESqEQa7a0RAru/AJ0f9xP9P0SX2nYPYIMSK+zUJNE4bwCfdKE5 360/hswaqaZ/VOy2vF6+Qt8= =0lpc -----END PGP SIGNATURE----- --jRHKVT23PllUwdXP--