Skip to content

System metrics monitoring (CPU, memory, network I/O) during benchmark runs#84

Open
acere wants to merge 4 commits into
awslabs:mainfrom
acere:feature/system-metrics-monitoring
Open

System metrics monitoring (CPU, memory, network I/O) during benchmark runs#84
acere wants to merge 4 commits into
awslabs:mainfrom
acere:feature/system-metrics-monitoring

Conversation

@acere

@acere acere commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an optional SystemMetricsMonitor callback that tracks CPU, memory, and network I/O during benchmark runs using psutil. Helps detect whether the client machine is a bottleneck during high-concurrency load tests.

Closes #83

Features

  • Background thread samples CPU, memory (RSS/VMS), and network I/O at a configurable interval
  • Aggregated stats (avg, p50, p90, p99, max) contributed to result.stats and persisted in stats.json
  • Raw samples saved to system_metrics_samples.jsonl for time-series analysis after the fact
  • monitor.plot_samples() for quick time-series visualization
  • load_test_result.plot_results(extra_stats=...) to plot system metrics vs concurrency alongside standard charts
  • Live metrics in the progress bar during runs via the Callback.live_stats() hook
  • Per-process (default) or system-wide monitoring modes
  • New optional dependency: psutil via llmeter[system-metrics]

What's included

  • llmeter/callbacks/system_metrics.py — the callback implementation
  • llmeter/plotting/plotting.pyextra_stats parameter on plot_load_test_results
  • Example notebook: examples/System Metrics Monitoring.ipynb
  • User guide: docs/user_guide/callbacks/system_metrics.md
  • API reference: docs/reference/callbacks/system_metrics.md
  • 11 unit tests, 5 integration tests
  • Docs nav and index updates

Known limitation

_RunConfig.save() uses dataclasses.asdict() which deepcopies callbacks — this crashes if a callback holds non-serializable runtime state (threads, events). Filed as #94; will be resolved by #54 (unified serialization).

acere added 2 commits June 30, 2026 10:36
…I/O tracking

Add an optional callback that monitors system resources during benchmark
runs using psutil. Features:

- Background thread samples CPU, memory (RSS/VMS), and network I/O
- Aggregated stats (avg, p50, p90, p99, max) contributed to Result.stats
- Live metrics displayed in the progress bar during runs
- Stats persist in stats.json across save/load round-trips
- Supports per-process (default) and system-wide monitoring modes
- New optional dependency: psutil via `llmeter[system-metrics]`

Also adds:
- Callback.live_stats() hook for real-time display integration
- "System" column in the live stats display for callback metrics
- Best practices documentation in Callback base class
- User guide documentation (metrics, installation, key concepts)
- API reference page
- 15 unit tests covering serialization, lifecycle, persistence, and reuse

Closes awslabs#83
- Remove _system_metrics_samples monkey-patch on Result (raw samples
  are already accessible via monitor.samples property)
- Remove redundant first-to-last net rate average that was overwritten
  by the per-interval stats computation
@acere
acere force-pushed the feature/system-metrics-monitoring branch from e92e809 to 4551389 Compare June 30, 2026 02:53
@acere
acere marked this pull request as ready for review July 2, 2026 03:50
@acere
acere requested a review from athewsey July 2, 2026 03:50
acere added 2 commits July 3, 2026 08:26
…temMetricsMonitor

- Add example notebook demonstrating system metrics monitoring with
  time-series plots, concurrency correlation, and bottleneck detection
- Add integration tests validating full lifecycle against Bedrock:
  basic usage, save/load persistence, reuse, system-wide mode, and
  higher concurrency scenarios
- Add user guide page for the system metrics callback
- Update mkdocs nav and callbacks index to include new docs
…integration

- Add plot_samples() method to SystemMetricsMonitor for time-series
  visualization of collected metrics within a run
- Add extra_stats parameter to LoadTestResult.plot_results() and
  plot_load_test_results() for plotting arbitrary stat keys vs
  concurrency (e.g. system metrics alongside standard charts)
- Persist raw samples to system_metrics_samples.jsonl in after_run
  when output_path is set, with load_samples() classmethod to restore
- Adopt __llmeter_class__/__llmeter_state__ envelope format for
  save_to_file, compatible with the serialization branch
- Remove __getstate__/__setstate__ — the dataclasses.asdict() deepcopy
  issue in _RunConfig.save() is a library-level concern (see awslabs#94)
- Rewrite example notebook to use result.stats, monitor.plot_samples(),
  and load_test_result.plot_results(extra_stats=...) instead of manual
  plotly code
@acere
acere force-pushed the feature/system-metrics-monitoring branch from 5059f8f to 07fb541 Compare July 3, 2026 02:27
@acere acere changed the title WIP: System metrics monitoring (CPU, memory, network I/O) during benchmark runs System metrics monitoring (CPU, memory, network I/O) during benchmark runs Jul 3, 2026
@athewsey

athewsey commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Only had a very quick skim of this so far but one question came to mind: Since we're not passing huge amounts of data between them and want to prioritize stability of collection, might it make more sense to use a process than a thread for this - in case the main process gets so busy the metric collection thread starts getting starved?

@acere

acere commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Separate process is an option, but realistically the overhead is minimal, and clients thread saturate way before that becomes relevant.

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.

Feature: System metrics monitoring (CPU, memory, network I/O) during benchmark runs

2 participants