RFR: 7903327: Refactor class 'GCProfiler.VMSupport'

Guoxiong Li gli at openjdk.org
Fri Sep 23 09:14:28 UTC 2022


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

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

Commit messages:
 - Refactor class VMSupport.

Changes: https://git.openjdk.org/jmh/pull/80/files
 Webrev: https://webrevs.openjdk.org/?repo=jmh&pr=80&range=00
  Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903327
  Stats: 10 lines in 1 file changed: 3 ins; 1 del; 6 mod
  Patch: https://git.openjdk.org/jmh/pull/80.diff
  Fetch: git fetch https://git.openjdk.org/jmh pull/80/head:pull/80

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


More information about the jmh-dev mailing list