On Wed, Jun 14, 2017 at 12:48:17 -0700, Richard Henderson wrote: > --- a/tcg-runtime.c > +++ b/tcg-runtime.c (snip) > tb = tb_htable_lookup(cpu, addr, cs_base, flags); > - if (likely(tb)) { > - atomic_set(&cpu->tb_jmp_cache[tb_jmp_cache_hash_func(addr)], tb); > - goto found; > + if (!tb) { > + return ret;
While booting debian-arm I'm measuring (see below) a hit rate in the high 90's for the htable lookups here, so adding an 'unlikely()' hint would be a good idea. [ I'm using the patch currently in your tcg-next branch, i.e. 0a2adf4e2 ] E. The below prints during bootup+shutdown: hit rate: 94.599500% hit rate: 95.794100% hit rate: 96.617900% hit rate: 96.527275% hit rate: 96.341320% hit rate: 96.641883% diff --git a/tcg-runtime.c b/tcg-runtime.c index ec3a34e..addc3fa 100644 --- a/tcg-runtime.c +++ b/tcg-runtime.c @@ -150,6 +150,7 @@ void *HELPER(lookup_tb_ptr)(CPUArchState *env, target_ulong addr) TranslationBlock *tb; target_ulong cs_base, pc; uint32_t flags, addr_hash; + static unsigned long long accesses, found; addr_hash = tb_jmp_cache_hash_func(addr); tb = atomic_rcu_read(&cpu->tb_jmp_cache[addr_hash]); @@ -159,11 +160,16 @@ void *HELPER(lookup_tb_ptr)(CPUArchState *env, target_ulong addr) && tb->pc == addr && tb->cs_base == cs_base && tb->flags == flags))) { + accesses++; + if (!(accesses % 1000000)) { + fprintf(stderr, "hit rate: %f%%\n", (double)found * 100 / accesses); + } tb = tb_htable_lookup(cpu, addr, cs_base, flags); if (!tb) { return tcg_ctx.code_gen_epilogue; } atomic_set(&cpu->tb_jmp_cache[addr_hash], tb); + found++; } qemu_log_mask_and_addr(CPU_LOG_EXEC, addr,