Skip to content

sim(network): expose send-window occupancy as metrics #205

Closed as not planned

Description

@PierreZ

Follow-up to #202, which deliberately added no metrics.

Why

Each stream direction now carries an exact accounting: outstanding = queued + in_flight + unread_at_peer, bounded by tcp_send_window_bytes, plus how long a writer sits parked on a full window. That is precisely the "queue is filling, reader is falling behind, writer is stalled" signal the metastability work wants to see in queue/busyness metrics, and today it is only reachable through SimWorld::outstanding_send_bytes and friends from a test.

Requested

Publish, per connection direction (or aggregated per process IP, whichever the metrics architecture keys on), through the existing app-metrics path the runner already fills into SimulationMetrics::app_series:

  • net_send_window_bytes (capacity, gauge);
  • net_outstanding_bytes (gauge), ideally split queued / in_flight / unread_at_peer;
  • net_writer_blocked (gauge, 0/1) or a cumulative net_writer_blocked_ns, sampled from the send-window waiter registry;
  • optionally net_in_flight_held (a partition is freezing this direction).

Constraints

  • Observation only: sampling must draw no randomness, register no wakers, and must not change when events run (no scheduler-driven sampling that adds events to the timeline, which would shift seeds).
  • Cheap: O(1) per sample from the fields already kept on ConnectionState; do not walk in_flight or send_buffer on every step.
  • The accounting must stay owned by the engine; metrics read it, never maintain a second copy.

Acceptance

  • The tests/flow_control.rs campaign (streamer into a slow reader with a 4 KiB window) shows net_outstanding_bytes pinned at the window and net_writer_blocked at 1 while the reader sleeps, and both dropping when it reads.
  • check_determinism stays green with metrics enabled.

Activity

  1. PierreZ commented on Nov 19, 2026

    @PierreZ
    OwnerAuthor

    Closing: this issue served the old paros metastability work, which the paros rework removed (archive tag v0.2.0-alpha.1). No current user asks for send-window metrics. Reopen it if a user needs them.


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementlatersim-network

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions