Artifactspublic-v0

ply

main
ply4 git calls36 ms40 KiB3 cachedprotocol v2
124 lines5.4 KiBRaw
1// Input sources for the memory cells (test/stream/cell.mjs), as plain iterator objects instead of generators (#249).
2//
3// A suspended generator on node 22 (V8 12.4) keeps every register of its frame, so the piece it yielded last, and the
4// `{ value }` of an inner for-of, stay reachable after the consumer dropped them. A heap snapshot at the peak of the
5// scan-work cell found three such 16 KiB pieces retained by the `parameters_and_registers` of `sealed`, `body` and
6// `storedMember` (49,152 B: node 22's whole overage over node 24 there); node 24 (V8 13.6) keeps none. These sources
7// keep only their position between calls, so a cell measures the same bytes on both: the piece being fed is the
8// caller's, and nothing older is reachable from the source.
9//
10// Each source is an iterator (and iterable) over Uint8Array pieces; `step` returns the next piece or END.
11import crypto from 'node:crypto';
13export const END = Symbol('end');
14const DONE = Object.freeze({ done: true, value: undefined });
16export function source(step) {
17 return {
18 next() { const v = step(); return v === END ? DONE : { done: false, value: v }; },
19 [Symbol.iterator]() { return this; },
20 };
22// The same source as an AsyncIterable, without an async frame of its own to hold a piece.
23export function asAsync(src) {
24 return { [Symbol.asyncIterator]() { return { next: () => Promise.resolve(src.next()) }; } };
26// One piece, dropped once it is handed over.
27export const once = piece => { let held = [piece]; return source(() => { const out = held.length > 0 ? held[0] : END; held = []; return out; }); };
28// The sources made by `makers`, one after another; only the current one is held.
29export function seq(makers) {
30 let i = 0, cur = makers.length > 0 ? makers[0]() : once(new Uint8Array(0));
31 return source(() => {
32 for (;;) {
33 const n = cur.next();
34 if (!n.done) return n.value;
35 i += 1;
36 if (i >= makers.length) return END;
37 cur = makers[i]();
38 }
39 });
41// `count` sources from `make(i)`, one after another.
42export function repeat(count, make) {
43 let i = 0, cur = null;
44 return source(() => {
45 for (;;) {
46 if (cur !== null) { const n = cur.next(); if (!n.done) return n.value; cur = null; }
47 if (i >= count) return END;
48 cur = make(i);
49 i += 1;
50 }
51 });
53// The pieces of `src`, then the SHA-1 of them (a pack trailer).
54export function sealed(src) {
55 const sha = crypto.createHash('sha1');
56 let open = true;
57 return source(() => {
58 if (!open) return END;
59 const n = src.next();
60 if (!n.done) { sha.update(n.value); return n.value; }
61 open = false;
62 return new Uint8Array(sha.digest());
63 });
65// `src` regrouped into `size`-byte chunks, as a transport hands a body over. The chunk being filled is held here
66// until it is full: one chunk, by design.
67export function chunked(src, size) {
68 let piece = null, off = 0, ended = false;
69 return source(() => {
70 if (ended) return END;
71 const buf = new Uint8Array(size);
72 let at = 0;
73 while (at < size) {
74 if (piece === null || off === piece.length) {
75 const n = src.next();
76 if (n.done) { ended = true; piece = null; return at > 0 ? buf.subarray(0, at) : END; }
77 piece = n.value; off = 0;
78 }
79 const k = Math.min(size - at, piece.length - off);
80 buf.set(piece.subarray(off, off + k), at);
81 at += k; off += k;
82 }
83 if (off === piece.length) piece = null;
84 return buf;
85 });
87// `src` framed into band-1 pkt-lines of `room` payload bytes, after a `packfile` line and before a flush: a v2 fetch
88// response as it is read. Holds the unframed remainder (under one frame).
89export function framed(src, room) {
90 const te = new TextEncoder();
91 const frame = payload => { const f = new Uint8Array(4 + payload.length); f.set(te.encode((payload.length + 4).toString(16).padStart(4, '0'))); f.set(payload, 4); return f; };
92 let state = 'head', pending = new Uint8Array(0);
93 const band1 = bytes => { const p = new Uint8Array(1 + bytes.length); p[0] = 1; p.set(bytes, 1); return frame(p); };
94 return source(() => {
95 for (;;) {
96 switch (state) {
97 case 'head': state = 'body'; return frame(te.encode('packfile\n'));
98 case 'body': {
99 if (pending.length >= room) { const out = band1(pending.subarray(0, room)); pending = pending.slice(room); return out; }
100 const n = src.next();
101 if (n.done) { state = 'tail'; continue; }
102 const joined = new Uint8Array(pending.length + n.value.length);
103 joined.set(pending); joined.set(n.value, pending.length);
104 pending = joined;
105 continue;
106 }
107 case 'tail': { state = 'flush'; if (pending.length === 0) continue; const out = band1(pending); pending = new Uint8Array(0); return out; }
108 case 'flush': state = 'end'; return te.encode('0000');
109 default: return END;
110 }
111 }
112 });
114// Read `stream` to its end, handing each item to `each`, from read callbacks rather than an async function: a `for
115// await` loop's frame keeps the item before the current one in a register while it waits for the next (a heap snapshot
116// of the pkt-iter cell found one 65,516 B frame held so on node 24 too), and that is the consumer's memory, not the
117// adapter's under test.
118export function drain(stream, each) {
119 const reader = stream.getReader();
120 return new Promise((resolve, reject) => {
121 const step = () => reader.read().then(r => { if (r.done) { resolve(); return; } each(r.value); step(); }, reject);
122 step();
123 });
Diagnostics4 git calls · 36 ms
CallStatusSizeTime036 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 · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=145
git.response.cache=HIT
git.response.duration_ms=2
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 1020038 KiB · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=38434
git.response.cache=HIT
git.response.duration_ms=4
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=19912563f540228593df0c489082e5e2508e21e4
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=38434
git.pkt.payload.max=38339
git.sideband.band1.bytes=38338
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=63
git.pack.bytes=38338
git.pack.ofs_delta=0
git.pack.ref_delta=8
git.pack.chain.max=8
git.pack.trailer=0bc36ab7adf82d3109177f11f1ea93f1ce071f77
git.pack.full=55
Open pack map
fetch2002.2 KiB · hit30 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=30
git.response.bytes=2231
git.response.cache=HIT
git.response.duration_ms=30
git.fetch.wants=aa3c848c26e3ad3beeda085ecd694b57b35a8b0d
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=2231
git.pkt.payload.max=2210
git.sideband.band1.bytes=2209
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.git
Ref
refs/heads/main
Commit
19912563f540228593df0c489082e5e2508e21e4
cf-ray
a5e2fa490ffe90c0
Request
3e7267a1…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format