Skip to content

Commit

Permalink
Optimise instrumented runtime mode in marking
Browse files Browse the repository at this point in the history
  • Loading branch information
stedolan committed Jul 26, 2021
1 parent 7c44451 commit 4c2b713
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions runtime/major_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ Caml_noinline static intnat do_some_marking
#ifndef CAML_INSTR
(intnat work)
#else
(intnat work, int* slice_fields, int* slice_pointers)
(intnat work, int* pslice_fields, int* pslice_pointers)
#endif
{
uintnat pb_enqueued = 0, pb_dequeued = 0;
Expand All @@ -638,6 +638,10 @@ Caml_noinline static intnat do_some_marking
#define Is_major_block(v) (Is_block_and_not_young(v) && Is_in_heap(v))
#endif

#ifdef CAML_INSTR
int slice_fields = 0, slice_pointers = 0;
#endif

while (1) {
value *scan, *obj_end, *scan_end;
uintnat min_pb = Pb_min; /* keep pb at least this full */
Expand Down Expand Up @@ -700,9 +704,13 @@ Caml_noinline static intnat do_some_marking

for (; scan < scan_end; scan++) {
value v = *scan;
CAML_EVENTLOG_DO({ (*slice_fields) ++; });
#ifdef CAML_INSTR
slice_fields ++;
#endif
if (Is_major_block(v)) {
CAML_EVENTLOG_DO({ (*slice_pointers) ++; });
#ifdef CAML_INSTR
slice_pointers ++;
#endif
if (pb_enqueued == pb_dequeued + Pb_size) {
break; /* Prefetch buffer is full */
}
Expand Down Expand Up @@ -734,6 +742,10 @@ Caml_noinline static intnat do_some_marking
*Caml_state->mark_stack = stk;
if (darkened_anything)
ephe_list_pure = 0;
#ifdef CAML_INSTR
*pslice_fields += slice_fields;
*pslice_pointers += slice_pointers;
#endif
return work;
}

Expand Down

0 comments on commit 4c2b713

Please sign in to comment.