United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6336608 : Ability to get system load average

Details
Type:
Enhancement
Submit Date:
2005-10-13
Status:
Resolved
Updated Date:
2010-04-02
Project Name:
JDK
Resolved Date:
2005-12-17
Component:
core-svc
OS:
generic
Sub-Component:
java.lang.management
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:

Related Reports
Relates:

Sub Tasks

Description
Need API to find out the overall system load.  E.g. amount of system CPU used and idle time.  Load average would be more useful to differentiate saturation from oversaturation.

                                    

Comments
EVALUATION

Will add this for Mustang.  It's small RFE and low risk.
                                     
2005-10-13
EVALUATION

A new method is added in java.lang.management.OperatingSystemMXBean interface:
 
    /**
     * Returns the system load average for the last minute.
     * The system load average is the sum of the number of runnable entity
     * queued to the {@linkplain #getAvailableProcessors available processors}
     * and the number of runnable entities running on the available processors
     * averaged over a period of time.
     * The way in which the load average is calculated is operating system
     * specific but is typically a damped time-dependent average.
     * <p>
     * If the load average was not available, a negative value is returned.
     * <p>
     * This method is designed to provide a hint about the system load
     * and may be queried frequently.
     * The load average may be unavailable on some platform where it is
     * expensive to implement this method.
     *
     * @return the system load average; or a negative value if not available.
     *
     * @since 1.6
     */
    public double getSystemLoadAverage();
 
Both linux and Solaris have an API to obtain load averages.  There isn't such metric on Windows.  Instead, there is a run queue length performance counter.  However, it is expensive to obtain the run queue length performance counter.  

Since one requirement of this API has to be cheap, in Sun's implementation, it will return negative value on Windows until a fast implementation can be done in the future.
                                     
2005-12-10
SUGGESTED FIX

Attached webrev.
                                     
2005-12-10
EVALUATION

The reason why this method is not supported on Windows is because the performance impact is too high.  It requires to poll the run queue performance very frequently and calculate the system load average.  The requirement is that this API needs to be on if supported.  When Windows provide a light weight API to get the needed information, we could add the support.
                                     
2006-03-30



Hardware and Software, Engineered to Work Together