Additional HRT logging

This commit is contained in:
Justin Ethier 2020-02-05 12:59:33 -05:00
parent 4863df17cf
commit 81a3cf9c2f
3 changed files with 26 additions and 3 deletions

12
gc.c
View file

@ -1144,6 +1144,9 @@ void gc_start_major_collection(gc_thread_data *thd){
void *gc_try_alloc_slow(gc_heap *h_passed, gc_heap *h, int heap_type, size_t size, char *obj, gc_thread_data *thd)
{
#ifdef CYC_HIGH_RES_TIMERS
long long tstamp = hrt_get_current();
#endif
gc_heap *h_start = h, *h_prev;
void *result = NULL;
// Find next heap
@ -1169,6 +1172,9 @@ void *gc_try_alloc_slow(gc_heap *h_passed, gc_heap *h, int heap_type, size_t siz
// prev_free_size = h_size; // Full size was cached
//}
gc_heap *keep = gc_sweep(h, heap_type, thd); // Clean up garbage objects
#ifdef CYC_HIGH_RES_TIMERS
hrt_log_delta("gc sweep", tstamp);
#endif
h_passed->num_unswept_children--;
if (!keep) {
// Heap marked for deletion, remove it and keep searching
@ -1262,6 +1268,9 @@ static void *gc_try_alloc_fixed_size(gc_heap * h, int heap_type, size_t size, ch
void *gc_try_alloc_slow_fixed_size(gc_heap *h_passed, gc_heap *h, int heap_type, size_t size, char *obj, gc_thread_data *thd)
{
#ifdef CYC_HIGH_RES_TIMERS
long long tstamp = hrt_get_current();
#endif
gc_heap *h_start = h, *h_prev;
void *result = NULL;
// Find next heap
@ -1283,6 +1292,9 @@ void *gc_try_alloc_slow_fixed_size(gc_heap *h_passed, gc_heap *h, int heap_type,
} else if (h->is_unswept == 1 && !gc_is_heap_empty(h)) {
unsigned int h_size = h->size;
gc_heap *keep = gc_sweep_fixed_size(h, heap_type, thd); // Clean up garbage objects
#ifdef CYC_HIGH_RES_TIMERS
hrt_log_delta("gc sweep fixed size", tstamp);
#endif
h_passed->num_unswept_children--;
if (!keep) {
// Heap marked for deletion, remove it and keep searching

View file

@ -22,6 +22,17 @@
#include <dlfcn.h>
#include "cyclone/bignum.h"
#ifdef CYC_HIGH_RES_TIMERS
/**
* \defgroup hrt High resolution timers
*/
/**@{*/
long long hrt_get_current();
long long hrt_cmp_current(long long tstamp);
void hrt_log_delta(const char *label, long long tstamp);
/**@}*/
#endif
/**
* Generic object type
* \ingroup objects

View file

@ -109,7 +109,7 @@ long long hrt_cmp_current(long long tstamp)
return (now - tstamp);
}
void hrt_log_delta(long long tstamp)
void hrt_log_delta(const char *label, long long tstamp)
{
static long long initial = 1;
static long long initial_tstamp;
@ -119,7 +119,7 @@ void hrt_log_delta(long long tstamp)
}
long long total = hrt_cmp_current(initial_tstamp);
long long delta = hrt_cmp_current(tstamp);
fprintf(stdout, "%llu, %llu\n", total, delta);
fprintf(stdout, "%s, %llu, %llu\n", label, total, delta);
}
/* END High resolution timers */
@ -6123,7 +6123,7 @@ long long tstamp = hrt_get_current();
// Cooperate with the collector thread
gc_mut_cooperate((gc_thread_data *) data, alloci);
#ifdef CYC_HIGH_RES_TIMERS
hrt_log_delta(tstamp);
hrt_log_delta("minor gc", tstamp);
#endif
// Let it all go, Neo...
longjmp(*(((gc_thread_data *) data)->jmp_start), 1);