RFR: 8358619: Fix interval recomputation in CPU Time Profiler

Johannes Bechberger jbechberger at openjdk.org
Thu Jul 10 09:55:41 UTC 2025


On Tue, 1 Jul 2025 19:41:43 GMT, Andrei Pangin <apangin at openjdk.org> wrote:

>> Fixes the recomputation issue by passing either the rate or the period directly to the sampler (instead of just the rate value with the period value converted into a rate). This prevents issues when the number of cores changes during the JFR recording.
>
> src/jdk.jfr/share/classes/jdk/jfr/internal/util/TimespanRateOrPeriod.java line 95:
> 
>> 93:         }
>> 94:         // fallback to days if no smaller unit is found
>> 95:         return String.format("%d/%s", (long)(rate / TimespanUnit.DAYS.nanos * 1_000_000_000.0), TimespanUnit.DAYS.text);
> 
> Do we really need this complication? Where is this `toString()` used?

In the CPUThrottleSetting:


    @Override
    public String combine(Set<String> values) {
        TimespanRateOrPeriod max = null;
        for (String value : values) {
            TimespanRateOrPeriod rate = TimespanRateOrPeriod.of(value);
            if (rate != null) {
                if (max == null) {
                    max = rate;
                } else {
                    max = TimespanRateOrPeriod.max(max, rate);
                }
            }
        }
        // "off" is not supported
        return Objects.requireNonNullElse(max.toString(), DEFAULT_VALUE);
    }


When combining different settings. We have to return a string.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25775#discussion_r2197180848


More information about the hotspot-jfr-dev mailing list