[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 10/10] tb-hash: improve tb_jmp_cache hash functi
From: |
Emilio G. Cota |
Subject: |
Re: [Qemu-devel] [PATCH 10/10] tb-hash: improve tb_jmp_cache hash function in user mode |
Date: |
Wed, 12 Apr 2017 01:07:32 -0400 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Wed, Apr 12, 2017 at 11:46:47 +0800, Paolo Bonzini wrote:
>
>
> On 12/04/2017 09:17, Emilio G. Cota wrote:
> > +
> > +/* In user-mode we can get better hashing because we do not have a TLB */
> > +static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc)
> > +{
> > + return (pc ^ (pc >> TB_JMP_CACHE_BITS)) & (TB_JMP_CACHE_SIZE - 1);
> > +}
>
> What about multiplicative hashing?
>
> return (uint64_t) (pc * 2654435761) >> 32;
I tested this one, taking the TB_JMP_CACHE_SIZE-1 lower bits of
the result:
http://imgur.com/QIhm875
In terms of quality it's good (I profile hit rates and they're all
pretty good), but shift+xor are just so hard to beat: shift+xor
take 1 cycle each; the multiplication takes on my machine 3 or 4
cycles (source: Fog's tables).
Thanks,
E.
- [Qemu-devel] [PATCH 07/10] tcg: add tcg_temp_local_new_ptr, (continued)
- [Qemu-devel] [PATCH 07/10] tcg: add tcg_temp_local_new_ptr, Emilio G. Cota, 2017/04/11
- [Qemu-devel] [PATCH 01/10] exec-all: add tb_from_jmp_cache, Emilio G. Cota, 2017/04/11
- [Qemu-devel] [PATCH 02/10] exec-all: inline tb_from_jmp_cache, Emilio G. Cota, 2017/04/11
- [Qemu-devel] [PATCH 06/10] tcg: add brcondi_ptr, Emilio G. Cota, 2017/04/11
- [Qemu-devel] [PATCH 03/10] target/arm: optimize cross-page block chaining in softmmu, Emilio G. Cota, 2017/04/11
- [Qemu-devel] [PATCH 04/10] target/i386: optimize cross-page block chaining in softmmu, Emilio G. Cota, 2017/04/11
- [Qemu-devel] [PATCH 05/10] tcg: add jr opcode, Emilio G. Cota, 2017/04/11
- [Qemu-devel] [PATCH 10/10] tb-hash: improve tb_jmp_cache hash function in user mode, Emilio G. Cota, 2017/04/11
- [Qemu-devel] [PATCH 08/10] target/arm: optimize indirect branches with TCG's jr op, Emilio G. Cota, 2017/04/11
- [Qemu-devel] [PATCH 09/10] target/i386: optimize indirect branches with TCG's jr op, Emilio G. Cota, 2017/04/11
- Re: [Qemu-devel] [PATCH 00/10] TCG optimizations for 2.10, Alex Bennée, 2017/04/12