Skip to content
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

[draft] [GC] Don't promote gen0 when it is mostly objects moved to the finalization queue #109085

Closed
wants to merge 6 commits into from

Conversation

markples
Copy link
Member

@markples markples commented Oct 21, 2024

There are several separate questions and cleanup ideas - see GH comments for the code

Comment on lines +29539 to +29545
bool do_promote = ((threshold > older_gen_size) || (promoted > threshold));

dprintf (6666, ("h%d promotion threshold: %zd, promoted bytes: %zd size n+1: %zd -> %s",
i, threshold, promoted, older_gen_size,
(((threshold > (older_gen_size)) || (promoted > threshold)) ? "promote" : "don't promote")));
(do_promote ? "promote" : "don't promote")));

if ((threshold > (older_gen_size)) || (promoted > threshold))
if (do_promote)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simple factoring from when I was initially changing this code

int finalization_percent = (total_promoted_bytes > 0)
? static_cast<int>((100 * finalization_promoted_bytes) / total_promoted_bytes) : 0;
dprintf (6666, ("finalization promotion: %d%% (%zd / %zd)", finalization_percent, finalization_promoted_bytes, total_promoted_bytes));
high_finalization_percentage = finalization_percent >= 90;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

90? Microbenchmark is showing 95-98, so this works for it, but 90 is awfully high.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6666 is probably not the right dprintf level here

@@ -45045,6 +45050,11 @@ BOOL gc_heap::decide_on_compacting (int condemned_gen_number,
should_compact = TRUE;
}

if (high_finalization_percentage)
{
should_compact = TRUE;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently not-compacting causes us to enable promotion below

dprintf(1, ("Finalizer counts @%5s; 0: %6zu; 1: %6zu, 2: %6zu; CF: %6zu; F: %6zu; Free: %6zu",
label, genCounts[0], genCounts[1], genCounts[2],
SegQueueCount(CriticalFinalizerListSeg), SegQueueCount(FinalizerListSeg), SegQueueCount(FreeListSeg)));
}
Copy link
Member Author

@markples markples Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing event only records how much is added to the finalization list. This lets us watch the size over time. I think this is probably worth a new event as well, but I haven't decided what it should be. (perhaps as minimal as just the "start" ones but only if something is non-zero?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably shouldn't be dprintf(1)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#ifdef

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add event for beginning of GC - add to HeapStats?

Comment on lines +168 to +169
FIRE_DPRINTF_EVENT(GCHeapStats_V2, 1,
"0: %zu(%zu); 1: %zu(%zu); 2: %zu(%zu); 3: %zu(%zu); 4: %zu(%zu); final: %zu bytes(%zu); pin: %zu; sync: %zu; gchandles: %zu",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an idea for removing the code duplication here -

This was useful to me because I was using other dprintfs (not an event log) to analyze this PR, but the checked-in dprintf was missing information that the event had.

The downside is that one can't update the dprintf because it has to match the event. Notice that I had to drop the gc_index from the output, so one now has to go find the *GC* line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to undo change to dprintf level 1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cut

Copy link
Contributor

Tagging subscribers to this area: @dotnet/gc
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant