[openbeosnetteam] Re: Pools implementation

> Hi,
>
> I've updated pools.c and the its testing procedure.

I saw :)

>
> There were many bugs, especially memory leaks.
> Furthermore, some access to the pool_cnt was not locked - I've
> introduced benaphores and read/write lock macros (in include/lock.h)
> which should speed up locking of the pool_mem blocks, and secure access
> to the pool_cnt structure.

/me bows his head... Thanks for checking that!

>
> For now, I took a read/write lock to protect accessing the pool_cnt
> structure - depending on how much concurrent access we will have for a
> single pool, it would be significantly faster to switch to benaphores.
> Especially pool_put() is much slower with read/write locks.
>
> Anyway, here are the test results:
>
> For a block size of 256 bytes:
>   For 50 loops malloc()/free() took 123043
>         malloc() took 106755
>         free() took 16288
>   For 50 loops pool_get()/pool_put() took 487806 (396%)
>         pool_get() took 322344 (301%)
>         pool_put() took 165462 (1015%)
>
> And for a block size of 2048 bytes:
>   For 50 loops malloc()/free() took 842836
>         malloc() took 785816
>         free() took 57020
>   For 50 loops pool_get()/pool_put() took 525862 (62%)
>         pool_get() took 344167 (43%)
>         pool_put() took 181695 (318%)

Well, just running it here's what I get...

For 50 loops malloc()/free() took 3183232
        malloc() took 3009073
        free() took 174159
For 50 loops pool_get()/pool_put() took 1400692 (44%)
        pool_get() took 902635 (29%)
        pool_put() took 498057 (285%)


These look good for me!

On a side note, this is interesting. Output is from an OpenBSD box pinging
across a 100M network. BeOS machine is PII 350 and BONE machine is P3 750...

bash-2.05$ ping 192.168.0.133
PING 192.168.0.133 (192.168.0.133): 56 data bytes
64 bytes from 192.168.0.133: icmp_seq=0 ttl=255 time=0.780 ms
64 bytes from 192.168.0.133: icmp_seq=1 ttl=255 time=0.316 ms
64 bytes from 192.168.0.133: icmp_seq=2 ttl=255 time=0.346 ms
64 bytes from 192.168.0.133: icmp_seq=3 ttl=255 time=0.327 ms
64 bytes from 192.168.0.133: icmp_seq=4 ttl=255 time=0.321 ms
64 bytes from 192.168.0.133: icmp_seq=5 ttl=255 time=0.308 ms
64 bytes from 192.168.0.133: icmp_seq=6 ttl=255 time=0.318 ms
64 bytes from 192.168.0.133: icmp_seq=7 ttl=255 time=0.316 ms
64 bytes from 192.168.0.133: icmp_seq=8 ttl=255 time=0.324 ms

PING 192.168.0.116 (192.168.0.116): 56 data bytes
64 bytes from 192.168.0.116: icmp_seq=0 ttl=255 time=1.294 ms
64 bytes from 192.168.0.116: icmp_seq=1 ttl=255 time=1.311 ms
64 bytes from 192.168.0.116: icmp_seq=2 ttl=255 time=0.630 ms
64 bytes from 192.168.0.116: icmp_seq=3 ttl=255 time=2.658 ms
64 bytes from 192.168.0.116: icmp_seq=4 ttl=255 time=0.922 ms
64 bytes from 192.168.0.116: icmp_seq=5 ttl=255 time=2.287 ms
64 bytes from 192.168.0.116: icmp_seq=6 ttl=255 time=0.511 ms

Guess which one is our stack and which is BONE? Not what I would have
expected at all really...

david



Other related posts: