hot path optimizations in uma_zalloc() & uma_zfree()

Nikos Ntarmos ntarmos at
Mon Jul 4 01:09:22 GMT 2005

Hash: SHA1

Hi there.

On Sat, Jul 02, 2005 at 01:27:00PM +0300, Andriy Tkachuk wrote:
> here even more refereces to memory in your variant.

Ummm... What compiler version are you use? The pointer variant produces
faster code for me on both NetBSD/alpha (gcc 3.3.3) and Linux/x86 (gcc
3.3.5), using both -O0 and -O2 (other compiler flags also tested with
similar results). Perhaps something specific to FreeBSD then? I guess
I'll have to set up a FBSD box and have a look at it, when I catch up
with some of the other stuff in my todo list...

Anyway, the proposed optimization even makes sense if you think about it
in a logical pen-and-paper way:

array variant:
1. load address of element 0 of array to register A
2. load counter to register B
3. decrease register B
4. store back new decreased B
5. load (dereference) A[B]

This last operation may either translate to a leal-type instruction, or
to an add+load-type sequence of instructions.

pointer variant:
1. load address of pointer to register A
2. decrease register A
3. store back new decreased A
4. load (dereference) A

Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Nikos "Nikolai" Ntarmos <ntarmos at>


More information about the freebsd-hackers mailing list