Skip to content

Commit

Permalink
update gc timers debugging code
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Jun 24, 2017
1 parent 696820b commit bbfc24c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
18 changes: 13 additions & 5 deletions src/gc-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ static void gc_verify_tags_page(jl_gc_pagemeta_t *pg)
// the following are used by the deserializer to invalidate objects
v->header != 0x10 && v->header != 0x20 &&
v->header != 0x30 && v->header != 0x40 &&
v->header != 0x50) {
v->header != 0x50 && v->header != 0x60) {
assert(jl_typeof(dt) == (jl_value_t*)jl_datatype_type);
}
}
Expand Down Expand Up @@ -652,7 +652,7 @@ void objprofile_count(void *ty, int old, int sz)

void objprofile_reset(void)
{
for(int g=0; g < 3; g++) {
for (int g = 0; g < 3; g++) {
htable_reset(&obj_counts[g], 0);
htable_reset(&obj_sizes[g], 0);
}
Expand Down Expand Up @@ -885,6 +885,14 @@ void gc_time_pool_end(int sweep_full)
sweep_full ? "full" : "quick");
}

void gc_time_sysimg_end(uint64_t t0)
{
double sweep_pool_sec = (jl_hrtime() - t0) / 1e9;
jl_printf(JL_STDOUT,
"GC sweep sysimg end %.2f ms\n",
sweep_pool_sec * 1000);
}

