RFR: 7903327: Refactor class 'GCProfiler.VMSupport'

Aleksey Shipilev shade at openjdk.org
Fri Sep 23 09:14:28 UTC 2022


On Fri, 23 Sep 2022 01:24:11 GMT, Guoxiong Li <gli at openjdk.org> wrote:

> Hi all,
> 
> This patch initializes the field `churn` in method `tryInitChurn` instead of in method `newListener` and the field `chrun` will be cleared when starting the profiler each time. But currently the `Multiset` doesn't have a method named `clear`, so I always create a new `HashMultiset` for it in method `startChurnProfile`.
> 
> And this patch only initializes the field `listener` one time and doesn't mark it as `null` when the profiler finished. It is a balance between time and space and I think it is better to save the time (instantiation time and GC time). And a new field `started` is introduced to mark whether the profiler has started.
> 
> Thanks for taking the time to review.
> 
> Best Regards,
> -- Guoxiong

Looks fine, but feel free to introduce `HashMultiset.clear()` (probably in `Multiset` interface) to save more memory on start.

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

PR: https://git.openjdk.org/jmh/pull/80


More information about the jmh-dev mailing list