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

8339648: ZGC: Division by zero in rule_major_allocation_rate #20888

Closed
wants to merge 4 commits into from
Closed
Changes from 3 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
3 changes: 2 additions & 1 deletion src/hotspot/share/gc/z/zDirector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ static bool rule_major_allocation_rate(const ZDirectorStats& stats) {

// Calculate the GC cost for each reclaimed byte
const double current_young_gc_time_per_bytes_freed = double(young_gc_time) / double(reclaimed_per_young_gc);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this division have the same issue?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it could if no memory has been reclaimed at all (since the VM started). Similar issues would occur in the call to calculate_extra_young_gc_time below. And there I think the problem is even worse, because we might end up with inf - inf == -nan.

Copy link
Member

Choose a reason for hiding this comment

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

The case where we have performed a major collection and no young collection has reclaim any memory seems like a very degenerate situation. The solution is probably to handle that case separately, and not try to adapt the current heuristics to handle the extreme values.

const double current_old_gc_time_per_bytes_freed = double(old_gc_time) / double(reclaimed_per_old_gc);
const double current_old_gc_time_per_bytes_freed = ((reclaimed_per_old_gc == 0) ? (std::numeric_limits<double>::infinity())
: (double(old_gc_time) / double(reclaimed_per_old_gc)));

This comment was marked as resolved.


// Calculate extra time per young collection inflicted by *not* doing an
// old collection that frees up memory in the old generation.
Expand Down