hot path optimizations in uma_zalloc() & uma_zfree()

Andriy Tkachuk andrit at ukr.net
Fri Jul 1 21:02:07 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.

Probaly this is the reason of throughput increasing.
I want to note, that all tests where made on my home workstation.
And each new test was made with new kernel just after rebooting
in ttyv withoud X-server.
I think the noise was not assential.

Ministats against second & third optimization showed this results:
(for different number of sockets created & destroyed in one iteration)

> /usr/src/tools/tools/ministat/ministat -c 99.5 sockloop_stat2_o1_sys_1000 sockloop_stat2_o2_sys_1000
x sockloop_stat2_o1_sys_1000
+ sockloop_stat2_o2_sys_1000
+--------------------------------------------------------------------------+
|+              +             +                      x     x              x|
||______________A_____________|                    |_______M__A__________| |
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3         2.373         2.403         2.381     2.3856667   0.015534907
+   3         2.298          2.34          2.32     2.3193333   0.021007935
No difference proven at 99.5% confidence
> /usr/src/tools/tools/ministat/ministat -c 99.5 sockloop_stat2_o1_sys_100 sockloop_stat2_o2_sys_100
x sockloop_stat2_o1_sys_100
+ sockloop_stat2_o2_sys_100
+--------------------------------------------------------------------------+
|+                       +             +                   x        x    x |
| |___________________A__M_______________|                 |_______AM_____||
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3         2.158         2.182         2.174     2.1713333   0.012220202
+   3         2.062         2.126         2.102     2.0966667   0.032331615
No difference proven at 99.5% confidence
> /usr/src/tools/tools/ministat/ministat -c 99.5 sockloop_stat2_o1_sys_10 sockloop_stat2_o2_sys_10
x sockloop_stat2_o1_sys_10
+ sockloop_stat2_o2_sys_10
+--------------------------------------------------------------------------+
|  +                                                                       |
|  +      +                                             x             xx   |
||_M_A____|                                              |________A___M___||
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3         1.754         1.777         1.776         1.769         0.013
+   3         1.672         1.684         1.673     1.6763333  0.0066583281
Difference at 99.5% confidence
        -0.0926667 +/- 0.060488
        -5.23836% +/- 3.41934%
        (Student's t, pooled s = 0.010328)
> /usr/src/tools/tools/ministat/ministat -c 99.5 sockloop_stat2_o1_sys_1 sockloop_stat2_o2_sys_1
x sockloop_stat2_o1_sys_1
+ sockloop_stat2_o2_sys_1
+--------------------------------------------------------------------------+
|+         +      +                                        x   x          x|
||________AM_______|                                      |____M_A_______| |
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3         1.938         1.993         1.953     1.9613333   0.028431204
+   3         1.722         1.785         1.759     1.7553333   0.031659648
Difference at 99.5% confidence
        -0.206 +/- 0.176222
        -10.5031% +/- 8.98479%
        (Student's t, pooled s = 0.0300888)





and for default confidence (95%) this results:

> /usr/src/tools/tools/ministat/ministat sockloop_stat2_o1_sys_1000 sockloop_stat2_o2_sys_1000
x sockloop_stat2_o1_sys_1000
+ sockloop_stat2_o2_sys_1000
+--------------------------------------------------------------------------+
|+              +             +                      x     x              x|
||______________A_____________|                    |_______M__A__________| |
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3         2.373         2.403         2.381     2.3856667   0.015534907
+   3         2.298          2.34          2.32     2.3193333   0.021007935
Difference at 95.0% confidence
        -0.0663333 +/- 0.0418758
        -2.78049% +/- 1.75531%
        (Student's t, pooled s = 0.0184752)
> /usr/src/tools/tools/ministat/ministat sockloop_stat2_o1_sys_100 sockloop_stat2_o2_sys_100
x sockloop_stat2_o1_sys_100
+ sockloop_stat2_o2_sys_100
+--------------------------------------------------------------------------+
|+                       +             +                   x        x    x |
| |___________________A__M_______________|                 |_______AM_____||
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3         2.158         2.182         2.174     2.1713333   0.012220202
+   3         2.062         2.126         2.102     2.0966667   0.032331615
Difference at 95.0% confidence
        -0.0746667 +/- 0.0553965
        -3.43875% +/- 2.55127%
        (Student's t, pooled s = 0.0244404)



Resume: the difference is present and it is more for smaller
deviations in balanced allocs & frees. It is up to 10% if deviation is minimal.


--
 Andriy Tkachuk.







More information about the freebsd-hackers mailing list