hot path optimizations in uma_zalloc() & uma_zfree()
John Baldwin
jhb at FreeBSD.org
Thu Jun 30 17:43:20 GMT 2005
On Thursday 30 June 2005 10:35 am, Andriy Tkachuk wrote:
> I just checked the object code - you right, it almost the same:
>
> - bucket->ub_bucket[bucket->ub_cnt] = item;
> - 22b9: 0f bf 43 08 movswl 0x8(%ebx),%eax
> - 22bd: 8b 4d 0c mov 0xc(%ebp),%ecx
> - 22c0: 89 4c 83 0c mov %ecx,0xc(%ebx,%eax,4)
> - bucket->ub_cnt++;
> - 22c4: 8d 42 01 lea 0x1(%edx),%eax
> - 22c7: 66 89 43 08 mov %ax,0x8(%ebx)
> + bucket->ub_bucket[bucket->ub_cnt++] = item;
> + 22b9: 0f bf c2 movswl %dx,%eax
> + 22bc: 8b 4d 0c mov 0xc(%ebp),%ecx
> + 22bf: 89 4c 83 0c mov %ecx,0xc(%ebx,%eax,4)
> + 22c3: 8d 42 01 lea 0x1(%edx),%eax
> + 22c6: 66 89 43 08 mov %ax,0x8(%ebx)
>
> but still there is some minor difference in first line.
> I'm not familiar with assembler, can somebody explain
> whether this difference is assential or not?
It just uses the stored value of the variable in %dx instead of loading it
from memory at 0x8(%ebx). When I compiled a simple test program here locally
I got identical object code though.
> in decrementation there is no difference at all:
>
> - bucket->ub_cnt--;
> + item = bucket->ub_bucket[--bucket->ub_cnt];
> 1bbe: 66 ff 49 08 decw 0x8(%ecx)
> - item = bucket->ub_bucket[bucket->ub_cnt];
> 1bc2: 0f bf 41 08 movswl 0x8(%ecx),%eax
> 1bc6: 8b 44 81 0c mov 0xc(%ecx,%eax,4),%eax
> 1bca: 89 45 f0 mov %eax,0xfffffff0(%ebp)
>
>
> ----- Original Message -----
> From: "Max Laier" <max at love2party.net>
> To: <freebsd-hackers at freebsd.org>
> Cc: "ant" <andrit at ukr.net>
> Sent: Thursday, June 30, 2005 3:15 PM
> Subject: Re: hot path optimizations in uma_zalloc() & uma_zfree()
>
> > Another optimization is very trivial, for example:
> > - bucket->ub_cnt--;
> > - item = bucket->ub_bucket[bucket->ub_cnt];
> > + item = bucket->ub_bucket[--bucket->ub_cnt];
> > (see the patch)
>
> Might be me, but this doesn't change the generated object code at all
> (modulo the changed __line__ in debugging).
>
>
>
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
--
John Baldwin <jhb at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
More information about the freebsd-hackers
mailing list