-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
More precise writebarrier for regions #67389
More precise writebarrier for regions #67389
Conversation
…g 4 bits for the current and planned generation. WKS shows no overall improvement, SVR crashes.
…l limits where objects in ephemeral regions may be located. We have to do a range check on the child object in mark_through_cards_helper anyway, and using the ephemeral range allows us to skip the table lookup in the cases where a child object cannot possibly be in an ephemeral region.
- accidentally removed setting plan gen num - need to make the default write barrier larger so we have enough space - fix copy & paste issue in GetCurrentWriteBarrierCode
…ons would remain stuck. This was because in these cases we would not explore the complete range of card table entries for the card bundle.
- use BitScanForward in find_card, find_card_dword - when we start a new card dword, consult the card bundles first - change JIT_ByRefWriteBarrier to consult the region_to_generation_table and set only single bits in the card table.
Tagging subscribers to this area: @dotnet/gc Issue DetailsThis introduces a lookup table for regions where we can find the current generation and the planned generation efficiently. The table has byte-sized elements where the low nibble is the current generation and the high nibble is the planned generation. The table is used in mark_through_cards_helper and in the write barriers (for now only the most frequently used ones, Array.Copy has its own way of setting cards that I haven't fixed). I have changed the write barrier to only set single bits for the case where a pointer to younger generation is stored into an object in an older generation. This costs an interlocked operation in the case the bit is not already set. Hopefully though this will be more than compensated by lower cost in card marking. I haven't implemented yet committing only the part of the lookup table that is needed.
|
src/coreclr/gc/gc.cpp
Outdated
} | ||
if (ephemeral_change) | ||
{ | ||
stomp_write_barrier_ephemeral (ephemeral_low, ephemeral_high, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stomp_write_barrier_ephemeral is required to be called while the EE is suspended. if we are calling this from init_heap_segment, it means it can be called when a new gen0 region is acquired while the EE is running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and when it's called from find_first_valid_region, we could optimize and only call this once at the end of the GC (if the ephemeral range actually got larger).
…rite barrier for OSX.
…lures in OSX are due it.
…f just a single bit. This will allows us to determine the tradeoff between being more precise in the write barrier, which saves work in card marking, and being faster in the write barrier which causes more work in card marking.
… release write barrier in debug builds.
running on a 1st party prod workload -
looking at 500 GCs during steady state as an example - |
…contain flags to indicate whether a region is sweep-in-plan, and whether it has been demoted. Generalize the config setting to change the write barrier to allow reverting to the SVR type write barrier as well. Bug fixes concerning setting the ephemeral limits in the write barrier, and where to compute the ephemeral limits within the GC. Use the lookup via the map_region_to_generation table in the mark phase as well.
…dy relocated and thus shouldn't be tested against gc_low/gc_high.
…doesn't need to be updated between GCs. Removed file name argument to _ASSERTE_ALL_BUILDS macro.
… Volatile<T> expands to T volatile. Use fixed ephemeral bounds for now, but keep more sophisticated code for setting ephemeral_low around.
This introduces a lookup table for regions where we can find the current generation and the planned generation efficiently.
The table has byte-sized elements where the low nibble is the current generation and the high nibble is the planned generation.
The table is used in mark_through_cards_helper and in the write barriers (for now only the most frequently used ones, Array.Copy has its own way of setting cards that I haven't fixed).
I have changed the write barrier to only set single bits for the case where a pointer to younger generation is stored into an object in an older generation. This costs an interlocked operation in the case the bit is not already set. Hopefully though this will be more than compensated by lower cost in card marking.
I haven't implemented yet committing only the part of the lookup table that is needed.