Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Bgc suspension fixes (#27729)
Browse files Browse the repository at this point in the history
* Changes to set gen0 bricks always. This reduces the time spent in find_first_object when finding the start of objects for marking interior pointers.

* Revert "Changes to set gen0 bricks always. This reduces the time spent in find_first_object when finding the start of objects for marking interior pointers."

This reverts commit 9d53ff9.

* Two fixes to speed up suspension for foreground GCs while background GC is in progress:

- In background_mark_simple1, check g_fSuspensionPending and if it is set, save the state of the work and restart the loop - this will call allow_fgc() and thus allow a foreground GC to take place.

- In revisit_written_page, call allow_fgc() at the end - this allow a foreground GC to happen whenever we are done with revisiting a written page.

* Addressed code review feedback - use counter instead of testing g_fSuspensionPending directly.
  • Loading branch information
PeterSolMS authored and sergiy-k committed Nov 13, 2019
1 parent 2c4fb32 commit a7678f5
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19882,7 +19882,8 @@ void gc_heap::background_mark_simple1 (uint8_t* oo THREAD_NUMBER_DCL)
*(place) = start;
*(background_mark_stack_tos++) = (uint8_t*)((size_t)oo | 1);

int i = num_partial_refs;
int num_pushed_refs = num_partial_refs;
int num_processed_refs = num_pushed_refs * 16;

go_through_object (method_table(oo), oo, s, ppslot,
start, use_start, (oo + s),
Expand All @@ -19900,7 +19901,7 @@ void gc_heap::background_mark_simple1 (uint8_t* oo THREAD_NUMBER_DCL)
if (contain_pointers_or_collectible (o))
{
*(background_mark_stack_tos++) = o;
if (--i == 0)
if (--num_pushed_refs == 0)
{
//update the start
*place = (uint8_t*)(ppslot+1);
Expand All @@ -19909,13 +19910,19 @@ void gc_heap::background_mark_simple1 (uint8_t* oo THREAD_NUMBER_DCL)

}
}
if (--num_processed_refs == 0)
{
// give foreground GC a chance to run
*place = (uint8_t*)(ppslot + 1);
goto more_to_do;
}

}
}
);
//we are finished with this object
*place = 0;
*(place+1) = 0;

more_to_do:;
}
else
Expand Down Expand Up @@ -27971,9 +27978,6 @@ void gc_heap::revisit_written_page (uint8_t* page,
}
else if (
concurrent_p &&
#ifndef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP // see comment below
large_objects_p &&
#endif // !FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP
((CObjectHeader*)o)->IsFree() &&
(next_o > min (high_address, page + WRITE_WATCH_UNIT_SIZE)))
{
Expand Down Expand Up @@ -28022,6 +28026,11 @@ void gc_heap::revisit_written_page (uint8_t* page,

dprintf (3,("Last object: %Ix", (size_t)last_object));
last_page = align_write_watch_lower_page (o);

if (concurrent_p)
{
allow_fgc();
}
}

// When reset_only_p is TRUE, we should only reset pages that are in range
Expand Down

0 comments on commit a7678f5

Please sign in to comment.