plot arena memory usage

This commit is contained in:
Nikita Smith
2026-02-11 15:26:22 -08:00
parent 2a76188570
commit 56b89cc8cb
2 changed files with 30 additions and 0 deletions
+28
View File
@@ -67,6 +67,7 @@ arena_alloc_(ArenaParams *params)
arena->res = reserve_size;
arena->allocation_site_file = params->allocation_site_file;
arena->allocation_site_line = params->allocation_site_line;
arena->name = params->name;
#if ARENA_FREE_LIST
arena->free_last = 0;
#endif
@@ -76,6 +77,14 @@ arena_alloc_(ArenaParams *params)
internal void
arena_release(Arena *arena)
{
#if PROFILE_TELEMETRY
{
Arena *base_arena = arena;
while (base_arena->prev) base_arena = base_arena->prev;
tmPlot(0, TM_PLOT_UNITS_MEMORY, TM_PLOT_DRAW_LINE, 0, "%s/%p", base_arena->name, base_arena);
}
#endif
for(Arena *n = arena->current, *prev = 0; n != 0; n = prev)
{
prev = n->prev;
@@ -182,6 +191,15 @@ arena_push(Arena *arena, U64 size, U64 align, B32 zero)
}
}
#if PROFILE_TELEMETRY
if(size > KB(1))
{
Arena *base_arena = arena;
while (base_arena->prev) base_arena = base_arena->prev;
tmPlot(0, TM_PLOT_UNITS_MEMORY, TM_PLOT_DRAW_LINE, (double)(current->base_pos + current->pos) / 1024.0 / 1024.0, "%s/%p", base_arena->name, base_arena);
}
#endif
// rjf: panic on failure
#if OS_FEATURE_GRAPHICAL
if(Unlikely(result == 0))
@@ -228,6 +246,16 @@ arena_pop_to(Arena *arena, U64 pos)
AssertAlways(new_pos <= current->pos);
AsanPoisonMemoryRegion((U8*)current + new_pos, (current->pos - new_pos));
current->pos = new_pos;
#if PROFILE_TELEMETRY
if((pos - (new_pos + current->base_pos)) > KB(1))
{
Arena *base_arena = arena;
while (base_arena->prev) base_arena = base_arena->prev;
tmPlot(0, TM_PLOT_UNITS_MEMORY, TM_PLOT_DRAW_LINE, (double)(current->base_pos + current->pos) / 1024.0 / 1024.0, "%s/%p", base_arena->name, base_arena);
}
#endif
}
//- rjf: arena push/pop helpers
+2
View File
@@ -25,6 +25,7 @@ struct ArenaParams
void *optional_backing_buffer;
char *allocation_site_file;
int allocation_site_line;
char *name;
};
typedef struct Arena Arena;
@@ -41,6 +42,7 @@ struct Arena
U64 res;
char *allocation_site_file;
int allocation_site_line;
char *name;
#if ARENA_FREE_LIST
Arena *free_last;
#endif