Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FSCmT-0005jQ-Ep for qemu-devel@nongnu.org; Sat, 08 Apr 2006 08:43:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FSCmS-0005gw-Il for qemu-devel@nongnu.org; Sat, 08 Apr 2006 08:43:08 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FSCmS-0005ga-Dy for qemu-devel@nongnu.org; Sat, 08 Apr 2006 08:43:08 -0400 Received: from [212.27.42.29] (helo=smtp3-g19.free.fr) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FSCqd-0000sg-Ul for qemu-devel@nongnu.org; Sat, 08 Apr 2006 08:47:28 -0400 Received: from mandriva.com (ivr94-5-82-237-225-33.fbx.proxad.net [82.237.225.33]) by smtp3-g19.free.fr (Postfix) with ESMTP id B02AE48141 for ; Sat, 8 Apr 2006 14:43:06 +0200 (CEST) Date: Sat, 8 Apr 2006 14:43:07 +0200 Subject: Re: [Qemu-devel] Translation cache sizes Content-Type: text/plain; charset=ISO-8859-1; format=flowed Mime-Version: 1.0 (Apple Message framework v553) From: Gwenole Beauchesne Content-Transfer-Encoding: quoted-printable In-Reply-To: <200604080413.52908.jseward@acm.org> Message-Id: <3ACA6D63-C6FD-11DA-9D2F-003065C7D858@mandriva.com> 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 Hi, > With those changes in place, the same boot-to-kdm process > requires only about 570000 translations to be made, and 2 > cache flushes to happen. Of course the cost is an extra > 48M of memory use. I faced a similar problem in Basilisk II. MacOS 8.x had a tendency to=20 invalidate the code cache approx. 1000 times per second. My poor=20 K6-2/300 was suffering a lot. About 45% of the time was dedicated to=20 compilation of code, and desktop experience was very sluggish. Then, I=20= came up with a very simple idea I named "lazy cache flush". Performance=20= increased by 76% and compilation time dropped below 10%, desktop=20 experience was very smooth. I will give you more contemporary results=20 hereunder. So what's lazy invalidation of the translation cache? Well, the goal is=20= simple: keep translated code as long as possible. In practise, you=20 invalidate the complete translation cache only when it is full. Other=20 explicit cache invalidation (CINV instructions on 68k, icbi on ppc,=20 etc.) is virtual. This means the code is kept but it is put in a=20 "dormant" state. That is, usual entry points (in the hash table, or=20 inter-block jumps) are redirected to a check/recovery code where the=20 source block is checksumed again. If it matches original's the=20 previously compiled code is brought back to life (restoration of entry=20= points in hash table, and inter-block links). Otherwise, it's=20 recompiled and new code is used. It's very simple and quite efficient. Since, I had no need to increase=20= the translation cache beyond 8MB. So, here are a few results on an Athlon64 3200+. Translation cache is=20 set to 8MB. The test consisted in booting to MacOS 8, running all=20 Speedometer 4 tests, then shuting down the virtual Mac. * Without lazy flush: Number of soft flushes: 0 Number of hard flushes: 101387 Number of checksums : 0 Number of calls to compile_block : 20244047 Total emulation time : 115,8 sec Total compilation time : 59,4 sec (51,3%) * With lazy flush: Number of soft flushes: 405520 Number of hard flushes: 7 Number of checksums : 46545721 Number of calls to compile_block : 340104 Total emulation time : 66,1 sec Total compilation time : 1,8 sec (2,8%) The results speak by themselves. ;-) Speedometer 4 "Performance Rating" increased by 12%. More=20 interestingly, Color QuickDraw tests improved by a 12x factor: scored=20 19.95 on average with lazy cache flush, 1.67 without. Bye, Gwenol=E9.=