more GC stats on exit

This commit is contained in:
Matthew Flatt 2016-08-11 09:58:03 -06:00
parent 0034c31820
commit b0ecafb731
2 changed files with 24 additions and 4 deletions

View File

@ -337,6 +337,8 @@ typedef struct Thread_Local_Variables {
struct Scheme_Thread *main_break_target_thread_;
intptr_t scheme_code_page_total_;
intptr_t max_gc_pre_used_bytes_;
int num_major_garbage_collections_;
int num_minor_garbage_collections_;
int locale_on_;
void *current_locale_name_ptr_;
int gensym_counter_;
@ -736,6 +738,8 @@ XFORM_GC_VARIABLE_STACK_THROUGH_THREAD_LOCAL;
#define main_break_target_thread XOA (scheme_get_thread_local_variables()->main_break_target_thread_)
#define scheme_code_page_total XOA (scheme_get_thread_local_variables()->scheme_code_page_total_)
#define max_gc_pre_used_bytes XOA (scheme_get_thread_local_variables()->max_gc_pre_used_bytes_)
#define num_major_garbage_collections XOA (scheme_get_thread_local_variables()->num_major_garbage_collections_)
#define num_minor_garbage_collections XOA (scheme_get_thread_local_variables()->num_minor_garbage_collections_)
#define locale_on XOA (scheme_get_thread_local_variables()->locale_on_)
#define current_locale_name_ptr XOA (scheme_get_thread_local_variables()->current_locale_name_ptr_)
#define gensym_counter XOA (scheme_get_thread_local_variables()->gensym_counter_)

View File

@ -178,6 +178,8 @@ THREAD_LOCAL_DECL(int scheme_did_gc_count);
THREAD_LOCAL_DECL(static intptr_t process_time_at_swap);
THREAD_LOCAL_DECL(static intptr_t max_gc_pre_used_bytes);
THREAD_LOCAL_DECL(static intptr_t num_major_garbage_collections);
THREAD_LOCAL_DECL(static intptr_t num_minor_garbage_collections);
SHARED_OK static int init_load_on_demand = 1;
SHARED_OK static int compiled_file_check = SCHEME_COMPILED_FILE_CHECK_MODIFY_SECONDS;
@ -9271,6 +9273,11 @@ static void inform_GC(int master_gc, int major_gc, int inc_gc,
&& (max_gc_pre_used_bytes >= 0))
max_gc_pre_used_bytes = pre_used;
if (major_gc)
num_major_garbage_collections++;
else
num_minor_garbage_collections++;
logger = scheme_get_gc_logger();
if (logger && scheme_log_level_p(logger, SCHEME_LOG_DEBUG)) {
/* Don't use scheme_log(), because it wants to allocate a buffer
@ -9346,17 +9353,26 @@ static void log_peak_memory_use()
if (max_gc_pre_used_bytes > 0) {
logger = scheme_get_gc_logger();
if (logger && scheme_log_level_p(logger, SCHEME_LOG_DEBUG)) {
char buf[256], nums[128], *num, *num2;
intptr_t buflen;
char buf[256], nums[128], *num, *numt, *num2;
intptr_t buflen, allocated_bytes;
#ifdef MZ_PRECISE_GC
allocated_bytes = GC_get_memory_ever_allocated();
#else
allocated_bytes = GC_get_total_bytes();
#endif
memset(nums, 0, sizeof(nums));
num = gc_num(nums, max_gc_pre_used_bytes);
num = gc_num(nums, max_gc_pre_used_bytes);
numt = gc_num(nums, allocated_bytes);
num2 = gc_unscaled_num(nums, scheme_total_gc_time);
sprintf(buf,
"" PLACE_ID_FORMAT "atexit peak was %sK; total %sms",
"" PLACE_ID_FORMAT "atexit peak %sK; alloc %sK; major %d; minor %d; %sms",
#ifdef MZ_USE_PLACES
scheme_current_place_id,
#endif
num,
numt,
num_major_garbage_collections,
num_minor_garbage_collections,
num2);
buflen = strlen(buf);
scheme_log_message(logger, SCHEME_LOG_DEBUG, buf, buflen, scheme_false);