mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 17:28:07 +00:00
plot arena memory usage
This commit is contained in:
@@ -67,6 +67,7 @@ arena_alloc_(ArenaParams *params)
|
|||||||
arena->res = reserve_size;
|
arena->res = reserve_size;
|
||||||
arena->allocation_site_file = params->allocation_site_file;
|
arena->allocation_site_file = params->allocation_site_file;
|
||||||
arena->allocation_site_line = params->allocation_site_line;
|
arena->allocation_site_line = params->allocation_site_line;
|
||||||
|
arena->name = params->name;
|
||||||
#if ARENA_FREE_LIST
|
#if ARENA_FREE_LIST
|
||||||
arena->free_last = 0;
|
arena->free_last = 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -76,6 +77,14 @@ arena_alloc_(ArenaParams *params)
|
|||||||
internal void
|
internal void
|
||||||
arena_release(Arena *arena)
|
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)
|
for(Arena *n = arena->current, *prev = 0; n != 0; n = prev)
|
||||||
{
|
{
|
||||||
prev = 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
|
// rjf: panic on failure
|
||||||
#if OS_FEATURE_GRAPHICAL
|
#if OS_FEATURE_GRAPHICAL
|
||||||
if(Unlikely(result == 0))
|
if(Unlikely(result == 0))
|
||||||
@@ -228,6 +246,16 @@ arena_pop_to(Arena *arena, U64 pos)
|
|||||||
AssertAlways(new_pos <= current->pos);
|
AssertAlways(new_pos <= current->pos);
|
||||||
AsanPoisonMemoryRegion((U8*)current + new_pos, (current->pos - new_pos));
|
AsanPoisonMemoryRegion((U8*)current + new_pos, (current->pos - 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
|
//- rjf: arena push/pop helpers
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ struct ArenaParams
|
|||||||
void *optional_backing_buffer;
|
void *optional_backing_buffer;
|
||||||
char *allocation_site_file;
|
char *allocation_site_file;
|
||||||
int allocation_site_line;
|
int allocation_site_line;
|
||||||
|
char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Arena Arena;
|
typedef struct Arena Arena;
|
||||||
@@ -41,6 +42,7 @@ struct Arena
|
|||||||
U64 res;
|
U64 res;
|
||||||
char *allocation_site_file;
|
char *allocation_site_file;
|
||||||
int allocation_site_line;
|
int allocation_site_line;
|
||||||
|
char *name;
|
||||||
#if ARENA_FREE_LIST
|
#if ARENA_FREE_LIST
|
||||||
Arena *free_last;
|
Arena *free_last;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user