summaryrefslogtreecommitdiff
path: root/lib/resource.h
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2021-11-27 00:21:12 +0100
committerMaria Matejka <mq@ucw.cz>2021-11-27 22:54:15 +0100
commitf772afc525156498900770ffe5a98349df89a45c (patch)
treefef3e68e487fb35335bdb14eb60821165b7dc066 /lib/resource.h
parent644e9ca94e2d10ba0c2de45f94523da2414328e3 (diff)
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.
Diffstat (limited to 'lib/resource.h')
-rw-r--r--lib/resource.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/resource.h b/lib/resource.h
index 76e3745f..9ec41ed8 100644
--- a/lib/resource.h
+++ b/lib/resource.h
@@ -2,6 +2,7 @@
* BIRD Resource Manager
*
* (c) 1998--1999 Martin Mares <mj@ucw.cz>
+ * (c) 2021 Maria Matejka <mq@jmq.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
@@ -11,6 +12,11 @@
#include "lib/lists.h"
+struct resmem {
+ size_t effective; /* Memory actually used for data storage */
+ size_t overhead; /* Overhead memory imposed by allocator strategies */
+};
+
/* Resource */
typedef struct resource {
@@ -26,11 +32,11 @@ struct resclass {
void (*free)(resource *); /* Freeing function */
void (*dump)(resource *); /* Dump to debug output */
resource *(*lookup)(resource *, unsigned long); /* Look up address (only for debugging) */
- size_t (*memsize)(resource *); /* Return size of memory used by the resource, may be NULL */
+ struct resmem (*memsize)(resource *); /* Return size of memory used by the resource, may be NULL */
};
/* Estimate of system allocator overhead per item, for memory consumtion stats */
-#define ALLOC_OVERHEAD 8
+#define ALLOC_OVERHEAD 16
/* Generic resource manipulation */
@@ -40,7 +46,7 @@ void resource_init(void);
pool *rp_new(pool *, const char *); /* Create new pool */
void rfree(void *); /* Free single resource */
void rdump(void *); /* Dump to debug output */
-size_t rmemsize(void *res); /* Return size of memory used by the resource */
+struct resmem rmemsize(void *res); /* Return size of memory used by the resource */
void rlookup(unsigned long); /* Look up address (only for debugging) */
void rmove(void *, pool *); /* Move to a different pool */