Skip to content

RTT-aware mux - #5405

Draft
crocodile-dentist wants to merge 17 commits into
mainfrom
mw/rtt-mux
Draft

RTT-aware mux#5405
crocodile-dentist wants to merge 17 commits into
mainfrom
mw/rtt-mux

Conversation

@crocodile-dentist

@crocodile-dentist crocodile-dentist commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description

This patch introduces echo-cookie rtt sampling mechanism into the Mux.

Checklist

Quality

  • Commit sequence makes sense and have useful messages, see ref.
  • New tests are added and existing tests are updated.
  • Self-reviewed the PR.

Maintenance

  • Linked an issue or added the PR to the current sprint of ouroboros-network project.
  • Added labels.
  • Updated changelog files.
  • The documentation has been properly updated, see ref.

These modules provide a fingertree-backed sliding window with fixed
element count. The fingertree backend caches a user-supplied monoidal measure
`v` which updates incrementally as elements are added and evicted, which
allows for constant time lookup of its value regardless of window
size.

The Window.Count module exposes a public API, and the private internal
implementation is exposed by the Internal.Count module without any
guarantees that it stays compatible between any releases.

The Measures module exposes some common and practical prebuilt
measures.
These modules keep samples within a configured duration of the newest
sample's timestamp. These variants abstract over the timestamp type
via the 'TimeLike' class, which have two implementations defined:

- `UTCTime` / `NominalDiffTime` (wall-clock, from `time`)
- `Time` / `DiffTime` (monotonic, from `io-classes:si-timers`)

Monotonic is preferred when sliding-window correctness must not be
perturbed by NTP corrections or wall-clock jumps; wall-clock fits
data that already carries `UTCTime` timestamps.
These modules expose sliding windows backed by an approximate t-digest
measure, which permit efficient computations of quantiles in bounded memory.
These expose some combinators which allow for summarising rolling
statistics across a long stream in constant memory.
Introduces new wire format in the Mux codec and some surface types.

Replace the single Word32 mhTimestamp with two Word16-sized fields
mhSendCookie and mhEchoCookie.

New `PeerRTT` type, threaded into `ExpandedInitiatorContext` and
`ResponderContext` to expose eventually at application level.

todo: tracing, deltaq, integration, tests/benchmarks

rtt
- muxer and demuxer accept RTTState
- the muxer mints a new cookie (or re-uses one) per the policy, and
  processSingleWanton echoes the last send cookie we received from
  our peer (provided by the demuxer).
- the demuxer in addition to the previous activity also prunes
  our cookie jar so it stays within bounded space.
To generate our cookies and prevent forgery attacks, we thread a PRNG
from the top level, through connection handler, and into our mux.
Adds MiniProtocolNum field so downstream trace consumers can bucket
or filter per mini-protocol. This is the prerequisite for either
for filtering out some protocols contributions, or bucketing them
and pooling the aggregate.

Add TraceRecvBurstSDU MiniProtocolNum Word16 DiffTime which allows
us to recover burst-SDU per-byte cost via a separate through-origin
estimator.
@crocodile-dentist crocodile-dentist self-assigned this Jul 16, 2026
@crocodile-dentist
crocodile-dentist requested a review from a team as a code owner July 16, 2026 14:04
@github-project-automation github-project-automation Bot moved this to In Progress in Ouroboros Network Jul 16, 2026
@crocodile-dentist
crocodile-dentist marked this pull request as draft July 16, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant