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});
Diagnostics4 git calls · 320 ms
CallStatusSizeTime0320 ms
discover200152 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=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 · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=316 git.response.bytes=38434 git.response.cache=HIT git.response.duration_ms=2 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=55Open pack map
fetch2001.5 KiB316 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1581 git.response.cache=MISS git.response.duration_ms=316 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=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1581 git.pkt.payload.max=1560 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://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply.git
- Ref
- refs/heads/main
- Commit
- 19912563f540228593df0c489082e5e2508e21e4
- cf-ray
- a5e1f9edd8f024ce
- Request
- fdb81525…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format