static int64_t big_total;
static int64_t big_freed;
static int64_t big_reset;
Expand All @@ -908,7 +916,7 @@ void gc_time_count_big(int old_bits, int bits)
void gc_time_big_end(void)
{
double t_ms = jl_ns2ms(jl_hrtime() - big_sweep_start);
jl_printf(JL_STDOUT, "GC sweep big %.2f "
jl_printf(JL_STDOUT, "GC sweep big %.2f ms "
"(freed %" PRId64 " / %" PRId64 " with %" PRId64 " rst)\n",
t_ms, big_freed, big_total, big_reset);
}
Expand All @@ -932,8 +940,8 @@ void gc_time_count_mallocd_array(int bits)

void gc_time_mallocd_array_end(void)
{
double t_ms = jl_ns2ms(jl_hrtime() - big_sweep_start);
jl_printf(JL_STDOUT, "GC sweep arrays %.2f "
double t_ms = jl_ns2ms(jl_hrtime() - mallocd_array_sweep_start);
jl_printf(JL_STDOUT, "GC sweep arrays %.2f ms "
"(freed %" PRId64 " / %" PRId64 ")\n",
t_ms, mallocd_array_freed, mallocd_array_total);
}
Expand Down
32 changes: 26 additions & 6 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,9 @@ static void gc_sweep_pool(int sweep_full)

static void gc_sweep_perm_alloc(void)
{
uint64_t t0 = jl_hrtime();
gc_sweep_sysimg();
gc_time_sysimg_end(t0);
}


Expand Down Expand Up @@ -2009,17 +2011,23 @@ mark: {
#endif
jl_taggedvalue_t *o = jl_astaggedvalue(new_obj);
jl_datatype_t *vt = (jl_datatype_t*)tag;
if ((void*)o >= sysimg_base && (void*)o < sysimg_end)
meta_updated = 1;
int foreign_alloc = 0;
int update_meta = __likely(!meta_updated && !gc_verifying);
if (update_meta && (void*)o >= sysimg_base && (void*)o < sysimg_end) {
foreign_alloc = 1;
update_meta = 0;
}
meta_updated = 0;
// Symbols are always marked
assert(vt != jl_symbol_type);
if (vt == jl_simplevector_type) {
size_t l = jl_svec_len(new_obj);
jl_value_t **data = jl_svec_data(new_obj);
size_t dtsz = l * sizeof(void*) + sizeof(jl_svec_t);
if (update_meta)
gc_setmark(ptls, o, bits, l * sizeof(void*) + sizeof(jl_svec_t));
gc_setmark(ptls, o, bits, dtsz);
else if (foreign_alloc)
objprofile_count(vt, bits == GC_OLD_MARKED, dtsz);
uintptr_t nptr = (l << 2) | (bits & GC_OLD);
objary_begin = data;
objary_end = data + l;
Expand All @@ -2038,6 +2046,8 @@ mark: {
else
gc_setmark_big(ptls, o, bits);
}
else if (foreign_alloc)
objprofile_count(vt, bits == GC_OLD_MARKED, sizeof(jl_array_t));
if (flags.how == 1) {
void *val_buf = jl_astaggedvalue((char*)a->data - a->offset * a->elsize);
verify_parent1("array", new_obj, &val_buf, "buffer ('loc' addr is meaningless)");
Expand All @@ -2046,7 +2056,7 @@ mark: {
bits, array_nbytes(a));
}
else if (flags.how == 2) {
if (update_meta) {
if (update_meta || foreign_alloc) {
objprofile_count(jl_malloc_tag, bits == GC_OLD_MARKED,
array_nbytes(a));
if (bits == GC_OLD_MARKED) {
Expand Down Expand Up @@ -2083,6 +2093,8 @@ mark: {
else if (vt == jl_module_type) {
if (update_meta)
gc_setmark(ptls, o, bits, sizeof(jl_module_t));
else if (foreign_alloc)
objprofile_count(vt, bits == GC_OLD_MARKED, sizeof(jl_module_t));
jl_module_t *m = (jl_module_t*)new_obj;
jl_binding_t **table = (jl_binding_t**)m->bindings.table;
size_t bsize = m->bindings.size;
Expand All @@ -2096,6 +2108,8 @@ mark: {
else if (vt == jl_task_type) {
if (update_meta)
gc_setmark(ptls, o, bits, sizeof(jl_task_t));
else if (foreign_alloc)
objprofile_count(vt, bits == GC_OLD_MARKED, sizeof(jl_task_t));
jl_task_t *ta = (jl_task_t*)new_obj;
gc_scrub_record_task(ta);
int stkbuf = (ta->stkbuf != (void*)(intptr_t)-1 && ta->stkbuf != NULL);
Expand Down Expand Up @@ -2148,15 +2162,21 @@ mark: {
goto obj8_loaded;
}
else if (vt == jl_string_type) {
size_t dtsz = jl_string_len(new_obj) + sizeof(size_t) + 1;
if (update_meta)
gc_setmark(ptls, o, bits, jl_string_len(new_obj) + sizeof(size_t) + 1);
gc_setmark(ptls, o, bits, dtsz);
else if (foreign_alloc)
objprofile_count(vt, bits == GC_OLD_MARKED, dtsz);
goto pop;
}
else {
if (__unlikely(!jl_is_datatype(vt)))
gc_assert_datatype_fail(ptls, vt, sp);
size_t dtsz = jl_datatype_size(vt);
if (update_meta)
gc_setmark(ptls, o, bits, jl_datatype_size(vt));
gc_setmark(ptls, o, bits, dtsz);
else if (foreign_alloc)
objprofile_count(vt, bits == GC_OLD_MARKED, dtsz);
if (vt == jl_weakref_type)
goto pop;
const jl_datatype_layout_t *layout = vt->layout;
Expand Down
4 changes: 3 additions & 1 deletion src/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ void gc_final_pause_end(int64_t t0, int64_t tend);
void gc_time_pool_start(void);
void gc_time_count_page(int freedall, int pg_skpd);
void gc_time_pool_end(int sweep_full);
void gc_time_sysimg_end(uint64_t t0);

void gc_time_big_start(void);
void gc_time_count_big(int old_bits, int bits);
Expand All @@ -543,7 +544,8 @@ STATIC_INLINE void gc_time_count_page(int freedall, int pg_skpd)
(void)freedall;
(void)pg_skpd;
}
#define gc_time_pool_end(sweep_full)
#define gc_time_pool_end(sweep_full) (void)(sweep_full)
#define gc_time_sysimg_end(t0) (void)(t0)
#define gc_time_big_start()
STATIC_INLINE void gc_time_count_big(int old_bits, int bits)
{
Expand Down

0 comments on commit bbfc24c

Please sign in to comment.