Skip to content

Commit

Permalink
record if a thread is responsible for a gc
Browse files Browse the repository at this point in the history
because the profile contains an entry for every gc
that this thread took part in

next up: record the gc sequence numbers because the
indices don't match up after threads have their work
stolen by another.
  • Loading branch information
timo committed Feb 18, 2018
1 parent aeabc1d commit 7753fc5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/gc/orchestrate.c
Expand Up @@ -416,7 +416,7 @@ void MVM_gc_enter_from_allocator(MVMThreadContext *tc) {

/* If profiling, record that GC is starting. */
if (tc->instance->profiling)
MVM_profiler_log_gc_start(tc, tc->instance->gc_full_collect);
MVM_profiler_log_gc_start(tc, tc->instance->gc_full_collect, 1);

/* Ensure our stolen list is empty. */
tc->gc_work_count = 0;
Expand Down Expand Up @@ -514,7 +514,7 @@ void MVM_gc_enter_from_interrupt(MVMThreadContext *tc) {

/* If profiling, record that GC is starting. */
if (tc->instance->profiling)
MVM_profiler_log_gc_start(tc, is_full_collection(tc));
MVM_profiler_log_gc_start(tc, is_full_collection(tc), 0);

/* We'll certainly take care of our own work. */
tc->gc_work_count = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/profiler/instrument.c
Expand Up @@ -315,6 +315,7 @@ typedef struct {
MVMString *gcs;
MVMString *time;
MVMString *full;
MVMString *responsible;
MVMString *cleared_bytes;
MVMString *retained_bytes;
MVMString *promoted_bytes;
Expand Down Expand Up @@ -483,6 +484,8 @@ static MVMObject * dump_thread_data(MVMThreadContext *tc, ProfDumpStrs *pds,
box_i(tc, ptd->gcs[i].time / 1000));
MVM_repr_bind_key_o(tc, gc_hash, pds->full,
box_i(tc, ptd->gcs[i].full));
MVM_repr_bind_key_o(tc, gc_hash, pds->responsible,
box_i(tc, ptd->gcs[i].responsible));
MVM_repr_bind_key_o(tc, gc_hash, pds->cleared_bytes,
box_i(tc, ptd->gcs[i].cleared_bytes));
MVM_repr_bind_key_o(tc, gc_hash, pds->retained_bytes,
Expand Down Expand Up @@ -535,6 +538,7 @@ void MVM_profile_dump_instrumented_data(MVMThreadContext *tc) {
pds.gcs = str(tc, "gcs");
pds.time = str(tc, "time");
pds.full = str(tc, "full");
pds.responsible = str(tc, "responsible");
pds.cleared_bytes = str(tc, "cleared_bytes");
pds.retained_bytes = str(tc, "retained_bytes");
pds.promoted_bytes = str(tc, "promoted_bytes");
Expand Down
3 changes: 2 additions & 1 deletion src/profiler/log.c
Expand Up @@ -279,7 +279,7 @@ void MVM_profile_log_allocated(MVMThreadContext *tc, MVMObject *obj) {
}

/* Logs the start of a GC run. */
void MVM_profiler_log_gc_start(MVMThreadContext *tc, MVMuint32 full) {
void MVM_profiler_log_gc_start(MVMThreadContext *tc, MVMuint32 full, MVMuint32 this_thread_responsible) {
MVMProfileThreadData *ptd = get_thread_data(tc);
MVMProfileGC *gc;

Expand All @@ -294,6 +294,7 @@ void MVM_profiler_log_gc_start(MVMThreadContext *tc, MVMuint32 full) {
gc->full = full;
gc->cleared_bytes = (char *)tc->nursery_alloc -
(char *)tc->nursery_tospace;
gc->responsible = this_thread_responsible;

/* Record start time. */
ptd->cur_gc_start_time = uv_hrtime();
Expand Down
7 changes: 5 additions & 2 deletions src/profiler/log.h
Expand Up @@ -45,7 +45,10 @@ struct MVMProfileGC {
MVMuint64 abstime;

/* Was it a full collection? */
MVMuint32 full;
MVMuint16 full;

/* Was this thread responsible? */
MVMuint16 responsible;

/* Nursery statistics. */
MVMuint32 cleared_bytes;
Expand Down Expand Up @@ -160,7 +163,7 @@ void MVM_profile_log_unwind(MVMThreadContext *tc);
MVMProfileContinuationData * MVM_profile_log_continuation_control(MVMThreadContext *tc, const MVMFrame *root_frame);
void MVM_profile_log_continuation_invoke(MVMThreadContext *tc, const MVMProfileContinuationData *cd);
void MVM_profile_log_allocated(MVMThreadContext *tc, MVMObject *obj);
void MVM_profiler_log_gc_start(MVMThreadContext *tc, MVMuint32 full);
void MVM_profiler_log_gc_start(MVMThreadContext *tc, MVMuint32 full, MVMuint32 this_thread_responsible);
void MVM_profiler_log_gc_end(MVMThreadContext *tc);
void MVM_profiler_log_spesh_start(MVMThreadContext *tc);
void MVM_profiler_log_spesh_end(MVMThreadContext *tc);
Expand Down

0 comments on commit 7753fc5

Please sign in to comment.