GitHubivarvong
ply
main
1// resolvePackRange's memory bound (#248), measured: each cell is its own process (test/stream/resolve-cell.mjs,
2// --expose-gc) under a 64 MiB V8 heap. The pack is on disk and read back through a file RangeSource, so live
3// arrayBuffers count what the resolver holds, not the pack. The bound the README states is one base, one pinned result,
4// one result, one delta's instructions and the cache: max(maxObjectSize, maxDeltaResult) + 3 x maxDeltaResult +
5// cacheBytes, whatever the pack's size, depth or shape. Linear chains hold less (a base, its result and the cache): the
6// pack grows four times between the two cells and the peak must not. A forked family larger than the cache
7// (test/stream/resolve-fork-cell.mjs) is the shape that pins a result and rebuilds bases, held to the stated bound.
8import { test } from 'vitest';
9import assert from 'node:assert/strict';
10import { spawnSync } from 'node:child_process';
11import { MEMORY_CELL_FLAGS } from './memcell.js';
13const MIB = 1024 * 1024;
14const SIZE = 4 * MIB;
15const CACHE = 8 * MIB;
16const DEPTH = 10;
17function cell(chains) {
18 const r = spawnSync(process.execPath, [...MEMORY_CELL_FLAGS, '--max-old-space-size=64', '--import', './test/ts-resolve.mjs', 'test/stream/resolve-cell.mjs', String(chains), String(DEPTH), String(SIZE), String(CACHE)], { encoding: 'utf8', env: process.env, maxBuffer: 1 << 20 });
19 assert.equal(r.status, 0, `chains ${chains}: exit ${r.status}\n${r.stderr}`);
20 return JSON.parse(r.stdout.trim().split('\n').at(-1));
21}
23test('resolving chains of 4 MiB objects holds one base, one result and the cache, however large the pack', () => {
24 const small = cell(2);
25 const large = cell(8);
26 console.log(JSON.stringify({ small, large }));
27 assert.ok(large.packBytes >= 4 * small.packBytes - MIB);
28 assert.equal(large.stats.applied, 8 * DEPTH * SIZE);
29 // a base and its result; the cache holds those same buffers (or others up to CACHE), and a 64 KiB read piece
30 const bound = 2 * SIZE + CACHE + MIB;
31 for (const r of [small, large]) assert.ok(r.abDelta <= bound, `${r.chains} chains held ${r.abDelta} > ${bound}`);
32 assert.ok(Math.abs(large.abDelta - small.abDelta) <= MIB, `the peak grew with the pack: ${small.abDelta} -> ${large.abDelta}`);
33});
35test('a forked family of 2 MiB objects larger than the cache resolves to the right oids inside the stated bound', () => {
36 const FORK_SIZE = 2 * MIB;
37 const FORK_DEPTH = 12;
38 const r = spawnSync(process.execPath, [...MEMORY_CELL_FLAGS, '--max-old-space-size=64', '--import', './test/ts-resolve.mjs', 'test/stream/resolve-fork-cell.mjs', String(FORK_DEPTH), String(FORK_SIZE), String(CACHE)], { encoding: 'utf8', env: process.env, maxBuffer: 1 << 20 });
39 assert.equal(r.status, 0, `fork cell: exit ${r.status}\n${r.stderr}`);
40 const got = JSON.parse(r.stdout.trim().split('\n').at(-1));
41 console.log(JSON.stringify(got));
42 // by hand: a root and, at each of 12 levels, two deltas on the spine and a leaf: 37 objects, 74 MiB against an 8 MiB cache
43 assert.equal(got.entries, 37);
44 assert.equal(got.wanted, 37);
45 assert.ok(got.entries * FORK_SIZE > 4 * CACHE, 'the family fits the cache');
46 // every oid is node:crypto's over the bytes the edits describe (the cell compares them)
47 assert.equal(got.oidsRight, 37);
48 // the fork did miss the cache: bases were made again
49 assert.ok(got.stats.rebuilt > 0, 'nothing was rebuilt: the family fit the cache');
50 // by hand, with maxObjectSize = maxDeltaResult = 2 MiB: 2 MiB + 3 x 2 MiB + 8 MiB = 16,777,216
51 const bound = Math.max(FORK_SIZE, FORK_SIZE) + 3 * FORK_SIZE + CACHE;
52 assert.equal(bound, 16_777_216);
53 assert.ok(got.abDelta <= bound, `the forked family held ${got.abDelta} > ${bound}`);
54});
Diagnostics6 git calls · 135 ms
CallStatusSizeTime0135 ms
discover200191 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 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 KiB2 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=11990 git.response.cache=UPDATING git.response.duration_ms=2 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 102004.2 KiB · 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=4347 git.response.cache=HIT git.response.duration_ms=2 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
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=3 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 · hit4 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=125 git.response.bytes=5724 git.response.cache=HIT git.response.duration_ms=4 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 KiB125 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1586 git.response.cache=MISS git.response.duration_ms=125 git.fetch.wants=617df87ae8fc1297e393f7439a70983e8d536694 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=1586 git.pkt.payload.max=1559 git.sideband.band1.bytes=1559 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
- a5e0fbbe7a96332c
- Request
- 7a86f8f0…
- 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