performance-analyzer icon indicating copy to clipboard operation
performance-analyzer copied to clipboard

Implement system metrics equivalent for Windows

Open kkhatua opened this issue 2 years ago • 4 comments

Child of https://github.com/opensearch-project/performance-analyzer/issues/75

System metrics are easily access in Linux, but a number of metrics are unavailable (directly) in Windows. There might be a need for finding out equivalent libraries or utilities that can provide the same level. e.g. https://github.com/opensearch-project/performance-analyzer-rca/blob/main/src/main/java/org/opensearch/performanceanalyzer/metrics_generator/linux/LinuxCPUPagingActivityGenerator.java

kkhatua avatar Oct 12 '22 20:10 kkhatua

Neutral answer: to get the data you seek on Windows requires accessing the Performance Counter framework. There are ways to do so via command line but they're slow and the ideal solution is using native access. To do that from within Java requires using JNI, JNR, JNA, or beginning with JDK19+, the new Java FFM API. I've explored all these options over the past seven years and can offer neutral advice for anyone wanting to reinvent the wheel.

Shameless plug:

There haven't been many Java-based libraries for accessing system metric data from Java. Back in 2010, the leading option was SIGAR but it was GPL licensed. Some guy named @dblock started a library to do the equivalent using JNA.

Around 2015, some other guy named @dbwiddis came along, wanting to measure the performance of cloud servers in a distributed computing cluster. After surveying all the options, he found @dblock's project and decided it was the best option. After a bug fix here, added features there, and customer obsession at answering every system-information-related question on Stack Overflow, eventually he ended up taking over as maintainer of that project and expanding its capabilities. It has essentially become the most popular Java-based system information library used by a lot of projects needing to track system metrics.

You may want to consider using that library as a dependency or asking @dbwiddis to port some of his code over here. He'd be happy to help.

dbwiddis avatar Oct 15 '22 04:10 dbwiddis

I am familiar with SIGAR and used it extensively for Hadoop/Hive based projects, but the project had shuttered since. OSHI looks like a promising alternative, so we'll take a look.

kkhatua avatar Oct 18 '22 20:10 kkhatua

I would evaluate replacing system metrix on Linux with OSHI as well, because it's a nicely abstracted interface for a myriad pieces of information. It would make cross-platform development for PA so much easier/faster. It's also fully dependent on JNA which is already included in OpenSearch.

dblock avatar Oct 19 '22 12:10 dblock

I would evaluate replacing system metrix on Linux with OSHI as well

Yep, it's a one-time change to get the same data from the same sources, but opens up Windows, macOS, and other OS's in the process.

dbwiddis avatar Oct 19 '22 16:10 dbwiddis