main
1// The protocol waterfall: one row per exchange, on one time axis from the start of the run. Each bar is the wait for
2// the server's headers (light) then the answer's body (dark); a row with no answer is hatched to where it gave up. Rows
3// are grouped by phase (seed, each step, judge, cleanup) and coloured by channel (main is ply under test, side the
4// other writer, judge the read-back). A fault is marked on its row. Pure: exchanges in, inline SVG out.
5import { renderRay } from '../rays.ts';
6import { html, type Html } from './html.ts';
7import type { Exchange, Phase } from './recorder.ts';
9const WIDTH = 1100;
10const LABEL = 420;
11const ROW = 22;
12const BAR = 12;
13const TOP = 28;
14const TICKS = 6;
15const PAD = 12;
17export const phaseName = (p: Phase): string => {
18 switch (p.tag) {
19 case 'seed': return 'seed';
20 case 'step': return `step ${p.index}`;
21 case 'judge': return 'judge';
22 case 'cleanup': return 'cleanup';
23 }
24};
25export const kb = (n: number): string => (n < 1024 ? `${n} B` : n < 1024 * 1024 ? `${(n / 1024).toFixed(1)} KiB` : `${(n / 1024 / 1024).toFixed(2)} MiB`);
26export const shortKind = (x: Exchange): string => {
27 switch (x.kind) {
28 case 'advertise-upload': return 'GET info/refs upload-pack';
29 case 'advertise-receive': return 'GET info/refs receive-pack';
30 case 'ls-refs': return 'POST upload-pack ls-refs';
31 case 'fetch': return 'POST upload-pack fetch';
32 case 'receive-pack': return 'POST receive-pack';
33 case 'other': return `${x.method} ${x.path.split('?')[0] || ''}`;
34 }
35};
36export const answerText = (x: Exchange): string => (x.answer.tag === 'http' ? String(x.answer.status) : 'no answer');
38export function waterfall(xs: readonly Exchange[]): Html {
39 const total = Math.max(1, ...xs.map(x => x.endMs));
40 const plot = WIDTH - LABEL - PAD;
41 const at = (ms: number): number => LABEL + (ms / total) * plot;
42 const height = TOP + xs.length * ROW + PAD;
43 const ticks = Array.from({ length: TICKS + 1 }, (_, i) => Math.round((total * i) / TICKS));
44 let last = '';
45 const rows = xs.map((x, r) => {
46 const y = TOP + r * ROW;
47 const ph = phaseName(x.phase);
48 const band = ph === last ? null : html`<line class="wf-phase" x1="0" x2="${WIDTH}" y1="${y}" y2="${y}"/><text class="wf-phase-label" x="${WIDTH - PAD}" y="${y + 11}" text-anchor="end">${ph}</text>`;
49 last = ph;
50 const x0 = at(x.startMs);
51 const xh = x.headersMs === null ? at(x.endMs) : at(x.headersMs);
52 const x1 = Math.max(at(x.endMs), xh + 1);
53 const wait = html`<rect class="wf-wait wf-${x.channel}" x="${x0.toFixed(1)}" y="${y + 5}" width="${Math.max(1, xh - x0).toFixed(1)}" height="${BAR}"/>`;
54 const body = x.headersMs === null ? null : html`<rect class="wf-body wf-${x.channel}" x="${xh.toFixed(1)}" y="${y + 5}" width="${Math.max(1, x1 - xh).toFixed(1)}" height="${BAR}"/>`;
55 const fault = x.applied === null ? null : html`<text class="wf-fault" x="${(x1 + 4).toFixed(1)}" y="${y + 15}">⚡ ${x.applied.tag}</text>`;
56 const failed = x.answer.tag === 'no-response' ? ' wf-failed' : '';
57 const label = `#${x.i} ${x.channel} ${shortKind(x)} ${answerText(x)} ↑${kb(x.requestBytes)} ↓${kb(x.responseBytes)}`;
58 const ms = `${Math.round(x.endMs - x.startMs)} ms · ray ${renderRay(x.cfRay)}`;
59 return html`${band}<a href="#x${x.i}"><g class="wf-row${failed}"><title>${label} · ${ms}</title><text class="wf-label" x="4" y="${y + 15}">${label}</text>${wait}${body}${fault}<text class="wf-ms" x="${(x1 + 4).toFixed(1)}" y="${y + (x.applied === null ? 15 : 26)}">${x.applied === null ? `${Math.round(x.endMs - x.startMs)} ms` : null}</text></g></a>`;
60 });
61 const axis = ticks.map(t => html`<line class="wf-tick" x1="${at(t).toFixed(1)}" x2="${at(t).toFixed(1)}" y1="${TOP - 6}" y2="${height - PAD}"/><text class="wf-tick-label" x="${at(t).toFixed(1)}" y="${TOP - 10}" text-anchor="middle">${t} ms</text>`);
62 return html`<svg class="waterfall" role="img" aria-label="protocol waterfall, ${xs.length} exchanges over ${total} ms" viewBox="0 0 ${WIDTH} ${height}" width="${WIDTH}" height="${height}" xmlns="http://www.w3.org/2000/svg">${axis}${rows}</svg>`;
63}
Diagnostics4 git calls · 315 ms
CallStatusSizeTime0315 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200145 B · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=145 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=145 git.pkt.payload.max=76 git.ls_refs.count=2 git.ls_refs.head=refs/heads/main
fetchblob:none · deepen 1020040 KiB · hit7 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=41349 git.response.cache=HIT git.response.duration_ms=7 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=526b305930b8ef382f2d7a1f9c0238730a585921 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=6 git.pkt.data=4 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=41349 git.pkt.payload.max=41254 git.sideband.band1.bytes=41253 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=61 git.pack.bytes=41253 git.pack.ofs_delta=0 git.pack.ref_delta=0 git.pack.chain.max=0 git.pack.trailer=ab60efef4b7243678c75de64a4386986ee885c1c git.pack.full=61Open pack map
fetch2001.7 KiB305 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=305 git.response.bytes=1783 git.response.cache=MISS git.response.duration_ms=305 git.fetch.wants=6b15329d726c2f420fb8ba22887f3967ea69772f git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1783 git.pkt.payload.max=1762 git.sideband.band1.bytes=1761 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply-web.git
- Ref
- refs/heads/main
- Commit
- 526b305930b8ef382f2d7a1f9c0238730a585921
- cf-ray
- a5e31c053f668682
- Request
- 96c6a143…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format