RFR: 8368015: Shenandoah: fix error in computation of average allocation rate
Kelvin Nilsen
kdnilsen at openjdk.org
Sat Sep 20 00:20:13 UTC 2025
On Fri, 19 Sep 2025 20:36:51 GMT, Kelvin Nilsen <kdnilsen at openjdk.org> wrote:
> We use bytes_allocated_since_gc_start() to compute allocation rates. This leaves a blind spot, as our current implementation ignores allocations and the time period between the moment we begin GC and the first time we update the allocation rate following the start of GC. When this happens, we typically find that the sampled number of allocations is smaller than the allocations that had accumulated by the time we triggered the start of the current GC cycle.
>
> This PR adds tracking for that accounting gap.
>
> I had something like this in mind:
>
> ```c++
> // atomic exchange existing value with zero
> size_t bytes_allocated = young_generation()->reset_bytes_allocated_since_gc_start();
> // incorporate the value into the samples for the average
> young_generation()->sample_allocations(bytes_allocated);
> ```
>
This is a good idea. We'll end up with two samples whereas my proposed solution had a single combined sample. But we avoid the extra variable. Also, two samples gives us better awareness of acceleration...
I'll make this change.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27398#issuecomment-3314273445
More information about the hotspot-gc-dev
mailing list