JDK-8296126 : Add +XX:OsCachedMetricsRefreshRate= to set a refresh rate of the cached metrics
  • Type: CSR
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Closed
  • Resolution: Withdrawn
  • Submitted: 2022-10-31
  • Updated: 2024-04-04
  • Resolved: 2024-04-04
Related Reports
CSR :  
Description
Summary
-------

Add a new command line option:

`-XX:OsCachedMetricsRefreshRate=<value>`, -

which will set the OS cached metrics refresh rate as times per second.

Problem
-------

JDK-8232207 introduced the timeout between re-readings of the cached metrics (memory limit and active processor count) to avoid re-reading container settings too often and at the same time keeps the system responsive. The value of the timeout was hardcoded as 20 ms and cannot be changed. However, in the course of the discussion there were some thoughts concerning possible need to add a flag to control it in the future.

Solution
--------

Add a new command line product option:

`-XX:OsCachedMetricsRefreshRate=<value>`, -

where a value is times per second and is in the range [1; 1000000000].

It substitutes the hardcoded timeout of 20 ms between re-readings of the OS cached metrics introduced in JDK-8232207 and allows to set this timeout (as a refresh rate) by a user at the launch time.

It can be used as followed:

    java -XX:OsCachedMetricsRefreshRate=100 MyApp

Specification
-------------

    --- a/src/hotspot/os/linux/globals_linux.hpp
    +++ b/src/hotspot/os/linux/globals_linux.hpp
    @@ -77,7 +77,13 @@
               "Use CPU_ALLOC code path in os::active_processor_count ")     \
                                                                             \
       product(bool, DumpPerfMapAtExit, false, DIAGNOSTIC,                   \
    -          "Write map file for Linux perf tool at exit")
    +          "Write map file for Linux perf tool at exit")                 \
    +                                                                        \
    +  product(uint, OsCachedMetricsRefreshRate, 50, DIAGNOSTIC,             \
    +          "Specify the refresh rate of the OS cached metrics to avoid " \
    +          "re-reading container settings too often. [times per second]" \
    +          "The default equals to 20ms timeout between re-reads.")       \
    +          range(1, NANOSECS_PER_SEC)                                    \
     
     // end of RUNTIME_OS_FLAGS

See the changes in the pull request [1] for implementation details. This option is only available on Linux.

[1] https://github.com/openjdk/jdk/pull/10918

Comments
Moved to Closed - withdrawn.
04-04-2024

The associated bug was closed as "Won't Fix": JDK-8296125 Add a command line option to set a refresh rate of the OS cached metrics in Linux What's the right way to closed this CSR?
03-04-2024

The option definition is shown as a diff with the latest update in the specification part. Thank you!
02-11-2022

[~omikhaltcova] I meant type the diff directly inline.
01-11-2022

Moving back to Draft. [~omikhaltcova], please have one or more other HotSpot engineers review this CSR before re-Proposing it or Finalizing it.
01-11-2022

[~omikhaltcova] For the specification part here please include the diff from globals.hpp that shows the definition of the new flag. Thank you.
01-11-2022