-
Bug
-
Resolution: Duplicate
-
P3
-
14
-
x86
-
windows
I think the Windows version is broken and returning true when it should be returning false! Certainly this logic makes no sense to me:
bool CPUPerformanceInterface::CPUPerformance::initialize() {
if (!pdh_acquire()) {
return true;
}
_context_switches = create_counter_query(PDH_SYSTEM_IDX, PDH_CONTEXT_SWITCH_RATE_IDX);
_process_cpu_load = create_process_query();
if (_process_cpu_load == NULL) {
return true;
}
allocate_counters(_process_cpu_load, 2);
if (initialize_process_counter(_process_cpu_load, 0, PDH_PROCESSOR_TIME_IDX) != OS_OK) {
return true;
}
if (initialize_process_counter(_process_cpu_load, 1, PDH_PRIV_PROCESSOR_TIME_IDX) != OS_OK) {
return true;
}
_process_cpu_load->set.initialized = true;
_machine_cpu_load = create_multi_counter_query();
if (_machine_cpu_load == NULL) {
return true;
}
initialize_cpu_query(_machine_cpu_load, PDH_PROCESSOR_TIME_IDX);
return true;
}
Only the final return should return true; all the others should return false.
bool CPUPerformanceInterface::CPUPerformance::initialize() {
if (!pdh_acquire()) {
return true;
}
_context_switches = create_counter_query(PDH_SYSTEM_IDX, PDH_CONTEXT_SWITCH_RATE_IDX);
_process_cpu_load = create_process_query();
if (_process_cpu_load == NULL) {
return true;
}
allocate_counters(_process_cpu_load, 2);
if (initialize_process_counter(_process_cpu_load, 0, PDH_PROCESSOR_TIME_IDX) != OS_OK) {
return true;
}
if (initialize_process_counter(_process_cpu_load, 1, PDH_PRIV_PROCESSOR_TIME_IDX) != OS_OK) {
return true;
}
_process_cpu_load->set.initialized = true;
_machine_cpu_load = create_multi_counter_query();
if (_machine_cpu_load == NULL) {
return true;
}
initialize_cpu_query(_machine_cpu_load, PDH_PROCESSOR_TIME_IDX);
return true;
}
Only the final return should return true; all the others should return false.
- duplicates
-
JDK-8245042 Improve scalability of reading Windows Performance counters via PDH when using the Process object
-
- Resolved
-
- relates to
-
JDK-8203321 assert(current_query_index < process_query_set->size) failed: invariant
-
- Resolved
-