GitHubivarvong
ply
main
1// Random trees for the differential test of parseTree (#207): src/objects.ts against the parser before it
2// (test/oracle/parsetree-ref.ts). Shared by test/parsetree.test.js and test/fuzz/parsetree.mjs.
3import { parseTree } from '../src/objects.js';
4import { parseTreeRef } from './oracle/parsetree-ref.ts';
5import { randomName, SPELLINGS } from './dotnames-corpus.js';
7const enc = s => new TextEncoder().encode(s);
8// Modes git writes, ones it canonicalizes, and ones fsck refuses (empty, zero-padded, not octal, not ASCII)
9const MODES = ['100644', '100755', '120000', '40000', '160000', '100664', '100700', '40755', '1', '7', '777777', '140000', '1040000',
10 '7100644', '300644', '777777777777777777777777040000', '0', '040000', '00', '', '8', 'g7', '1006 44', '10064é', '100644', '-1', '4000a'];
11const WORDS = ['a', 'b', 'd', 'd.x', 'd0', 'D', 'src', 'README.md', 'é', 'é', 'a/b', '.', '..', '', 'x'.repeat(4097), 'x'.repeat(4096), 'README'];
12const sortKey = e => [...e.name, ...(e.dir ? [0x2f] : [])];
13const cmp = (a, b) => { const x = sortKey(a), y = sortKey(b); for (let i = 0; i < Math.min(x.length, y.length); i++) if (x[i] !== y[i]) return x[i] - y[i]; return x.length - y.length; };
15export function randomTree(r) {
16 const n = r.int(4) === 0 ? r.int(3) : 1 + r.int(12);
17 const entries = [];
18 for (let i = 0; i < n; i++) {
19 const mode = r.int(5) === 0 ? r.pick(MODES) : r.pick(MODES.slice(0, 5));
20 const k = r.int(10);
21 const name = k < 4 ? enc(r.pick(WORDS)) : k < 6 ? randomName(r) : k < 7 ? enc(r.pick(SPELLINGS)) : enc(`f${r.int(1000)}`);
22 const oid = new Uint8Array(20);
23 if (r.int(20) !== 0) for (let j = 0; j < 20; j++) oid[j] = r.int(256);
24 const low = Number.parseInt(mode.slice(-6), 8) & 0xffff;
25 entries.push({ mode: enc(mode), name, oid, dir: /^[0-7]+$/.test(mode) && (low & 0o170000) === 0o40000 });
26 }
27 if (r.int(4) !== 0) entries.sort(cmp);
28 if (r.int(10) === 0 && entries.length > 0) entries.push(entries[r.int(entries.length)]);
29 const parts = [];
30 for (const e of entries) parts.push(...e.mode, ...(r.int(50) === 0 ? [] : [0x20]), ...e.name, ...(r.int(50) === 0 ? [] : [0]), ...e.oid);
31 let bytes = Uint8Array.from(parts);
32 if (r.int(15) === 0 && bytes.length > 0) bytes = bytes.subarray(0, r.int(bytes.length));
33 const limits = r.int(8) === 0 ? { maxTreeEntries: r.int(6) } : {};
34 return { bytes, limits };
35}
37const view = r => (r.ok ? { ok: true, entries: r.value.map(e => ({ mode: e.mode, name: e.name, oid: e.oid, oidOffset: e.oidOffset, entryOffset: e.entryOffset })) } : { ok: false, code: r.error.code, message: r.error.message });
38// The first tree on which the two parsers differ (a repro), or null; counts accepted and refused trees
39export function judgeTrees(trees, stats = { n: 0, accepted: 0, refused: {} }) {
40 for (const { bytes, limits } of trees) {
41 const want = view(parseTreeRef(bytes, limits));
42 const got = view(parseTree(bytes, limits));
43 stats.n++;
44 if (want.ok) stats.accepted++; else stats.refused[want.message.replace(/".*"/u, '"…"').replace(/\d+/gu, 'N')] = (stats.refused[want.message.replace(/".*"/u, '"…"').replace(/\d+/gu, 'N')] ?? 0) + 1;
45 if (JSON.stringify(want) !== JSON.stringify(got)) return { hex: Buffer.from(bytes).toString('hex'), limits, want, got };
46 }
47 return null;
48}
Diagnostics8 git calls · 181 ms
CallStatusSizeTime0181 ms
discover200191 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=191 git.server.agent=git/github-9922ec520325-Linux git.server.object_format=sha1 git.server.caps=agent ls-refs fetch server-option object-format git.server.fetch=shallow wait-for-done filter git.protocol.version=2 git.pkt.frames=9 git.pkt.data=7 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=191 git.pkt.payload.max=36
ls-refs20012 KiB87 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=83 git.response.bytes=11990 git.response.cache=EXPIRED git.response.duration_ms=87 git.protocol.version=2 git.pkt.frames=152 git.pkt.data=151 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=11990 git.pkt.payload.max=122 git.ls_refs.count=151 git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 1200347 B · hit3 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=347 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=19912563f540228593df0c489082e5e2508e21e4 git.fetch.haves.count=0 git.fetch.deepen=1 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=347 git.pkt.payload.max=247 git.sideband.band1.bytes=247 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=247 git.pack.trailer=4b72f39b5ea57c5ae3009f90b53e3a6a155093e7Open pack map
fetchtree:0 · deepen 102004.2 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=68 git.response.bytes=4347 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 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=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=4347 git.pkt.payload.max=4247 git.sideband.band1.bytes=4247 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=10 git.pack.bytes=4247 git.pack.ofs_delta=0 git.pack.ref_delta=0 git.pack.chain.max=0 git.pack.trailer=a6caf8e129bea82c9bae4cbc7c130c9205add400 git.pack.full=10Open pack map
fetchcombine:blob:none+tree:2 · deepen 1200—68 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.cache=BYPASS git.fetch.filter=combine:blob:none+tree:2 git.fetch.wants=19912563f540228593df0c489082e5e2508e21e4 git.fetch.haves.count=0 git.fetch.deepen=1 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 error.type=remote_error error=remote: filter 'combine' not supported
fetchtree:0200919 B · hit2 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=919 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=800d30ba8923860bfc460ca884b7f9ba22083588 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=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=919 git.pkt.payload.max=892 git.sideband.band1.bytes=892 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=892 git.pack.trailer=5323b9266eea5ded637285d1c5320699f12be76eOpen pack map
fetchtree:02005.6 KiB · hit3 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=5724 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=58fabb6768b3f737ee9cd8bac647bdc27405fb4d 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=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=5724 git.pkt.payload.max=5697 git.sideband.band1.bytes=5697 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=5697 git.pack.trailer=be7e0453974a5fe832f9065a33bb7e3434c10e9bOpen pack map
fetch2001.5 KiB · hit21 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=21 git.response.bytes=1532 git.response.cache=HIT git.response.duration_ms=21 git.fetch.wants=3f1a74f098d1db9bf3139f4cd479d63d4bc29e5e 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=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1532 git.pkt.payload.max=1505 git.sideband.band1.bytes=1505 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://github.com/ivarvong/ply
- Ref
- refs/heads/main
- Commit
- 19912563f540228593df0c489082e5e2508e21e4
- cf-ray
- a5e164ccf825b1a9
- Request
- f665b599…
- Protocol
- v2 · sha1
- Agent
- git/github-9922ec520325-Linux
- Filter
- advertised
- Fetch
- shallow wait-for-done filter
- Capabilities
- agent ls-refs fetch server-option object-format