From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1E7v6Z-0007x1-Le for qemu-devel@nongnu.org; Wed, 24 Aug 2005 09:15:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1E7v6X-0007v4-2O for qemu-devel@nongnu.org; Wed, 24 Aug 2005 09:15:47 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E7v3T-0005hz-VI for qemu-devel@nongnu.org; Wed, 24 Aug 2005 09:12:36 -0400 Received: from [64.233.184.193] (helo=wproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1E7un3-0003G8-N2 for qemu-devel@nongnu.org; Wed, 24 Aug 2005 08:55:37 -0400 Received: by wproxy.gmail.com with SMTP id i21so82602wra for ; Wed, 24 Aug 2005 05:54:27 -0700 (PDT) Message-ID: <23bcb8700508240554653c7ff0@mail.gmail.com> Date: Wed, 24 Aug 2005 08:54:27 -0400 From: Doctor Bill Subject: Re: [Qemu-devel] [PATCH] const / static (against current CVS) In-Reply-To: <20050823174026.GA27203@rhlx01.fht-esslingen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20050823174026.GA27203@rhlx01.fht-esslingen.de> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org My own experience is the effect of these types of optimizations is usually negligible, although it is still the first thing I do when optimizing a program. The main improvement I find is reducing the time required to initialize variables and improved code readability.=20 If you know values are constant, you do not need to reference how there values are changing in a debugger... Probably more important is to make sure none constant data structures are done on the stack. There is no good reason why any code page should be read-write. Bill On 8/23/05, Andreas Mohr wrote: > Hello all, >=20 > Introduction part: > ---------- > I'm doing a performance tuning effort all over the place in > frequently-used Linux programs: > I'm trying to mark as many data areas as possible const (and static) > in various programs (at those places where it's actually feasible, > that is). >=20 > This should have the following benefits: > a) more .rodata (read-only) pages in programs, which means that > pages (since they're read-only and can thus be restored from the binary a= ny > time) can simply be discarded instead of having to be paged out when > free memory is getting low > b) more page sharing between program instances due to less > modified / read-write (and thus unique instance *per-program*!) memory pa= ges > c) various const compiler optimizations kicking in > d) less linker work to be done (static) > e) we detect previously silent memory corruption (random data area trashi= ng) > better >=20 > (use "objdump -x" to analyze what can be improved) >=20 > In smaller programs marking variables as const won't be enough to get > several whole pages (4K size) back to read-only, but it goes into the > right direction after all, since we don't intend to actually increase > the number of read-write pages... > ---------- >=20 > This patch against current CVS adds const and/or static to numerous struc= ts > that obviously could be made so. It compiles without any warnings, > and qemu even still runs! ;-) >=20 > Patch had been posted to "Patches Repository" on User Forum about a month > ago, but of course that wasn't enough... (silly me) >=20 > Thank you, >=20 > Andreas Mohr > (patch attached) >=20 > -- > GNU/Linux. It's not the software that's free, it's you. >=20 >=20 > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel >=20 >=20 >=20 >