Intel® Performance Counter Monitor (Intel® PCM)
repository·master·Indexed 25 days ago
https://github.com/intel/pcmA high-performance monitoring suite and API for tracking performance and energy metrics on Intel® Core™, Xeon®, Atom™, and Xeon Phi™ processors. It includes command-line tools for real-time observation of IPC, frequency, memory/QPI bandwidth, cache misses, and energy consumption, as well as a sensor server for exporting metrics via HTTP in JSON or Prometheus format for use with Grafana dashboards.
What's inside Intel PCM
- Intel® Performance Counter Monitor (Intel® PCM) is an API and a set of tools used to monitor performance and energy metrics of Intel® Core™, Xeon®, Atom™, and Xeon Phi™ processors. It is compatible with Linux, Windows, FreeBSD, DragonFlyBSD, and ChromeOS.
Monitor PCIe transactions with PCM-IIO
masterThe
pcm-iiotool is used to monitor PCIe transactions. It provides a breakdown of metrics per PCIe bus (IIO stack) and/or per PCIe device.Metrics are categorized into three groups:
Inbound (PCIe device DMA into system)
- IB write: Bytes per second requested by the PCIe device to write to main memory via DMA.
- IB read: Bytes per second requested by the PCIe device to read from main memory via DMA.
Outbound (CPU MMIO to the PCIe device)
- OB read: Bytes per second requested by the CPU to read from the PCIe device via MMIO.
- OB write: Bytes per second requested by the CPU to write to the PCIe device via MMIO.
IOMMU metrics
- IOTLB Lookup: IOTLB lookups per second.
- IOTLB Miss: IOTLB misses per second.
- Ctxt Cache Hit: Context cache hits per second.
- 256T Cache Hit: Second Level Page Walk Cache Hits to a 256T page per second.
- 512G Cache Hit: Second Level Page Walk Cache Hits to a 512G page per second.
- 1G Cache Hit: Second Level Page Walk Cache Hits to a 1G page per second.
- 2M Cache Hit: Second Level Page Walk Cache Hits to a 2M page per second.
- IOMMU Mem Access: IOMMU memory accesses per second.
Install and run the PCM command-line utility on Windows
masterTo use the
pcm.exeutility on Windows, you must first compile and install the Windows MSR driver (msr.sys). For systems with more than 64 logical cores, ensure you compile all binaries inx64platform mode.Prerequisites
- Compile the MSR driver: Follow the driver compilation guide.
- Sign the driver: For Windows 7 and later, you must sign
msr.sys. To allow test-signed drivers, runbcdedit /set testsigning onin an administrator command prompt and reboot.
Installation Steps
- Build
pcm.exe:
The executable will be incmake -B build cmake --build build --config Release --parallelbuild\bin\Release. - Setup Directories:
- Create a directory in
C:\Program Files (x86)\PCM\(as Administrator). - Copy
msr.systoc:\windows\system32. - Copy
pcm.exeto your PCM directory.
- Create a directory in
- Execution:
Run
pcm.exefrom the PCM directory as an Administrator.
Troubleshooting
If you encounter the error
Starting MSR service failed with error 3 The system cannot find the path specified., run:pcm --uninstallDriverand optionally reboot.
cmake -B build cmake --build build --config Release --parallelInstall the PMU Service on Windows
masterTo install the PMU Service as a Windows service, you must first build the project. Once built, use the command line to run the executable with the
-Installflag.PMU Service.exe -InstallInstall the Grafana front-end on a host system
masterThe Grafana front-end can be installed on any host system with connectivity to the target system. Ensure
curlanddockerare installed on the host.Using Telegraf and InfluxDB
Navigate to
scripts/grafanain the PCM source directory and runstart.shproviding the target system's address and port:sudo bash start.sh http://target_system_address:9738Using Prometheus
Alternatively, use
start-prometheus.shto start Prometheus and Grafana containers:sudo bash start-prometheus.sh target_system_address:9738Monitoring Multiple Hosts
To monitor multiple hosts, provide a text file (e.g.,
targets.txt) containing the IP addresses and ports in the following format:host1_ipaddress:pcmport host2_ipaddress:pcmportThen run:
sudo bash start.sh targets.txt # OR sudo bash start-prometheus.sh targets.txtNote: If the host and target are the same machine, do not use
localhost. Use the external IP address or hostname instead, aslocalhostinside the container resolves to the container's own private IP.sudo bash start.sh http://target_system_address:9738Configure Latency Optimized Mode via BIOS
masterDepending on your BIOS version and OEM, the Efficiency Latency Control (ELC) settings can typically be found in one of these menu paths:
- Path 1:
Socket Configuration->Advanced Power Management->CPU – Advanced PM Tuning->Latency Optimized Mode(Set to Enabled or Disabled) - Path 2:
System Utilities->System Configuration->BIOS/Platform Configuration (RBSU)->Power and Performance Options->Advanced Power Options->Efficiency Latency Control(Select Default (Optimized Power Mode) or Latency Optimized Mode)
- Path 1:
Lookup events by name using simdjson
masterIf
pcm-rawis compiled with thesimdjsonsubmodule, it can automatically translate event names into raw encodings using JSON event lists from the Intelperfmonrepository.Setup Requirements: To enable this, you must ensure
simdjsonis present in thesrc/directory. You can do this by cloning the repository recursively or manually:cd src/ git clone https://github.com/simdjson/simdjson.git # Then re-compile PCMUsage:
- Use
-trto enable translation. - Use
-e <EVENT_NAME>for individual events. - Use
-el <FILE>to load event groups from a file (supports multiplexing via semicolon-separated groups).
Example (Individual events):
pcm-raw -tr -e INST_RETIRED.ANY -e CPU_CLK_UNHALTED.THREADExample (Event file):
pcm-raw -tr -el event_file.txtpcm-raw -tr -e INST_RETIRED.ANY -e CPU_CLK_UNHALTED.THREAD -e CPU_CLK_UNHALTED.REF_TSC -e LD_BLOCKS.STORE_FORWARD -e UNC_CHA_CLOCKTICKS -e UNC_M_CAS_COUNT.RD- Use
Measure metrics for specific processes or threads
masterPCM natively measures system-wide, per-processor, or per-core metrics. To monitor a specific process or thread, pin that process/thread to specific cores and read the PCM data for those cores.
Note: Because the OS may schedule other tasks on those cores, this may introduce noise. For high-precision per-process or per-thread profiling, use Intel VTune profiler or the Linux perf profiler.
Build and run pcm-sensor-server on Windows
masterThe
pcm-sensor-serverexposes PCM metrics via HTTP in JSON or Prometheus formats for Grafana integration.Building
- Ensure
msr.sysis compiled and signed. - Build the server:
The executable is located atcmake -B build cmake --build build --config Release --target pcm-sensor-serverbuild\bin\Release\pcm-sensor-server.exe. Note: For HTTPS support, ensure OpenSSL is installed and available to CMake.
Running
- Deployment:
- Copy
pcm-sensor-server.exeto a protected directory (e.g.,C:\Program Files\PCM\). - Copy
msr.systoc:\windows\system32. - If using WinPmem for memory bandwidth, copy
winpmem_x64.sys(orwinpmem_x86.sys) toc:\windows\system32. - Security Warning: Do not place binaries in user-writable directories (Downloads, Desktop, etc.).
- Copy
- Execution:
Run as Administrator:
pcm-sensor-server.exe
CLI Options
-p <port>: Run on a specific port (default:9738).-D <level>: Set debug verbosity level (0= no debug).-s: Enable HTTPS (requires OpenSSL and certificate files).-hor--help: Show help.
Accessing Metrics
- JSON:
http://localhost:9738/(requiresAccept: application/jsonheader). - Prometheus:
http://localhost:9738/metrics.
Windows Limitations
- No Daemon Mode: The
-doption is not supported; the server runs in the foreground. - No Real-time Priority: The
-Roption is not supported. - Signal Handling: Use
Ctrl+Cto stop the server (SIGTERM/SIGINT are not supported).
cmake -B build cmake --build build --config Release --target pcm-sensor-server # Run as Administrator pcm-sensor-server.exe -p 9738- Ensure
Install and configure the Graphical Perfmon front end on Windows
masterThe Perfmon front end allows viewing PCM counters via Windows Performance Monitor.
Installation Steps
- Driver Setup: Compile and sign
msr.sys, then copy it toc:\windows\system32. - Build Components: Build
pcm-lib.dllandPCM-Service.exeusing CMake or Visual Studio. - Deployment:
- Copy
PCM-Service.exe,PCM-Service.exe.config, andpcm-lib.dllinto a PCM sub-directory inC:\Program Files. - Note: The
.configfile is required to preventSystem.NotSupportedExceptionrelated to CAS policy.
- Copy
- Service Setup:
- Open an Administrator terminal in the PCM directory.
- Run:
"PCM-Service.exe" -Install - Run:
net start pcmservice
- Usage: Open Windows Performance Monitor (
perfmon) and look for newPCM*counters.
Troubleshooting
- Service won't start: Check the Windows Event Viewer under
Windows Logs > Applicationfor error messages. - 'custom counter file view is out of memory': This occurs if another application initialized performance counters before PCM.
- Fix 1: Stop/disable the competing application and reboot.
- Fix 2: Edit your
machine.configfile to add:<system.diagnostics> <performanceCounters filemappingsize="2097152" /> </system.diagnostics>
"PCM-Service.exe" -Install net start pcmservice- Driver Setup: Compile and sign
Setup pcm-sensor-server on Windows
masterpcm-sensor-serverruns natively on Windows with the following requirements and limitations:Requirements
- Windows 10+ or Windows Server 2016+.
- Administrator privileges.
- MSR driver installed.
Limitations
- No Daemon Mode: The
-dflag is not available; the server runs in the foreground only. - No Real-time Priority: The
-Rflag is not available. - Stopping: Use
Ctrl+Cto stop the server.
For build instructions, see
WINDOWS_HOWTO.md.Run Intel PCM Server Container with Limited Capabilities
masterIf you prefer not to use--privilegedmode, you can run the container with specific capabilities and volume mounts to access necessary system resources. This configuration exposes CPU metrics on port9738.