main
ply4 git calls253 ms42 KiB2 cachedprotocol v2
134 lines4.5 KiBRaw
1// The harness's own health. A VM pause (the box is snapshotted: dmesg "crng reseeded due to virtual machine fork", 69 of
2// them in the 38 h before 2026-11-10 16:13) or a blocked event loop stops every timer, socket read and probe tick at once;
3// when the process runs again the wall clock (and usually the monotonic clock) has jumped. Requests in flight across such
4// a gap time out on the client, and a probe dwell that stops issuing looks like a starved window. Neither is evidence
5// about the Worker. This module records those gaps so callers can tell a client stall from a product failure.
6import { CLIENT_STALL_MS, CLIENT_TICK_MS } from './baseline.ts'
8/** A gap in the client's own clocks, in wall-clock milliseconds (`from` is the last healthy tick, `to` the first after). */
9export type Stall = {
10 readonly from: number
11 readonly to: number
12 readonly ms: number
15/** What the probe schedule and the smoke read: the gaps seen so far, measured at the call. */
16export type StallSource = {
17 /** Check the clocks now (a resumed loop sees the gap before its next timer fires). Returns the stall it found, or null. */
18 check(): Stall | null
19 /** Every stall that overlaps [from, to]. */
20 during(from: number, to: number): readonly Stall[]
21 /** Milliseconds of [from, to] the client spent stalled. */
22 stalledMs(from: number, to: number): number
25export type ClientClocks = {
26 /** Wall clock, ms. */
27 wall(): number
28 /** Monotonic clock, ms. */
29 mono(): number
32const SYSTEM_CLOCKS: ClientClocks = {
33 wall: () => Date.now(),
34 mono: () => Number(process.hrtime.bigint() / 1_000_000n),
37/**
38 * A gap is a stall when either clock advanced by more than `stallMs` between two checks. Ticks are `tickMs` apart, so a
39 * healthy gap is about `tickMs`; the wall clock catches a VM pause even when the guest's monotonic clock did not advance.
40 */
41export function gapStall(prevWall: number, prevMono: number, wall: number, mono: number, stallMs: number): Stall | null {
42 const gap = Math.max(wall - prevWall, mono - prevMono)
43 if (gap <= stallMs) return null
44 return { from: prevWall, to: prevWall + gap, ms: gap }
47function overlap(stall: Stall, from: number, to: number): number {
48 return Math.max(0, Math.min(stall.to, to) - Math.max(stall.from, from))
51export class ClientHealth implements StallSource {
52 private readonly clocks: ClientClocks
53 private readonly stallMs: number
54 private readonly tickMs: number
55 private prevWall: number
56 private prevMono: number
57 private readonly seen: Stall[] = []
58 private timer: ReturnType<typeof setInterval> | null = null
60 constructor(clocks: ClientClocks = SYSTEM_CLOCKS, stallMs = CLIENT_STALL_MS, tickMs = CLIENT_TICK_MS) {
61 this.clocks = clocks
62 this.stallMs = stallMs
63 this.tickMs = tickMs
64 this.prevWall = clocks.wall()
65 this.prevMono = clocks.mono()
66 }
68 start(): void {
69 if (this.timer !== null) return
70 this.prevWall = this.clocks.wall()
71 this.prevMono = this.clocks.mono()
72 this.timer = setInterval(() => {
73 this.check()
74 }, this.tickMs)
75 this.timer.unref()
76 }
78 stop(): void {
79 if (this.timer === null) return
80 clearInterval(this.timer)
81 this.timer = null
82 }
84 check(): Stall | null {
85 const wall = this.clocks.wall()
86 const mono = this.clocks.mono()
87 const stall = gapStall(this.prevWall, this.prevMono, wall, mono, this.stallMs)
88 this.prevWall = wall
89 this.prevMono = mono
90 if (stall) this.seen.push(stall)
91 return stall
92 }
94 stalls(): readonly Stall[] {
95 return [...this.seen]
96 }
98 during(from: number, to: number): readonly Stall[] {
99 return this.seen.filter(stall => overlap(stall, from, to) > 0)
100 }
102 stalledMs(from: number, to: number): number {
103 return this.seen.reduce((sum, stall) => sum + overlap(stall, from, to), 0)
104 }
107/** A source that never stalls: tests and callers outside a run. */
108export const NO_STALLS: StallSource = {
109 check: () => null,
110 during: () => [],
111 stalledMs: () => 0,
114let active: ClientHealth | null = null
116/** The run's monitor, started by the pipeline. Outside a run this is NO_STALLS. */
117export function clientHealth(): StallSource {
118 return active === null ? NO_STALLS : active
121export function startClientHealth(): ClientHealth {
122 if (active === null) active = new ClientHealth()
123 active.start()
124 return active
127/** Stops the run's monitor and returns every stall it saw. */
128export function stopClientHealth(): readonly Stall[] {
129 if (active === null) return []
130 active.stop()
131 const seen = active.stalls()
132 active = null
133 return seen
Diagnostics4 git calls · 253 ms
CallStatusSizeTime0253 ms
discover200152 B4 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
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 · hit4 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
git.response.bytes=145
git.response.cache=HIT
git.response.duration_ms=4
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 · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=246
git.response.bytes=41349
git.response.cache=HIT
git.response.duration_ms=3
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=61
Open pack map
fetch2001.7 KiB246 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1771
git.response.cache=MISS
git.response.duration_ms=246
git.fetch.wants=b948bf8f8d03afca2b402f62a8cbb641d4968f69
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=1771
git.pkt.payload.max=1750
git.sideband.band1.bytes=1749
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
a5e330840cb418aa
Request
c1522c97…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format