On Thursday 30 June 2005 00:08, ant wrote: > I just tryed to make buckets management in perCPU cache like in > Solaris (see paper of Jeff Bonwick - Magazines and Vmem) > and got perfomance gain around 10% in my test program. > Then i made another minor code optimization and got another 10%. > The program just creates and destroys sockets in loop. > > I suppose the reason of first gain lies in increasing of cpu cache hits. > In current fbsd code allocations and freeings deal with > separate buckets. Buckets are changed when one of them > became full or empty first. In Solaris this work is pure LIFO: > i.e. alloc() and free() work with one bucket - the current bucket > (it is called magazine there), that's why cache hit rate is bigger. > > 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).
> the patch is for uma_core.c from RELENG_5, but i checked
> uma_core.c in CURRENT - it's the same regarding to thiese
> improvements. I don't have any commit rights, so the patch
> is just for reviewing. Here it is:
>
> --- sys/vm/uma_core.c.orig Wed Jun 29 21:46:52 2005
> +++ sys/vm/uma_core.c Wed Jun 29 23:09:32 2005
> @@ -1830,8 +1830,7 @@
>
> if (bucket) {
> if (bucket->ub_cnt > 0) {
> - bucket->ub_cnt--;
> - item = bucket->ub_bucket[bucket->ub_cnt];
> + item = bucket->ub_bucket[--bucket->ub_cnt];
> #ifdef INVARIANTS
> bucket->ub_bucket[bucket->ub_cnt] = NULL;
> #endif
Okay, but no effect according to my reading of the object code.
> @@ -2263,8 +2262,7 @@
> if (bucket->ub_cnt < bucket->ub_entries) {
> KASSERT(bucket->ub_bucket[bucket->ub_cnt] == NULL,
> ("uma_zfree: Freeing to non free bucket index."));
> - bucket->ub_bucket[bucket->ub_cnt] = item;
> - bucket->ub_cnt++;
> + bucket->ub_bucket[bucket->ub_cnt++] = item;
This changes semantics, as far as I understand. Might be a consequence of the
other work you are doing, but doesn't seem right from a first glance.
--
/"\ Best regards, | [EMAIL PROTECTED]
\ / Max Laier | ICQ #67774661
X http://pf4freebsd.love2party.net/ | [EMAIL PROTECTED]
/ \ ASCII Ribbon Campaign | Against HTML Mail and News
pgpJREL2u4fAT.pgp
Description: PGP signature

