Expand description
A forge to measure against, and the client that measures it.
The cost this instrument exists for is a cost to a PROCESS, so the
measurement is ps -o time= on a forge’s own CPU time, sampled around a
window of raw websocket work and charged against an idle arm of the same
length. That needs a forge the instrument can watch from outside without
disturbing the one somebody is using, and it needs the client in another
process - a client sharing this one would put its own decoding of a 28 MB
frame inside the number.
Two roles, and the server is the default:
cargo build --release -p forge-server --features testing --bin forge-fold-cost
forge-fold-cost --transcript /tmp/hub.jsonl --breakdown # serve
forge-fold-cost --measure --pid <that pid> --arm refresh # measureBuild it in release. The profile moves the headline figure by 7x -
the same transcript and the same command read 1,413 ms for a read in a
debug build and 204 ms in a release one - so every row says which build
its figures came from. That is the MEASURING CLIENT’s build, and the
server’s is a separate thing a row cannot report: see client_profile.
Every arm prints its own denominator - the frames it read, the bytes they carried, the turns and messages they held - because an arm that reported a cost without them could not be told from one that had stopped seeing the conversation at all. The check that matters is running two arms of the same name against a server before and after a change and finding the bytes identical: that is what says the instrument was still watching the conversation rather than having gone quiet.
And each arm sends what its name says, which is not a detail. A
refresh is an unsubscribe and a subscribe, because that is what the
client sends on every update for the open seat; a subscribe carries its
own connect; an idle arm does nothing at all. An arm that sent a more
and called itself a refresh would report on a path the client never takes.
The seat’s conversation is the file --transcript names, written in under
the session id the fixture seeds. Nothing here synthesises one: a fold over
invented rows is a fold over rows whose size is a property of this file
rather than of a conversation, which is the one thing a measurement of
per-byte cost cannot afford.
Re-exports§
pub(crate) use Path;🔒pub(crate) use PathBuf;🔒pub(crate) use std::sync::Arc;🔒pub(crate) use Duration;🔒pub(crate) use Instant;🔒pub(crate) use clap::Parser;🔒pub(crate) use forge_primitives::SessionSlot;🔒pub(crate) use forge_server::surface::ViewSurface;🔒pub(crate) use forge_server::testing::Fleet;🔒pub(crate) use forge_server::transport::TransportState;🔒pub(crate) use ClientMessage;🔒pub(crate) use ServerMessage;🔒pub(crate) use Subject;🔒pub(crate) use forge_server::transport::serve;🔒pub(crate) use SinkExt;🔒pub(crate) use StreamExt;🔒pub(crate) use tokio_tungstenite::tungstenite::Message;🔒
Structs§
Enums§
- Arm 🔒
- The workload an arm sends, as a closed set.
Functions§
- a_
socket 🔒 - A socket with nothing asked on it yet, which the greeting has arrived on.
- attach 🔒
- Attach to the seat and take the answer, which is what a connect costs.
- breakdown 🔒
- Where the CONVERSATION’s time goes inside one request, taken once before any client attaches: a fix that removes one of these three is worth what that one costs and no more.
- count 🔒
- The messages a page or a snapshot carried, counted the way a client draws them: one per turn, plus the frames each turn holds.
- cpu_
seconds 🔒 - Another process’s CPU time, at
ps’s 10 ms resolution. - main 🔒
- measure 🔒
- parse_
cpu_ 🔒time [[dd-]hh:]mm:ss.ccas seconds, orNonewhen it is not that.- profile 🔒
- What this run was built as, which moves the headline figure by 7x.
- read_
one 🔒 - The next answer on the socket, counted into
arm. - rss 🔒
- This process’s resident set, which is what holding a conversation costs.
- serve_
one 🔒 - work 🔒
- Ask on a connection already open, reading every frame and counting it.