Skip to content

Commit

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

Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>

* Update collector/perf_linux.go

Co-authored-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>

* Update collector/perf_linux.go

Co-authored-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>

Co-authored-by: Ben Kochie <superq@gmail.com>
  • Loading branch information
hodgesds and SuperQ authored Aug 2, 2022
1 parent 9ed3266 commit b43db0d
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 b43db0d

Please sign in to comment.