Received: from [140.186.70.92] (port=54662 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKs92-0000hb-N1 for qemu-devel@nongnu.org; Tue, 23 Nov 2010 07:40:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PKs8N-0003ns-Un for qemu-devel@nongnu.org; Tue, 23 Nov 2010 07:38:48 -0500 Received: from afflict.kos.to ([92.243.29.197]:60552) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PKs8N-0003nC-Q0 for qemu-devel@nongnu.org; Tue, 23 Nov 2010 07:38:07 -0500 Date: Tue, 23 Nov 2010 14:38:04 +0200 From: Riku Voipio Subject: Re: [Qemu-devel] [PATCH, RFT] Speedup 'tb_find_slow' by using the same heuristic as during memory page lookup Message-ID: <20101123123804.GA18003@afflict.kos.to> References: <4CEAC792.7040307@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4CEAC792.7040307@ispras.ru> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kirill Batuzov Cc: qemu-devel@nongnu.org Hi, tested and improves indeed startup speed. On Mon, Nov 22, 2010 at 10:42:10PM +0300, Kirill Batuzov wrote: > Move the last found TB to the head of the list so it will be found more > quickly next time it will be looked for. > > Signed-off-by: Kirill Batuzov > Signed-off-by: Pavel Yushchenko > --- > Hello. This patch gives significant boost to a used by us rather rich > (for embedded one - featuring X-server, many daemons and applications) > ARM-based system literally decreasing its boot to desktop time by TWO > times! (Average number of traversed 'tb_phys_hash' entries in the main > loop of the 'tb_find_slow' function reduced from 20 to 1.5.) We were > able to shorten boot to login time by about 25% as well using Debian on > versatilepb (no X-server, only basic system). Seems like kernel booting > time is not affected. No problems were encountered during our > experiments. > > We are looking forward for comments about this change and help with > testing. Thanks in advance! > > cpu-exec.c | 5 +++++ > 1 files changed, 5 insertions(+), 0 deletions(-) > > diff --git a/cpu-exec.c b/cpu-exec.c > index 5d6dd51..55c4526 100644 > --- a/cpu-exec.c > +++ b/cpu-exec.c > @@ -161,6 +161,11 @@ static TranslationBlock *tb_find_slow(target_ulong pc, > tb = tb_gen_code(env, pc, cs_base, flags, 0); > > found: > + if (*ptb1) { > + *ptb1 = tb->phys_hash_next; > + tb->phys_hash_next = tb_phys_hash[h]; > + tb_phys_hash[h] = tb; > + } > /* we add the TB in the virtual pc hash table */ > env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb; > return tb;