mirror of
https://gitlab.labs.nic.cz/labs/bird.git
synced 2024-05-11 16:54:54 +00:00
Memory statistics split into Effective and Overhead
This feature is intended mostly for checking that BIRD's allocation strategies don't consume much memory space. There are some cases where withdrawing routes in a specific order lead to memory fragmentation and this output should give the user at least a notion of how much memory is actually used for data storage and how much memory is "just allocated" or used for overhead. Also raising the "system allocator overhead estimation" from 8 to 16 bytes; it is probably even more. I've found 16 as a local minimum in best scenarios among reachable machines. I couldn't find any reasonable method to estimate this value when BIRD starts up. This commit also fixes the inaccurate computation of memory overhead for slabs where the "system allocater overhead estimation" was improperly added to the size of mmap-ed memory.
This commit is contained in:
@@ -45,7 +45,7 @@ struct linpool {
|
||||
static void lp_free(resource *);
|
||||
static void lp_dump(resource *);
|
||||
static resource *lp_lookup(resource *, unsigned long);
|
||||
static size_t lp_memsize(resource *r);
|
||||
static struct resmem lp_memsize(resource *r);
|
||||
|
||||
static struct resclass lp_class = {
|
||||
"LinPool",
|
||||
@@ -287,7 +287,7 @@ lp_dump(resource *r)
|
||||
m->total_large);
|
||||
}
|
||||
|
||||
static size_t
|
||||
static struct resmem
|
||||
lp_memsize(resource *r)
|
||||
{
|
||||
linpool *m = (linpool *) r;
|
||||
@@ -299,9 +299,11 @@ lp_memsize(resource *r)
|
||||
for(c=m->first_large; c; c=c->next)
|
||||
cnt++;
|
||||
|
||||
return ALLOC_OVERHEAD + sizeof(struct linpool) +
|
||||
cnt * (ALLOC_OVERHEAD + sizeof(struct lp_chunk)) +
|
||||
m->total + m->total_large;
|
||||
return (struct resmem) {
|
||||
.effective = m->total + m->total_large,
|
||||
.overhead = ALLOC_OVERHEAD + sizeof(struct linpool) +
|
||||
cnt * (ALLOC_OVERHEAD + sizeof(struct lp_chunk)),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user