Skip to content

Conversation

@griffinmilsap
Copy link
Collaborator

Profiling Feature Overview

  • Adds sliding-window profiling for publishers and channels to surface throughput, byte rate, and backpressure/processing latency without extra serialization hops.
  • GraphServer can now fan out PROFILE requests over existing control links and aggregate JSON snapshots across all connected publishers/channels.

Key Details

  • Telemetry primitives in src/ezmsg/core/profiling.py track rolling counts/bytes and buffer lease durations; Backpressure optionally emits timings per client.
  • Publishers (src/ezmsg/core/pubclient.py) record msg/byte rates and backpressure lease timing; channels (src/ezmsg/core/messagechannel.py) capture per-subscriber processing time and last transport mode (local|shm|tcp), plus subscriber handles for readability.
  • GraphServer (src/ezmsg/core/graphserver.py) understands new protocol commands PROFILE/PROFILE_DATA (src/ezmsg/core/netprotocol.py), gathers profiles, and exposes them via GraphService.profile(window_s).
  • CLI support: python -m ezmsg.core profile --window 2.0 prints aggregated JSON, including per-publisher/channel stats.
  • Subscribers may pass handle= when creating to label profiles; defaults to the topic/address.

Why It Matters

  • Gives per-process, per-stream visibility into bottlenecks: time from backpressure lease→free (upper bound on publish rate) and per-subscriber processing latency inside ez.subscriber callbacks.
  • Minimal overhead via small time windows (~2s default) and reuse of existing graph connections; no extra message serialization.

Usage Example

# Collect a 2s snapshot from a running graph
ezmsg profile --window 2.0

# Programmatic
from ezmsg.core.graphserver import GraphService
profile = await GraphService().profile(2.0)

Notable Outputs

  • Publisher: total/window messages & bytes, message/byte rates, backpressure avg/max (ms), in-flight leases.
  • Channel: per-subscriber avg/max processing (ms), samples, message rate, in-flight leases, transport mode, subscriber handle/id.

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