[haiku-commits] Re: r35601 - in haiku/trunk: headers/private/kernel/slab src/system/kernel/cache src/system/kernel/slab src/system/kernel/vm

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 24 Feb 2010 17:27:58 +0100

On 2010-02-24 at 15:43:20 [+0100], axeld@xxxxxxxxxxxxxxxx wrote:
> Author: axeld
> Date: 2010-02-24 15:43:20 +0100 (Wed, 24 Feb 2010)
> New Revision: 35601
> Changeset: http://dev.haiku-os.org/changeset/35601/haiku
[...]
>  static bool
> -exchange_with_empty(object_depot* depot, DepotMagazine*& magazine)
> +exchange_with_empty(object_depot* depot, DepotMagazine*& magazine,
> +    DepotMagazine*& freeMagazine)
>  {
> +    ASSERT(magazine == NULL || magazine->IsFull());
> +
>      SpinLocker _(depot->inner_lock);
>  
>      if (depot->empty == NULL)
> @@ -137,9 +139,12 @@
>  
>      depot->empty_count--;
>  
> -    if (magazine) {
> -        _push(depot->full, magazine);
> -        depot->full_count++;
> +    if (magazine != NULL) {
> +        if (depot->full_count < depot->max_count) {
> +            _push(depot->full, magazine);
> +            depot->full_count++;
> +        } else
> +            freeMagazine = magazine;

A disadvantage of this implementation is that a relatively recently used 
magazine is discarded while older ones are kept, which from a caching 
perspective is definitely suboptimal. Have you by any chance tested how that 
affects performance?


> Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp
> ===================================================================
> --- haiku/trunk/src/system/kernel/slab/Slab.cpp    2010-02-24 14:10:17 UTC 
> (rev 35600)
> +++ haiku/trunk/src/system/kernel/slab/Slab.cpp    2010-02-24 14:43:20 UTC 
> (rev 35601)
> @@ -413,6 +413,11 @@
>          if (cache->reclaimer)
>              cache->reclaimer(cache->cookie, level);
>  
> +        if ((cache->flags & CACHE_NO_DEPOT) == 0) {
> +            object_depot_make_empty(&cache->depot, 0);
> +                // TODO: what flags?

The apropriate alloc/free flags. I suppose CACHE_DONT_WAIT_FOR_MEMORY could 
be specified to prevent the somewhat pathological situation that the low 
memory handler has to wait for memory (when the object depot for the 
magazines object cache wants to allocate a magazine and has to go to 
MemoryManager; or when a HashedObjectCache's hash table is resized). I guess 
it would be better to introduce a special flag CACHE_DONT_ALLOCATE for this 
case, though.

CU, Ingo

Other related posts: