$linuxjunkies
>

counter

also: counter variable, performance counter, PMC, perf counter

A variable or register that tracks the number of occurrences of an event, such as instruction executions in a CPU or network packets sent. Counters increment or decrement to measure system activity and performance.

A counter is a numeric variable maintained by the kernel or hardware to count occurrences of specific events. Common examples include CPU instruction counters, performance monitoring counters, and network packet counters that track bytes transmitted or received.

In Linux, you can view various system counters using tools like cat /proc/stat for CPU statistics, ethtool -S for network interface counters, or perf stat for hardware performance counters. For example, /proc/stat shows fields like user, nice, and idle representing CPU time spent in different states.

Performance monitoring counters (PMCs) on modern CPUs track low-level events like cache misses, branch mispredictions, and memory access patterns, which developers use to optimize code performance. These counters help diagnose bottlenecks and understand system behavior.

Related terms