* The low resource handler now empties the cache depot's magazines; before,

they were never freed unless the cache was destroyed (I just wondered why
  my system would bury >1G in the magazines).
* Made the magazine capacity variable per cache, ie. for larger objects, it's
  not a good idea to have 64*CPU buffers lying around in the worst case.
* Furthermore, the create_object_cache_etc()/object_depot_init() now have
  arguments for the magazine capacity as well as the maximum number of full
  unused magazines.
* By default, you might want to initialize both to zero, as then some hopefully
  usable defaults are computed. Otherwise (the only current example is the
  vm_page_mapping cache) you can just put in the values you'd want there.
  The page mapping cache uses larger values, as its objects are usually
  allocated and deleted in larger chunks.
* Beware, though, I couldn't test these changes yet as Qemu didn't like to run
  today. I'll test these changes on another machine now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35601 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-02-24 14:43:20 +00:00
parent e7f640f25f
commit ff59ce680d
13 changed files with 112 additions and 59 deletions
+7 -2
View File
@@ -1,4 +1,5 @@
/*
* Copyright 2010, Axel Dörfler. All Rights Reserved.
* Copyright 2007, Hugo Santos. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
@@ -19,9 +20,11 @@ typedef struct object_depot {
DepotMagazine* empty;
size_t full_count;
size_t empty_count;
size_t max_count;
size_t magazine_capacity;
struct depot_cpu_store* stores;
void* cookie;
void* cookie;
void (*return_object)(struct object_depot* depot, void* cookie,
void* object, uint32 flags);
} object_depot;
@@ -31,7 +34,8 @@ typedef struct object_depot {
extern "C" {
#endif
status_t object_depot_init(object_depot* depot, uint32 flags, void* cookie,
status_t object_depot_init(object_depot* depot, size_t capacity,
size_t maxCount, uint32 flags, void* cookie,
void (*returnObject)(object_depot* depot, void* cookie, void* object,
uint32 flags));
void object_depot_destroy(object_depot* depot, uint32 flags);
@@ -45,4 +49,5 @@ void object_depot_make_empty(object_depot* depot, uint32 flags);
}
#endif
#endif /* _SLAB_OBJECT_DEPOT_H_ */
+6 -5
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2008, Axel Dörfler. All Rights Reserved.
* Copyright 2008-2010, Axel Dörfler. All Rights Reserved.
* Copyright 2007, Hugo Santos. All Rights Reserved.
*
* Distributed under the terms of the MIT License.
@@ -42,11 +42,12 @@ typedef void (*object_cache_reclaimer)(void* cookie, int32 level);
extern "C" {
#endif
object_cache* create_object_cache(const char* name, size_t object_size,
object_cache* create_object_cache(const char* name, size_t objectSize,
size_t alignment, void* cookie, object_cache_constructor constructor,
object_cache_destructor);
object_cache* create_object_cache_etc(const char* name, size_t object_size,
size_t alignment, size_t max_byte_usage, uint32 flags, void* cookie,
object_cache_destructor destructor);
object_cache* create_object_cache_etc(const char* name, size_t objectSize,
size_t alignment, size_t maxByteUsage, size_t magazineCapacity,
size_t maxMagazineCount, uint32 flags, void* cookie,
object_cache_constructor constructor, object_cache_destructor destructor,
object_cache_reclaimer reclaimer);