Skip to content

[release/7.0] Disable mark phase prefetching for segments #78925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24093,12 +24093,17 @@ BOOL ref_p (uint8_t* r)
return (straight_ref_p (r) || partial_object_p (r));
}

mark_queue_t::mark_queue_t() : curr_slot_index(0)
mark_queue_t::mark_queue_t()
#ifdef MARK_PHASE_PREFETCH
: curr_slot_index(0)
#endif //MARK_PHASE_PREFETCH
{
#ifdef MARK_PHASE_PREFETCH
for (size_t i = 0; i < slot_count; i++)
{
slot_table[i] = nullptr;
}
#endif //MARK_PHASE_PREFETCH
}

// place an object in the mark queue
Expand All @@ -24108,6 +24113,7 @@ mark_queue_t::mark_queue_t() : curr_slot_index(0)
FORCEINLINE
uint8_t *mark_queue_t::queue_mark(uint8_t *o)
{
#ifdef MARK_PHASE_PREFETCH
Prefetch (o);

// while the prefetch is taking effect, park our object in the queue
Expand All @@ -24120,6 +24126,9 @@ uint8_t *mark_queue_t::queue_mark(uint8_t *o)
curr_slot_index = (slot_index + 1) % slot_count;
if (old_o == nullptr)
return nullptr;
#else //MARK_PHASE_PREFETCH
uint8_t* old_o = o;
#endif //MARK_PHASE_PREFETCH

// this causes us to access the method table pointer of the old object
BOOL already_marked = marked (old_o);
Expand Down Expand Up @@ -24171,6 +24180,7 @@ uint8_t *mark_queue_t::queue_mark(uint8_t *o, int condemned_gen)
// returns nullptr if there is no such object
uint8_t* mark_queue_t::get_next_marked()
{
#ifdef MARK_PHASE_PREFETCH
size_t slot_index = curr_slot_index;
size_t empty_slot_count = 0;
while (empty_slot_count < slot_count)
Expand All @@ -24190,15 +24200,18 @@ uint8_t* mark_queue_t::get_next_marked()
}
empty_slot_count++;
}
#endif //MARK_PHASE_PREFETCH
return nullptr;
}

void mark_queue_t::verify_empty()
{
#ifdef MARK_PHASE_PREFETCH
for (size_t slot_index = 0; slot_index < slot_count; slot_index++)
{
assert(slot_table[slot_index] == nullptr);
}
#endif //MARK_PHASE_PREFETCH
}

void gc_heap::mark_object_simple1 (uint8_t* oo, uint8_t* start THREAD_NUMBER_DCL)
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/gc/gcpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ inline void FATAL_GC_ERROR()
// + creates some ro segs
// We can add more mechanisms here.
//#define STRESS_REGIONS
#define MARK_PHASE_PREFETCH
#endif //USE_REGIONS

// FEATURE_STRUCTALIGN was added by Midori. In CLR we are not interested
Expand Down Expand Up @@ -1224,9 +1225,11 @@ enum bookkeeping_element

class mark_queue_t
{
#ifdef MARK_PHASE_PREFETCH
static const size_t slot_count = 16;
uint8_t* slot_table[slot_count];
size_t curr_slot_index;
#endif //MARK_PHASE_PREFETCH

public:
mark_queue_t();
Expand Down