RFR: 8270100: Fix some inaccurate GC logging

Albert Mingkun Yang ayang at openjdk.java.net
Mon Jul 12 18:53:51 UTC 2021


On Mon, 12 Jul 2021 08:22:09 GMT, Volker Simonis <simonis at openjdk.org> wrote:

> duplicate the computation of threads_count and adjust_for_thread_increase

I don't view a method call and accessing a global as much duplication. Anyway, this is subjective.

> I don't see why assigning to 100 to _shrink_factor and current_shrink_factor should be any better?

Having a logic-free (does nothing but print) logger brings less surprise. IOW, many expect a logger faithfully reflect the actual internal states with no distortion.

> These values aren't used except for logging if ShrinkHeapInSteps is false.

That's true, but I prefer that the logger doesn't know `ShrinkHeapInSteps`, and just prints `_shrink_factor` and `current_shrink_factor` as they are.

> But on heap expansion, we'll return from the method early, before even reaching the shrinking logic.

I see; thank you for pointing it out. How about sth like this?


void CardGeneration::compute_new_size() {
  ... 
  if (capacity_after_gc < minimum_desired_capacity) {
    ...
    // expanding the heap; reset shrink factor
    _shrink_factor = 0;
    return;
  }

  if (capacity_after_gc > maximum_desired_capacity) {
    ...
    if (ShrinkHeapInSteps) {
      current_shrink_factor = _shrink_factor;
      _shrink_factor = ...
    } else {
      // Shrink 100% to the desired value
      current_shrink_factor = _shrink_factor = 100;
    }
    // log internal states
  }
}

-------------

PR: https://git.openjdk.java.net/jdk/pull/4727


More information about the hotspot-gc-dev mailing list