[openbeosnetteam] Pools implementation

  • From: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
  • To: "OpenBeOS Net-Team" <openbeosnetteam@xxxxxxxxxxxxx>
  • Date: Wed, 20 Feb 2002 17:52:59 CET (+0100)

Hi,

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

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.

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%)

Unfortunately, I don't have the "scores" of the old implementation, but 
it should be significantly faster with a block size of 256 bytes (for 
pool_get(); pool_put() is much slower due to the semaphore locking).
 
Adios...
   Axel.



Other related posts: