Skip to content

Commit

Permalink
Add additional perf counters for stalled frontend/backend cycles (pro…
Browse files Browse the repository at this point in the history
…metheus#2191)

* Add stalled frontend/backend cycles counters for perf collector

Signed-off-by: Daniel Hodges <[email protected]>

* Update collector/perf_linux.go

Co-authored-by: Ben Kochie <[email protected]>
Signed-off-by: Daniel Hodges <[email protected]>

* Update collector/perf_linux.go

Co-authored-by: Ben Kochie <[email protected]>
Signed-off-by: Daniel Hodges <[email protected]>

Co-authored-by: Ben Kochie <[email protected]>
  • Loading branch information
2 people authored and oblitorum committed Apr 9, 2024
1 parent 0056e1f commit 2684183
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions collector/perf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,26 @@ func NewPerfCollector(logger log.Logger) (Collector, error) {
[]string{"cpu"},
nil,
),
"stalled_cycles_backend_total": prometheus.NewDesc(
prometheus.BuildFQName(
namespace,
perfSubsystem,
"stalled_cycles_backend_total",
),
"Number of stalled backend CPU cycles",
[]string{"cpu"},
nil,
),
"stalled_cycles_frontend_total": prometheus.NewDesc(
prometheus.BuildFQName(
namespace,
perfSubsystem,
"stalled_cycles_frontend_total",
),
"Number of stalled frontend CPU cycles",
[]string{"cpu"},
nil,
),
"page_faults_total": prometheus.NewDesc(
prometheus.BuildFQName(
namespace,
Expand Down Expand Up @@ -598,6 +618,9 @@ func (c *perfCollector) updateHardwareStats(ch chan<- prometheus.Metric) error {
if err := (*profiler).Profile(hwProfile); err != nil {
return err
}
if hwProfile == nil {
continue
}

cpuid := strconv.Itoa(c.hwProfilerCPUMap[profiler])

Expand Down Expand Up @@ -656,6 +679,22 @@ func (c *perfCollector) updateHardwareStats(ch chan<- prometheus.Metric) error {
cpuid,
)
}

if hwProfile.StalledCyclesBackend != nil {
ch <- prometheus.MustNewConstMetric(
c.desc["stalled_cycles_backend_total"],
prometheus.CounterValue, float64(*hwProfile.StalledCyclesBackend),
cpuid,
)
}

if hwProfile.StalledCyclesFrontend != nil {
ch <- prometheus.MustNewConstMetric(
c.desc["stalled_cycles_frontend_total"],
prometheus.CounterValue, float64(*hwProfile.StalledCyclesFrontend),
cpuid,
)
}
}

return nil
Expand All @@ -667,6 +706,9 @@ func (c *perfCollector) updateSoftwareStats(ch chan<- prometheus.Metric) error {
if err := (*profiler).Profile(swProfile); err != nil {
return err
}
if swProfile == nil {
continue
}

cpuid := strconv.Itoa(c.swProfilerCPUMap[profiler])

Expand Down Expand Up @@ -720,6 +762,9 @@ func (c *perfCollector) updateCacheStats(ch chan<- prometheus.Metric) error {
if err := (*profiler).Profile(cacheProfile); err != nil {
return err
}
if cacheProfile == nil {
continue
}

cpuid := strconv.Itoa(c.cacheProfilerCPUMap[profiler])

Expand Down

0 comments on commit 2684183

Please sign in to comment.