1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-12 06:41:13 +02:00

Add a statistic for tracking how many cells are marked conservatively.

This allows an informed choice for deciding how many segments to
create.  After startup, ~2% of the cells are scanned conservatively.
This commit is contained in:
Han-Wen Nienhuys 2008-08-16 15:03:48 -03:00
parent 82ae1b8eb3
commit 40945e5e9f
5 changed files with 12 additions and 3 deletions

View file

@ -78,7 +78,7 @@ scm_mark_all (void)
scm_i_init_guardians_for_gc (); scm_i_init_guardians_for_gc ();
scm_i_clear_mark_space (); scm_i_clear_mark_space ();
scm_i_find_heap_calls = 0;
/* Mark every thread's stack and registers */ /* Mark every thread's stack and registers */
scm_threads_mark_stacks (); scm_threads_mark_stacks ();
@ -404,7 +404,7 @@ scm_gc_mark_dependencies (SCM p)
{ {
/* We are in debug mode. Check the ptr exhaustively. */ /* We are in debug mode. Check the ptr exhaustively. */
valid_cell = valid_cell && (scm_i_find_heap_segment_containing_object (ptr) >= 0); valid_cell = valid_cell && scm_in_heap_p (ptr);
} }
#endif #endif

View file

@ -115,12 +115,14 @@ scm_i_insert_segment (scm_t_heap_segment *seg)
I think this function is too long to be inlined. --hwn I think this function is too long to be inlined. --hwn
*/ */
int int
scm_i_find_heap_segment_containing_object (SCM obj) scm_i_find_heap_segment_containing_object (SCM obj)
{ {
if (!CELL_P (obj)) if (!CELL_P (obj))
return -1; return -1;
scm_i_find_heap_calls ++;
if ((scm_t_cell *) obj < lowest_cell || (scm_t_cell *) obj >= highest_cell) if ((scm_t_cell *) obj < lowest_cell || (scm_t_cell *) obj >= highest_cell)
return -1; return -1;

View file

@ -44,6 +44,7 @@ scm_i_get_new_heap_segment (scm_t_cell_type_statistics *freelist,
if (len < SCM_MIN_HEAP_SEG_SIZE) if (len < SCM_MIN_HEAP_SEG_SIZE)
len = SCM_MIN_HEAP_SEG_SIZE; len = SCM_MIN_HEAP_SEG_SIZE;
/* todo: consider having a more flexible lower bound. */
{ {
scm_t_heap_segment *seg = scm_i_make_empty_heap_segment (freelist); scm_t_heap_segment *seg = scm_i_make_empty_heap_segment (freelist);

View file

@ -210,7 +210,7 @@ unsigned long scm_mtrigger;
unsigned long scm_cells_allocated = 0; unsigned long scm_cells_allocated = 0;
unsigned long scm_last_cells_allocated = 0; unsigned long scm_last_cells_allocated = 0;
unsigned long scm_mallocated = 0; unsigned long scm_mallocated = 0;
long int scm_i_find_heap_calls = 0;
/* Global GC sweep statistics since the last full GC. */ /* Global GC sweep statistics since the last full GC. */
scm_t_sweep_statistics scm_i_gc_sweep_stats = { 0, 0 }; scm_t_sweep_statistics scm_i_gc_sweep_stats = { 0, 0 };
@ -241,6 +241,7 @@ SCM_SYMBOL (sym_gc_time_taken, "gc-time-taken");
SCM_SYMBOL (sym_gc_mark_time_taken, "gc-mark-time-taken"); SCM_SYMBOL (sym_gc_mark_time_taken, "gc-mark-time-taken");
SCM_SYMBOL (sym_times, "gc-times"); SCM_SYMBOL (sym_times, "gc-times");
SCM_SYMBOL (sym_cells_marked, "cells-marked"); SCM_SYMBOL (sym_cells_marked, "cells-marked");
SCM_SYMBOL (sym_cells_marked_conservatively, "cells-marked-conservatively");
SCM_SYMBOL (sym_cells_swept, "cells-swept"); SCM_SYMBOL (sym_cells_swept, "cells-swept");
SCM_SYMBOL (sym_malloc_yield, "malloc-yield"); SCM_SYMBOL (sym_malloc_yield, "malloc-yield");
SCM_SYMBOL (sym_cell_yield, "cell-yield"); SCM_SYMBOL (sym_cell_yield, "cell-yield");
@ -314,6 +315,7 @@ SCM_DEFINE (scm_gc_stats, "gc-stats", 0, 0, 0,
unsigned long int local_scm_gc_times; unsigned long int local_scm_gc_times;
unsigned long int local_scm_gc_mark_time_taken; unsigned long int local_scm_gc_mark_time_taken;
unsigned long int local_protected_obj_count; unsigned long int local_protected_obj_count;
unsigned long int local_conservative_scan_count;
double local_scm_gc_cells_swept; double local_scm_gc_cells_swept;
double local_scm_gc_cells_marked; double local_scm_gc_cells_marked;
double local_scm_total_cells_allocated; double local_scm_total_cells_allocated;
@ -327,6 +329,7 @@ SCM_DEFINE (scm_gc_stats, "gc-stats", 0, 0, 0,
/* Below, we cons to produce the resulting list. We want a snapshot of /* Below, we cons to produce the resulting list. We want a snapshot of
* the heap situation before consing. * the heap situation before consing.
*/ */
local_conservative_scan_count = scm_i_find_heap_calls;
local_scm_mtrigger = scm_mtrigger; local_scm_mtrigger = scm_mtrigger;
local_scm_mallocated = scm_mallocated; local_scm_mallocated = scm_mallocated;
local_scm_heap_size = local_scm_heap_size =
@ -369,6 +372,8 @@ SCM_DEFINE (scm_gc_stats, "gc-stats", 0, 0, 0,
scm_from_double (local_scm_total_cells_allocated)), scm_from_double (local_scm_total_cells_allocated)),
scm_cons (sym_heap_size, scm_cons (sym_heap_size,
scm_from_ulong (local_scm_heap_size)), scm_from_ulong (local_scm_heap_size)),
scm_cons (sym_cells_marked_conservatively,
scm_from_ulong (local_conservative_scan_count)),
scm_cons (sym_mallocated, scm_cons (sym_mallocated,
scm_from_ulong (local_scm_mallocated)), scm_from_ulong (local_scm_mallocated)),
scm_cons (sym_mtrigger, scm_cons (sym_mtrigger,

View file

@ -275,6 +275,7 @@ SCM_INTERNAL SCM scm_i_all_segments_statistics (SCM hashtab);
SCM_INTERNAL unsigned long *scm_i_segment_table_info(int *size); SCM_INTERNAL unsigned long *scm_i_segment_table_info(int *size);
extern long int scm_i_deprecated_memory_return; extern long int scm_i_deprecated_memory_return;
extern long int scm_i_find_heap_calls;
/* /*
global init funcs. global init funcs.