Skip to content

Performance: vcgencmd is spawned twice per fast tick (measure_temp + get_throttled) #66

Description

@LarsLaskowski

Source: Full code review 2026-07-17 (docs/reviews/2026-07-17-full-code-review.md), finding F9.
Category: performance / cleanup · Severity: low · Effort: small

Problem

TemperatureCollector (measure_temp, internal/collector/temperature.go:195-204) and ThrottledCollector (get_throttled, internal/collector/throttled.go:90-96) each fork+exec vcgencmd on every fast tick — two subprocesses per 5-second tick on the hot path, each with its own 5 s timeout that counts against the tick budget. The two collectors also duplicate the lazy-redetect logic (redetectVcgencmdLocked) verbatim.

Suggested fix

Extract a small shared vcgencmd runner (single detection + throttled re-detection + run(ctx, subcommand) helper) used by both collectors. Optionally batch both readings per tick through it; halves the exec rate and removes the duplication.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions