Skip to content

Commit

Permalink
Merge branch 'yyc/gc-debug-cleanup'
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Jul 28, 2015
2 parents 2207c2f + 0abba4f commit 23bb555
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/gc-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ static void gc_verify(void)
}

#else
#define gc_verify()
#define verify_val(v)
#define verify_parent1(ty,obj,slot,arg1)
#define verify_parent2(ty,obj,slot,arg1,arg2)
Expand Down
29 changes: 10 additions & 19 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,11 @@ static htable_t obj_sizes[3];
#endif

#ifdef GC_FINAL_STATS
static size_t total_freed_bytes=0;
static size_t total_freed_bytes = 0;
static uint64_t max_pause = 0;
static uint64_t total_sweep_time=0;
static uint64_t total_mark_time=0;
static uint64_t total_fin_time=0;
static uint64_t total_sweep_time = 0;
static uint64_t total_mark_time = 0;
static uint64_t total_fin_time = 0;
#endif
int sweeping = 0;

Expand Down Expand Up @@ -1703,14 +1703,8 @@ static int push_root(jl_value_t *v, int d, int bits)
else if (vt == (jl_value_t*)jl_symbol_type) {
//gc_setmark_other(v, GC_MARKED); // symbols have their own allocator and are never freed
}
else if (
#ifdef GC_VERIFY
// this check should not be needed but it helps catching corruptions early
gc_typeof(vt) == (jl_value_t*)jl_datatype_type
#else
1
#endif
) {
// this check should not be needed but it helps catching corruptions early
else if (gc_typeof(vt) == (jl_value_t*)jl_datatype_type) {
jl_datatype_t *dt = (jl_datatype_t*)vt;
size_t dtsz;
if (dt == jl_datatype_type)
Expand Down Expand Up @@ -1738,13 +1732,11 @@ static int push_root(jl_value_t *v, int d, int bits)
//while(ci)
// refyoung |= gc_push_root(children[--ci], d);
}
#ifdef GC_VERIFY
else {
jl_printf(JL_STDOUT, "GC error (probable corruption) :\n");
jl_(vt);
abort();
}
#endif

ret:
#ifdef GC_VERIFY
Expand Down Expand Up @@ -2075,9 +2067,7 @@ void jl_gc_collect(int full)
#endif
estimate_freed = live_bytes - scanned_bytes - perm_scanned_bytes + actual_allocd;

#ifdef GC_VERIFY
gc_verify();
#endif

#if defined(MEMPROFILE)
all_pool_stats();
Expand Down Expand Up @@ -2315,16 +2305,17 @@ void jl_print_gc_stats(JL_STREAM *s)
jl_printf(s, "gc pause \t%.2f ms avg\n\t\t%2.0f ms max\n",
NS2MS(total_gc_time)/n_pause, NS2MS(max_pause));
jl_printf(s, "\t\t(%2d%% mark, %2d%% sweep, %2d%% finalizers)\n",
(total_mark_time*100)/total_gc_time, (total_sweep_time*100)/total_gc_time,
(total_fin_time*100)/total_gc_time);
(int)(total_mark_time * 100 / total_gc_time),
(int)(total_sweep_time * 100 / total_gc_time),
(int)(total_fin_time * 100 / total_gc_time));
}
int i = 0;
while (i < REGION_COUNT && regions[i]) i++;
jl_printf(s, "max allocated regions : %d\n", i);
struct mallinfo mi = mallinfo();
jl_printf(s, "malloc size\t%d MB\n", mi.uordblks/1024/1024);
jl_printf(s, "max page alloc\t%ld MB\n", max_pg_count*GC_PAGE_SZ/1024/1024);
jl_printf(s, "total freed\t%llu b\n", total_freed_bytes);
jl_printf(s, "total freed\t%" PRIuPTR " b\n", total_freed_bytes);
jl_printf(s, "free rate\t%.1f MB/sec\n", (total_freed_bytes/gct)/1024/1024);
}
#endif
Expand Down
2 changes: 0 additions & 2 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,7 @@ static struct uv_shutdown_queue_item *next_shutdown_queue_item(struct uv_shutdow
DLLEXPORT void jl_atexit_hook(int exitcode)
{
if (exitcode == 0) julia_save();
#if defined(GC_FINAL_STATS)
jl_print_gc_stats(JL_STDERR);
#endif
if (jl_options.code_coverage)
jl_write_coverage_data();
if (jl_options.malloc_log)
Expand Down
4 changes: 0 additions & 4 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1480,10 +1480,6 @@ DLLEXPORT size_t jl_static_show(JL_STREAM *out, jl_value_t *v);
DLLEXPORT size_t jl_static_show_func_sig(JL_STREAM *s, jl_value_t *type);
DLLEXPORT void jlbacktrace(void);

#if defined(GC_FINAL_STATS)
void jl_print_gc_stats(JL_STREAM *s);
#endif

// debugging
void show_execution_point(char *filename, int lno);

Expand Down
5 changes: 5 additions & 0 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ void gc_debug_print_status();
#else
#define gc_debug_print_status()
#endif
#if defined(GC_FINAL_STATS)
void jl_print_gc_stats(JL_STREAM *s);
#else
#define jl_print_gc_stats(s) ((void)s)
#endif
int jl_assign_type_uid(void);
jl_value_t *jl_cache_type_(jl_datatype_t *type);
int jl_get_t_uid_ctr(void);
Expand Down
2 changes: 1 addition & 1 deletion src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
// profiling options

// GC_FINAL_STATS prints total GC stats at exit
//#define GC_FINAL_STATS
// #define GC_FINAL_STATS

// MEMPROFILE prints pool summary statistics after every GC
//#define MEMPROFILE
Expand Down

0 comments on commit 23bb555

Please sign in to comment.