Skip to content

perf(collector): parse /proc/loadavg without heap allocation - #27

Open
GreyPikachu wants to merge 1 commit into
RomanSnitko:mainfrom
GreyPikachu:perf/zero-alloc-loadavg
Open

GreyPikachu wants to merge 1 commit into
RomanSnitko:mainfrom
GreyPikachu:perf/zero-alloc-loadavg

Conversation

@GreyPikachu

Copy link
Copy Markdown

Description

This pull request optimizes /proc/loadavg parsing by replacing std::istringstream with zero-allocation std::string_view token scanning and std::from_chars.

Motivation

std::istringstream allocates a heap buffer and incurs locale-dependent stream overhead on every collection cycle. Because MetricsCollector::Load() runs on every tick, eliminating dynamic string allocation preserves cache locality and reduces allocator pressure in the sampling hot path.

Changes

  • Replaced std::istringstream in MetricsCollector::Load() with a localized std::string_view whitespace scanner and std::from_chars.

Verification

  • Verified parsing against standard /proc/loadavg formats (e.g. 1 2 3 1/2 42).
  • Existing core and integration tests pass without errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants