Artifactspublic-v0

ply

main
ply4 git calls324 ms39 KiB2 cachedprotocol v2
72 lines4.4 KiBRaw
1// Delta instructions, encoded (gitformat-pack "Deltified representation"): the size varint, copy and insert opcodes, a
2// delta from its instructions, and the structural splice the edit pipeline sends. A leaf: pack.ts (the pack builder)
3// and packresolve.ts (makeDelta) both import it, and it imports neither.
4import { concat } from './bytes.js';
5import {
6 BYTE_MASK, OBJ_SIZE_NEXT_MASK, OBJ_CONTINUE, OBJ_SIZE_NEXT_BASE,
7 DELTA_COPY, DELTA_COPY_MAX, DELTA_INSERT_MAX, DELTA_OFF_SHIFT,
8 DELTA_COPY_OFF1, DELTA_COPY_OFF2, DELTA_COPY_OFF3, DELTA_COPY_OFF4,
9 DELTA_COPY_LEN1, DELTA_COPY_LEN2, DELTA_COPY_LEN3,
10} from './format.js';
12export function encodeVarint(n: number): Uint8Array { // delta header style: 7-bit LE groups
13 const out: number[] = [];
14 let rest = n;
15 do { let b = rest & OBJ_SIZE_NEXT_MASK; rest = Math.floor(rest / OBJ_SIZE_NEXT_BASE); if (rest > 0) b |= OBJ_CONTINUE; out.push(b); } while (rest > 0);
16 return Uint8Array.from(out);
18export const copyOp = (off: number, len: number): Uint8Array => {
19 let op = DELTA_COPY;
20 const b: number[] = [];
21 let o = off;
22 let l = len === DELTA_COPY_MAX ? 0 : len;
23 if (o & BYTE_MASK) { op |= DELTA_COPY_OFF1; b.push(o & BYTE_MASK); } o >>>= DELTA_OFF_SHIFT;
24 if (o & BYTE_MASK) { op |= DELTA_COPY_OFF2; b.push(o & BYTE_MASK); } o >>>= DELTA_OFF_SHIFT;
25 if (o & BYTE_MASK) { op |= DELTA_COPY_OFF3; b.push(o & BYTE_MASK); } o >>>= DELTA_OFF_SHIFT;
26 if (o & BYTE_MASK) { op |= DELTA_COPY_OFF4; b.push(o & BYTE_MASK); }
27 if (l & BYTE_MASK) { op |= DELTA_COPY_LEN1; b.push(l & BYTE_MASK); } l >>>= DELTA_OFF_SHIFT;
28 if (l & BYTE_MASK) { op |= DELTA_COPY_LEN2; b.push(l & BYTE_MASK); } l >>>= DELTA_OFF_SHIFT;
29 if (l & BYTE_MASK) { op |= DELTA_COPY_LEN3; b.push(l & BYTE_MASK); }
30 return Uint8Array.of(op, ...b);
31};
32export const copyOps = (off: number, len: number): Uint8Array[] => {
33 const parts: Uint8Array[] = [];
34 let o = off;
35 let left = len;
36 while (left > 0) { const n = Math.min(left, DELTA_COPY_MAX); parts.push(copyOp(o, n)); o += n; left -= n; }
37 return parts;
38};
39export const insertOps = (bytes: Uint8Array): Uint8Array[] => {
40 const parts: Uint8Array[] = [];
41 for (let i = 0; i < bytes.length; i += DELTA_INSERT_MAX) {
42 const chunk = bytes.subarray(i, Math.min(i + DELTA_INSERT_MAX, bytes.length));
43 parts.push(Uint8Array.of(chunk.length), chunk);
44 }
45 return parts;
46};
48// One delta instruction (gitformat-pack "Deltified representation"): copy `len` bytes of the source from `off`, or insert
49// the literal bytes. A copy longer than DELTA_COPY_MAX or an insert longer than DELTA_INSERT_MAX is one instruction
50// here and as many opcodes as it takes on the wire (encodeDeltaOps).
51export type DeltaOp = { readonly tag: 'copy'; readonly off: number; readonly len: number } | { readonly tag: 'insert'; readonly bytes: Uint8Array };
52// A delta's bytes from its sizes and instructions.
53export function encodeDeltaOps(srcSize: number, dstSize: number, ops: readonly DeltaOp[]): Uint8Array<ArrayBuffer> {
54 const parts = [encodeVarint(srcSize), encodeVarint(dstSize)];
55 for (const op of ops) parts.push(...(op.tag === 'copy' ? copyOps(op.off, op.len) : insertOps(op.bytes)));
56 return concat(parts);
59// Structural delta: base with [off, off+oldLen) replaced by `insert`. Pure; needs no base bytes. The instructions are a
60// copy of the prefix, the insert, and a copy of the tail, each only when it is not empty.
61export type Splice = { readonly baseLen: number; readonly off: number; readonly oldLen: number; readonly insert: Uint8Array };
62export type SplicedDelta = { readonly delta: Uint8Array<ArrayBuffer>; readonly resultLen: number; readonly ops: { readonly copy: number; readonly insert: number }; readonly program: readonly DeltaOp[] };
63export function spliceDelta({ baseLen, off, oldLen, insert }: Splice): SplicedDelta {
64 const resultLen = baseLen - oldLen + insert.length;
65 const tail = baseLen - off - oldLen;
66 const program: DeltaOp[] = [];
67 if (off > 0) program.push({ tag: 'copy', off: 0, len: off });
68 if (insert.length > 0) program.push({ tag: 'insert', bytes: insert });
69 if (tail > 0) program.push({ tag: 'copy', off: off + oldLen, len: tail });
70 // Stryker disable next-line EqualityOperator,ConditionalExpression: an empty prefix or tail is Math.ceil(0) = 0 copies either way
71 return { delta: encodeDeltaOps(baseLen, resultLen, program), resultLen, program, ops: { copy: (off > 0 ? Math.ceil(off / DELTA_COPY_MAX) : 0) + (tail > 0 ? Math.ceil(tail / DELTA_COPY_MAX) : 0), insert: Math.ceil(insert.length / DELTA_INSERT_MAX) } };
Diagnostics4 git calls · 324 ms
CallStatusSizeTime0324 ms
discover200152 B3 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 · 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 1020038 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=318
git.response.bytes=38434
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=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
fetch2001.6 KiB318 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1593
git.response.cache=MISS
git.response.duration_ms=318
git.fetch.wants=344c19f04fff798075ca4f794525b2b66f99e1a2
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=1593
git.pkt.payload.max=1572
git.sideband.band1.bytes=1571
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
a5e2fe9ada43f3c9
Request
cdffb669…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format