@ref0/git 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contracts/calls-spent.d.mts +2 -12
- package/dist/contracts/calls-spent.mjs +4 -5
- package/dist/contracts/commits.d.mts +14 -2
- package/dist/contracts/commits.mjs +22 -3
- package/dist/contracts/events.d.mts +70 -4
- package/dist/contracts/events.mjs +27 -3
- package/dist/contracts/git.d.mts +13 -3
- package/dist/contracts/objects.d.mts +18 -0
- package/dist/contracts/queue.d.mts +3 -2
- package/dist/contracts/queue.mjs +4 -2
- package/dist/contracts/refs.mjs +3 -1
- package/dist/core/ancestry.mjs +5 -4
- package/dist/core/events/seen.mjs +5 -4
- package/dist/core/index-job.mjs +23 -1
- package/dist/core/index-lost.d.mts +11 -0
- package/dist/core/index-lost.mjs +55 -0
- package/dist/core/job-view.mjs +20 -0
- package/dist/core/objects/commit-writes.mjs +1 -1
- package/dist/core/objects/commits.mjs +10 -9
- package/dist/core/objects/merges.mjs +1 -1
- package/dist/core/objects/reading.mjs +28 -13
- package/dist/core/objects/trees.mjs +1 -1
- package/dist/core/parts.d.mts +7 -0
- package/dist/core/publish.mjs +9 -5
- package/dist/core/purge.mjs +16 -3
- package/dist/core/push.mjs +27 -11
- package/dist/core/ref-view.mjs +1 -25
- package/dist/core/repack.mjs +36 -14
- package/dist/core/view.d.mts +10 -1
- package/dist/core/view.mjs +15 -6
- package/dist/core/work.mjs +47 -4
- package/dist/effect.d.mts +2 -3
- package/dist/effect.mjs +2 -3
- package/dist/engine/commits.mjs +4 -3
- package/dist/engine/merge-bases.mjs +5 -3
- package/dist/engine/merge.mjs +4 -3
- package/dist/engine/parts.d.mts +1 -0
- package/dist/engine/parts.mjs +1 -1
- package/dist/engine/walk.mjs +62 -20
- package/dist/http/core-parts.mjs +17 -8
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/lfs/objects.mjs +7 -4
- package/dist/lfs/upkeep.mjs +6 -5
- package/dist/lfs/upload-most.mjs +8 -2
- package/dist/protocol/bytes/streams.mjs +84 -2
- package/dist/protocol/diff/read.d.mts +1 -0
- package/dist/protocol/diff/read.mjs +5 -2
- package/dist/protocol/objects/commit.d.mts +7 -0
- package/dist/protocol/objects/commit.mjs +5 -1
- package/dist/queue/advance.mjs +39 -10
- package/dist/queue/host.d.mts +4 -0
- package/dist/queue/layer.mjs +4 -2
- package/dist/queue/limits.mjs +18 -2
- package/dist/queue/rows.mjs +2 -1
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/commits.d.mts +202 -198
- package/dist/rest/forks.d.mts +99 -99
- package/dist/rest/refs.d.mts +144 -144
- package/dist/rest/repos.d.mts +48 -48
- package/dist/rest/topics.d.mts +112 -112
- package/dist/rest/trees.d.mts +58 -58
- package/dist/rest/wire.d.mts +19 -1
- package/dist/rest/work.d.mts +39 -39
- package/dist/server/joined.d.mts +11 -5
- package/dist/server/joined.mjs +3 -2
- package/dist/server/registry.mjs +11 -5
- package/dist/server/server.mjs +16 -4
- package/dist/storage/index-bitmaps.mjs +16 -10
- package/dist/storage/index-build.mjs +61 -13
- package/dist/storage/index-graph.d.mts +1 -0
- package/dist/storage/index-graph.mjs +29 -5
- package/dist/storage/index-layers.d.mts +1 -0
- package/dist/storage/index-layers.mjs +5 -2
- package/dist/storage/index-reach.mjs +7 -5
- package/dist/storage/index-remap.mjs +5 -5
- package/dist/storage/index-visible.mjs +16 -5
- package/dist/storage/links.mjs +3 -3
- package/dist/storage/pack-order.d.mts +1 -0
- package/dist/storage/pack-order.mjs +18 -1
- package/dist/storage/prune-walk.mjs +5 -2
- package/dist/storage/prune.mjs +107 -37
- package/dist/storage/receive-bounds.mjs +3 -2
- package/dist/storage/visible.mjs +3 -2
- package/dist/storage/walk.d.mts +1 -0
- package/dist/storage/walk.mjs +9 -5
- package/dist/storage/wants.mjs +17 -11
- package/dist/store/call-count.d.mts +8 -0
- package/dist/store/call-count.mjs +15 -7
- package/dist/store/errors.d.mts +7 -1
- package/dist/store/errors.mjs +7 -1
- package/dist/store/job-try.mjs +3 -1
- package/dist/store/records.mjs +17 -2
- package/dist/store/repo-record.mjs +9 -2
- package/dist/store/scopes.mjs +10 -2
- package/dist/sync/bound.d.mts +1 -1
- package/dist/sync/import.mjs +1 -1
- package/dist/sync/layer.mjs +4 -7
- package/dist/sync/mirror.mjs +1 -1
- package/dist/topics/advance.mjs +4 -4
- package/dist/topics/layer.mjs +1 -1
- package/package.json +3 -3
|
@@ -3,6 +3,7 @@ import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
|
3
3
|
import { rawLinks } from "../protocol/objects/links-raw.mjs";
|
|
4
4
|
import { isTreeMode } from "../protocol/objects/object.mjs";
|
|
5
5
|
import { parseTreeBytes } from "../protocol/objects/tree.mjs";
|
|
6
|
+
import { noRepoRoots } from "../protocol/objects/commit.mjs";
|
|
6
7
|
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
7
8
|
import { bitmapWords } from "./ewah.mjs";
|
|
8
9
|
import { ewahMostWords, openBitmaps } from "./index-bitmaps.mjs";
|
|
@@ -369,7 +370,7 @@ const whileFollowed = (allotment, objects, follow) => {
|
|
|
369
370
|
/**
|
|
370
371
|
* The positions `starts` reach, as words over every position, or `undefined` when it can't say:
|
|
371
372
|
* a walk past `most` reads, an object it can't find, or a link to an ID the index doesn't hold,
|
|
372
|
-
* such as one listed after it. A position with a stored bitmap is ORed whole and not walked; any
|
|
373
|
+
* such as one listed after it. One of `input.roots` leads to its tree alone, never its parents. A position with a stored bitmap is ORed whole and not walked; any
|
|
373
374
|
* other is read, and its links found by position, a few at a time. A blob is reached and never
|
|
374
375
|
* read. It holds a word for each 32 positions, unless it's given `bits`, and at most `most` IDs
|
|
375
376
|
* still to read, charged to `allotment`, and each batch it follows, charged by `whileFollowed`.
|
|
@@ -390,6 +391,7 @@ const whileFollowed = (allotment, objects, follow) => {
|
|
|
390
391
|
const reachOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, starts, carry) {
|
|
391
392
|
const { layout, bitmaps } = input;
|
|
392
393
|
const most = input.most ?? 2e3;
|
|
394
|
+
const roots = input.roots ?? noRepoRoots;
|
|
393
395
|
const words = bitmapWords(layout.positions);
|
|
394
396
|
const held = (input.bits === void 0 ? words * 4 : 0) + most * 24;
|
|
395
397
|
yield* Effect.acquireRelease(input.allotment.grow(held), () => Effect.sync(() => input.allotment.shrink(held)));
|
|
@@ -448,8 +450,9 @@ const reachOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, starts, carr
|
|
|
448
450
|
continue;
|
|
449
451
|
}
|
|
450
452
|
let tree = object.type === "commit";
|
|
453
|
+
const rooted = tree && roots.has(object.oid);
|
|
451
454
|
const malformed = rawLinks(object.type, bytes, (from, at) => {
|
|
452
|
-
linked.push({
|
|
455
|
+
if (tree || !rooted) linked.push({
|
|
453
456
|
id: from.slice(at, at + 20),
|
|
454
457
|
links: true,
|
|
455
458
|
to: tree ? "trees" : "commits"
|
|
@@ -91,7 +91,8 @@ const shrinkOnClose = (allotment, held) => () => Effect.sync(() => allotment.shr
|
|
|
91
91
|
* What `tips`, none of which the index holds, reach before they meet it, through `onward`: each
|
|
92
92
|
* object outside the index, read or not, counted, and each position met set in `met`, kept as a
|
|
93
93
|
* bit, not walked. A blob is reached and never read, and an object the repo doesn't hold, as a
|
|
94
|
-
* shallow repo's parent, is left out
|
|
94
|
+
* shallow repo's parent, is left out, and one of `input.roots` leads to its tree alone, never its
|
|
95
|
+
* parents, as the index's graph has it. Past `most` objects outside it, it stops, not closed. Each
|
|
95
96
|
* batch it follows is charged by `whileFollowed`, and it holds at most `most` IDs between them.
|
|
96
97
|
*/
|
|
97
98
|
const outsideOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, tips, most) {
|
|
@@ -116,7 +117,7 @@ const outsideOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, tips, most
|
|
|
116
117
|
ids.delete(oid);
|
|
117
118
|
continue;
|
|
118
119
|
}
|
|
119
|
-
const steps = yield* stepsOf(object, true);
|
|
120
|
+
const steps = yield* stepsOf(object, true, input.roots);
|
|
120
121
|
for (const each of onward(steps)) if (!ids.has(each)) read.add(each);
|
|
121
122
|
for (const each of steps.reached) if (!ids.has(each)) linked.add(each);
|
|
122
123
|
}
|
|
@@ -157,8 +158,8 @@ const indexCovers = (input, listed) => {
|
|
|
157
158
|
* doesn't cover `listed`, as after a repack took a covered pack out, for the caller's walk. A tip
|
|
158
159
|
* whose reach won't close within `most` sets `pastLimit`. Where `unclosed`, so does one whose walk
|
|
159
160
|
* meets an object past the bytes it may follow at once, which a fetch's want check refuses as
|
|
160
|
-
* `levelTooLarge`: a visible set still shows its tips, and what their bitmaps reach. Its
|
|
161
|
-
* allotment is the scope's.
|
|
161
|
+
* `levelTooLarge`: a visible set still shows its tips, and what their bitmaps reach. Its walks
|
|
162
|
+
* follow no parent of `input.roots`. Its allotment is the scope's.
|
|
162
163
|
*/
|
|
163
164
|
const tipsReach = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, input, unclosed = false) {
|
|
164
165
|
let tooLarge = false;
|
|
@@ -192,7 +193,8 @@ const tipsReach = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
|
|
|
192
193
|
bitmaps,
|
|
193
194
|
read,
|
|
194
195
|
allotment,
|
|
195
|
-
most
|
|
196
|
+
most,
|
|
197
|
+
roots: input.roots
|
|
196
198
|
};
|
|
197
199
|
let known = true;
|
|
198
200
|
let walked = 0;
|
|
@@ -515,10 +515,10 @@ const remapIndex = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
515
515
|
});
|
|
516
516
|
/**
|
|
517
517
|
* The `index` row a geometric step's merge leaves, laid again over its pack, or `undefined` when
|
|
518
|
-
* it can't be: the row isn't built, is a refusal for spent tries, or doesn't
|
|
519
|
-
* before the merge; the merge took a pack it doesn't cover; the remap
|
|
520
|
-
* says; or it fails of its own, its calls run out, its allotment can't
|
|
521
|
-
* reads is lost or corrupt, each logged with its cause. Then the listing commits without it, and
|
|
518
|
+
* it can't be: the row isn't built, is a refusal for spent tries, is marked lost, or doesn't
|
|
519
|
+
* cover the listing before the merge; the merge took a pack it doesn't cover; the remap
|
|
520
|
+
* declines, as `remapIndex` says; or it fails of its own, its calls run out, its allotment can't
|
|
521
|
+
* grow, or a stored file it reads is lost or corrupt, each logged with its cause. Then the listing commits without it, and
|
|
522
522
|
* the next `git.index` builds again. A merge it finds incomplete, the merged pack's own files lost
|
|
523
523
|
* or corrupt among it, fails the step, an error in the log; so do an interruption, a defect and
|
|
524
524
|
* any other failure.
|
|
@@ -528,7 +528,7 @@ const remapRow = (parts, input) => Effect.scoped(Effect.gen(function* () {
|
|
|
528
528
|
...indexRowKey,
|
|
529
529
|
value: parts.row
|
|
530
530
|
});
|
|
531
|
-
if (row === void 0 || "refused" in row || row.refusal !== void 0) return void 0;
|
|
531
|
+
if (row === void 0 || "refused" in row || row.refusal !== void 0 || row.lost === true) return void 0;
|
|
532
532
|
if (!coversListing(row.layers, input.listed, parts.holds?.packs)) return void 0;
|
|
533
533
|
const plan = remapPlan(row.layers, input.listed, input.taken, input.merged.pack.objects);
|
|
534
534
|
if (plan === void 0) return void 0;
|
|
@@ -33,6 +33,16 @@ const unindexedRead = () => gitError("RESOURCE_EXHAUSTED", readByIdText, {
|
|
|
33
33
|
const isUnindexedRead = (error) => error.code === "RESOURCE_EXHAUSTED" && error.message === readByIdText;
|
|
34
34
|
/** What each ID a set has answered adds to what it keeps: its hex and its place in the map. */
|
|
35
35
|
const answerBytes = 160;
|
|
36
|
+
/**
|
|
37
|
+
* The core's ask for the rebuild of the `index` row a set's input names, once the index fails its
|
|
38
|
+
* own checks, kept off `VisibleInput`'s contract as a set's reach is.
|
|
39
|
+
*/
|
|
40
|
+
const lostAsks = /* @__PURE__ */ new WeakMap();
|
|
41
|
+
/** `input`, whose set asks `lost` once the index its row names fails its own checks. */
|
|
42
|
+
const askingOnLost = (input, lost) => {
|
|
43
|
+
lostAsks.set(input, lost);
|
|
44
|
+
return input;
|
|
45
|
+
};
|
|
36
46
|
/** Each set `indexedVisible` made, with its `SetReach`, kept off the set's contract. */
|
|
37
47
|
const setReaches = /* @__PURE__ */ new WeakMap();
|
|
38
48
|
/** The want check `set` answers by its own reach, if `indexedVisible` made it. */
|
|
@@ -47,20 +57,21 @@ const setReachOf = (set) => setReaches.get(set);
|
|
|
47
57
|
* never on an ID, and a hidden ID and an absent one still read alike. Outside a request's hold, or
|
|
48
58
|
* once it has closed, an ask builds the reach for itself and lets it go once answered. A tip
|
|
49
59
|
* answers with no lookup, since its caller sees it. An index that fails its own checks,
|
|
50
|
-
* `DATA_LOSS`, gives the set to `fallback` too, with its error in the log
|
|
51
|
-
* is reached that it hasn't shown.
|
|
60
|
+
* `DATA_LOSS`, gives the set to `fallback` too, with its error in the log and the core's ask for
|
|
61
|
+
* the row's rebuild, `askingOnLost`, so it never says an ID is reached that it hasn't shown.
|
|
52
62
|
*/
|
|
53
63
|
const indexedVisible = (parts, listed, input, fallback) => {
|
|
54
64
|
if (!indexCovers(input, listed)) return fallback();
|
|
55
65
|
const tips = {
|
|
56
66
|
row: input.row,
|
|
57
|
-
tips: input.tips
|
|
67
|
+
tips: input.tips,
|
|
68
|
+
roots: input.roots
|
|
58
69
|
};
|
|
59
70
|
const shownTips = new Set(input.tips);
|
|
60
71
|
/** The tips as `tipsReach` walks them: each once, where it first comes. */
|
|
61
72
|
const walkedTips = [...shownTips];
|
|
62
73
|
/** An index that fails its own checks as `value`, its error in the log. */
|
|
63
|
-
const lostAs = (value) => (effect) => effect.pipe(Effect.catchIf((error) => error.code === "DATA_LOSS", (error) => Effect.as(indexUnreadable(listed.repo, error), value)));
|
|
74
|
+
const lostAs = (value) => (effect) => effect.pipe(Effect.catchIf((error) => error.code === "DATA_LOSS", (error) => Effect.as(indexUnreadable(listed.repo, error, lostAsks.get(input)), value)));
|
|
64
75
|
let fell;
|
|
65
76
|
let held;
|
|
66
77
|
let using = 0;
|
|
@@ -165,4 +176,4 @@ const indexedVisible = (parts, listed, input, fallback) => {
|
|
|
165
176
|
setReaches.set(set, reach);
|
|
166
177
|
return set;
|
|
167
178
|
};
|
|
168
|
-
export { indexedVisible, isUnindexedRead, setReachOf, unindexedRead };
|
|
179
|
+
export { askingOnLost, indexedVisible, isUnindexedRead, setReachOf, unindexedRead };
|
package/dist/storage/links.mjs
CHANGED
|
@@ -136,8 +136,8 @@ const segmentPast = (what, most) => gitError("RESOURCE_EXHAUSTED", `the segment'
|
|
|
136
136
|
*/
|
|
137
137
|
const segmentTooLarge = (segment) => {
|
|
138
138
|
const { boundary = [], needs = [] } = segment;
|
|
139
|
-
if (boundary.length >
|
|
140
|
-
return needs.length >
|
|
139
|
+
if (boundary.length > receiveBoundaryMost) return segmentPast(`boundary names ${boundary.length.toLocaleString("en-US")} commits`, receiveBoundaryMost);
|
|
140
|
+
return needs.length > receiveCutParentsMost ? segmentPast(`answer needs ${needs.length.toLocaleString("en-US")} parents`, receiveCutParentsMost) : void 0;
|
|
141
141
|
};
|
|
142
142
|
/** What a segment's cut carries from one step to the next: the parents counted, by commit. */
|
|
143
143
|
const CutCarry = /* @__PURE__ */ Schema.Struct({
|
|
@@ -151,7 +151,7 @@ const CutCarry = /* @__PURE__ */ Schema.Struct({
|
|
|
151
151
|
* too: one goes on from the `carried` count and parents of the steps before it.
|
|
152
152
|
*/
|
|
153
153
|
const segmentCut = (asked, carried) => {
|
|
154
|
-
const most = Math.max(0, Math.min(asked ??
|
|
154
|
+
const most = Math.max(0, Math.min(asked ?? receiveCutParentsMost, receiveCutParentsMost));
|
|
155
155
|
const byCommit = new Map(carried?.byCommit.map(([commit, parents]) => [commit, [...parents]]));
|
|
156
156
|
let count = carried?.count ?? 0;
|
|
157
157
|
return {
|
|
@@ -2,6 +2,7 @@ import "../contracts/objects.mjs";
|
|
|
2
2
|
import "../contracts/result.mjs";
|
|
3
3
|
import "../protocol/packs/indexer.mjs";
|
|
4
4
|
import "../protocol/packs/step.mjs";
|
|
5
|
+
import "../protocol/objects/commit.mjs";
|
|
5
6
|
import "../contracts/calls-spent.mjs";
|
|
6
7
|
import "./pack-reads.mjs";
|
|
7
8
|
import "./pack-ranges.mjs";
|
|
@@ -344,6 +344,21 @@ const entryById = (entries, id) => {
|
|
|
344
344
|
}
|
|
345
345
|
return -1;
|
|
346
346
|
};
|
|
347
|
+
/** No positions: a slice that read no root. */
|
|
348
|
+
const noRoots = /* @__PURE__ */ new Set();
|
|
349
|
+
/**
|
|
350
|
+
* The repo positions of the slice's first `kept` entries, the first at `first`, whose IDs are
|
|
351
|
+
* among `roots`: each root searched for in the slice's own IDs.
|
|
352
|
+
*/
|
|
353
|
+
const rootsWithin = (entries, roots, kept, first) => {
|
|
354
|
+
if (roots === void 0 || roots.size === 0) return noRoots;
|
|
355
|
+
const found = /* @__PURE__ */ new Set();
|
|
356
|
+
for (const root of roots) {
|
|
357
|
+
const within = entryById(entries, oidBytes(root));
|
|
358
|
+
if (within >= 0 && within < kept) found.add(first + within);
|
|
359
|
+
}
|
|
360
|
+
return found;
|
|
361
|
+
};
|
|
347
362
|
const unknown = 4;
|
|
348
363
|
/** The code a pack entry's header gives a whole object, or `unknown` for a delta. */
|
|
349
364
|
const knownOf = (kind) => kind === "ofs" || kind === "ref" ? unknown : typeCodes[kind];
|
|
@@ -535,6 +550,7 @@ const spentRead = (at, span) => ({
|
|
|
535
550
|
read: 0,
|
|
536
551
|
skipped: 0,
|
|
537
552
|
rereads: 0,
|
|
553
|
+
roots: noRoots,
|
|
538
554
|
spent: span
|
|
539
555
|
});
|
|
540
556
|
const sliceRead = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
@@ -773,7 +789,8 @@ const sliceRead = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
773
789
|
bases: bases.subarray(0, based),
|
|
774
790
|
read,
|
|
775
791
|
skipped,
|
|
776
|
-
rereads: indexer.rereads
|
|
792
|
+
rereads: indexer.rereads,
|
|
793
|
+
roots: rootsWithin(entries, input.roots, types.length, ranges.base + at.position)
|
|
777
794
|
};
|
|
778
795
|
});
|
|
779
796
|
/** The first `count` words of `pairs`, two at a time, compacted to those whose first is below `limit`; their count. */
|
|
@@ -180,7 +180,7 @@ const droppedOnRefusal = (walk, input, pack, _start, _missing, options = {}) =>
|
|
|
180
180
|
* A refused fresh walk drops its runs; one given `saved` or `known` keeps them. A test sets
|
|
181
181
|
* `treesAtOnce` below its bound.
|
|
182
182
|
*/
|
|
183
|
-
const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, start, missing, { rows = 0, treesAtOnce = pruneTreesAtOnce, calls, saved, known } = {}) {
|
|
183
|
+
const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, start, missing, { rows = 0, treesAtOnce = pruneTreesAtOnce, calls, saved, known, roots } = {}) {
|
|
184
184
|
const { allotment, listed } = input;
|
|
185
185
|
const objects = listed.packs.reduce((sum, each) => sum + each.objects, 0) + rows;
|
|
186
186
|
const blocks = listed.packs.reduce((sum, each) => sum + Math.ceil(each.bytes / blockBytes), 0);
|
|
@@ -214,7 +214,10 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
214
214
|
held -= bytes;
|
|
215
215
|
allotment.shrink(bytes);
|
|
216
216
|
});
|
|
217
|
-
const reads = countedReads(
|
|
217
|
+
const reads = countedReads(roots === void 0 ? reader : {
|
|
218
|
+
...reader,
|
|
219
|
+
roots
|
|
220
|
+
}, objects + 1e6, charged, void 0, release);
|
|
218
221
|
/** Where each of `oids` is for the seen set: its first listed pack and its rank there. */
|
|
219
222
|
const ranksOf = Effect.fnUntraced(function* (oids) {
|
|
220
223
|
const at = /* @__PURE__ */ new Map();
|
package/dist/storage/prune.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { fail } from "../contracts/result.mjs";
|
|
2
2
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
3
|
+
import { rootsOf } from "../store/repo-record.mjs";
|
|
3
4
|
import { decodeRow } from "../store/errors.mjs";
|
|
4
5
|
import { WholeRepo, wholeRef } from "../store/ref-rows.mjs";
|
|
5
6
|
import { ReachedMark, markHolds } from "../store/records.mjs";
|
|
6
|
-
import { collections, reachedKey, repoScope } from "../store/scopes.mjs";
|
|
7
|
+
import { collections, reachedKey, repoRootsKey, repoScope } from "../store/scopes.mjs";
|
|
7
8
|
import { bucketDeleteMany, readWhole } from "./calls.mjs";
|
|
8
9
|
import { putOnce } from "./index-build.mjs";
|
|
9
10
|
import { isPackId, objectCollections, runKey } from "./layout.mjs";
|
|
@@ -70,7 +71,8 @@ const PassClasses = /* @__PURE__ */ Schema.Struct({
|
|
|
70
71
|
* scratch pack, till the pass's last step drops them. `classes` names the classes object its
|
|
71
72
|
* merges read, and `redos` counts the rewrites it dropped as pushes moved its refs onto what they
|
|
72
73
|
* were about to drop: the third waits for the next period, as `pruneStep` says, and that period's
|
|
73
|
-
* walks start again with none (#1660).
|
|
74
|
+
* walks start again with none (#1660). `periods` counts the periods in a row the pass has waited
|
|
75
|
+
* so, which a wait for any other reason ends, as `ObjectsStep.busy` says (#2233).
|
|
74
76
|
*/
|
|
75
77
|
const PruneStarted = /* @__PURE__ */ Schema.Struct({
|
|
76
78
|
at: Schema.Int,
|
|
@@ -80,7 +82,8 @@ const PruneStarted = /* @__PURE__ */ Schema.Struct({
|
|
|
80
82
|
n: Schema.optional(WalkCarry)
|
|
81
83
|
})),
|
|
82
84
|
classes: Schema.optional(PassClasses),
|
|
83
|
-
redos: Schema.optional(Schema.Int)
|
|
85
|
+
redos: Schema.optional(Schema.Int),
|
|
86
|
+
periods: Schema.optional(Schema.Int)
|
|
84
87
|
});
|
|
85
88
|
const pruneStartedKey = {
|
|
86
89
|
collection: objectCollections.prune,
|
|
@@ -202,13 +205,14 @@ const bitsOf = (bits, packs) => {
|
|
|
202
205
|
* `start` with `known` reached already, as D2's walk carries it. A new walk, with neither, drops
|
|
203
206
|
* what a pass that died left under `scratch` first. With `more`, where it stopped, for the mark.
|
|
204
207
|
*/
|
|
205
|
-
const walkOn = /* @__PURE__ */ Effect.fnUntraced(function* (input, scratch, start, rows, missing, calls, saved, known) {
|
|
208
|
+
const walkOn = /* @__PURE__ */ Effect.fnUntraced(function* (input, scratch, start, rows, missing, calls, roots, saved, known) {
|
|
206
209
|
if (saved === void 0 && known === void 0) yield* dropRuns(input.bucket, scratch);
|
|
207
210
|
const walked = yield* pruneWalk(input, scratch, start, missing, {
|
|
208
211
|
rows: rows.length,
|
|
209
212
|
calls,
|
|
210
213
|
saved,
|
|
211
|
-
known
|
|
214
|
+
known,
|
|
215
|
+
roots
|
|
212
216
|
});
|
|
213
217
|
return "more" in walked ? { more: walked.more } : {
|
|
214
218
|
runs: walked.reached,
|
|
@@ -233,14 +237,29 @@ const refsHeld = /* @__PURE__ */ Effect.fnUntraced(function* (input, scratch, wa
|
|
|
233
237
|
}, upkeepRuns);
|
|
234
238
|
return held;
|
|
235
239
|
}, Effect.scoped);
|
|
236
|
-
/**
|
|
240
|
+
/** Each object `rows`, ref rows, name, once each. */
|
|
241
|
+
const refIdsIn = (rows) => Effect.map(Effect.forEach(rows ?? [], (row) => wholeRef(pruneWhole, row)), (refs) => [...new Set(refs)]);
|
|
242
|
+
/**
|
|
243
|
+
* Every ref's object, once each, and the repo's roots in the same read: a walk from the refs
|
|
244
|
+
* follows no root's parents, so what only they reach is no ref's.
|
|
245
|
+
*/
|
|
237
246
|
const refsOf = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
247
|
+
const snapshot = yield* input.store.read({
|
|
248
|
+
scope: repoScope(input.listed.repo),
|
|
249
|
+
reads: [{ collection: collections.refs }, repoRootsKey]
|
|
250
|
+
});
|
|
251
|
+
return {
|
|
252
|
+
refs: yield* refIdsIn(snapshot.results[0]),
|
|
253
|
+
roots: yield* rootsOf(snapshot.results[1])
|
|
254
|
+
};
|
|
255
|
+
});
|
|
256
|
+
/** Every ref's object, once each, with no roots: what a listing checks its bits were read at. */
|
|
257
|
+
const refIdsOf = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
238
258
|
const snapshot = yield* input.store.read({
|
|
239
259
|
scope: repoScope(input.listed.repo),
|
|
240
260
|
reads: [{ collection: collections.refs }]
|
|
241
261
|
});
|
|
242
|
-
|
|
243
|
-
return [...new Set(refs)];
|
|
262
|
+
return yield* refIdsIn(snapshot.results[0]);
|
|
244
263
|
});
|
|
245
264
|
/** The objects of `packs` and `rows` that `reached` leaves out: where the needed walk starts. */
|
|
246
265
|
const unreachedOf = (packs, rows, reached) => [...new Set([...oidsOf(packs), ...rows.map((row) => row.oid)].filter((oid) => !reached.has(oid)))];
|
|
@@ -409,7 +428,7 @@ const cruftListing = (landed) => Effect.fnUntraced(function* (input, merge) {
|
|
|
409
428
|
* merge waits at its commit pass, and the pass catches up first.
|
|
410
429
|
*/
|
|
411
430
|
const keptListing = (read, seen, rows, landed) => Effect.fnUntraced(function* (input, merge) {
|
|
412
|
-
if ((yield* readsDigest(yield*
|
|
431
|
+
if ((yield* readsDigest(yield* refIdsOf(input), rows)) !== seen.reads || !sameIds(seen.packs, classedIds(input, read))) return void 0;
|
|
413
432
|
const removed = yield* takenOf(input, merge);
|
|
414
433
|
const { packs, quarantines, first } = yield* writtenOf(merge);
|
|
415
434
|
const dropped = removed.filter((pack) => read.cruft.has(pack.id));
|
|
@@ -528,9 +547,43 @@ const emptiedStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, em
|
|
|
528
547
|
if (dropped.length > 0) step.drops = true;
|
|
529
548
|
return step;
|
|
530
549
|
});
|
|
531
|
-
/** `started` with `
|
|
550
|
+
/** A mark at `started`'s start, with its `periods`, if any: what each new mark of the pass keeps. */
|
|
551
|
+
const periodsOf = (started) => started.periods === void 0 ? { at: started.at } : {
|
|
552
|
+
at: started.at,
|
|
553
|
+
periods: started.periods
|
|
554
|
+
};
|
|
555
|
+
/**
|
|
556
|
+
* The pass's mark with its count of periods pushes held it ended, when an underway pass's mark
|
|
557
|
+
* has one: what a wait for anything but pushes puts, its walks and its wait kept (#2233).
|
|
558
|
+
*/
|
|
559
|
+
const countEnded = (read) => {
|
|
560
|
+
const { started } = read;
|
|
561
|
+
const last = read.pass?.at;
|
|
562
|
+
if (started?.periods === void 0 || last !== void 0 && started.at <= last) return void 0;
|
|
563
|
+
const value = { ...started };
|
|
564
|
+
delete value.periods;
|
|
565
|
+
return {
|
|
566
|
+
...pruneStartedKey,
|
|
567
|
+
value
|
|
568
|
+
};
|
|
569
|
+
};
|
|
570
|
+
/** `step`, or a step of its own when there's none, putting `row` too. */
|
|
571
|
+
const alsoPuts = (step, row) => {
|
|
572
|
+
const base = step ?? {
|
|
573
|
+
change: { rows: noRows },
|
|
574
|
+
more: true
|
|
575
|
+
};
|
|
576
|
+
return {
|
|
577
|
+
...base,
|
|
578
|
+
change: {
|
|
579
|
+
...base.change,
|
|
580
|
+
put: [...base.change.put ?? [], row]
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
};
|
|
584
|
+
/** `started` with `patch` laid over it, its `waits` ended and its `periods` kept. */
|
|
532
585
|
const remarked = (started, patch) => {
|
|
533
|
-
const value =
|
|
586
|
+
const value = periodsOf(started);
|
|
534
587
|
const walks = "walks" in patch ? patch.walks : started.walks;
|
|
535
588
|
const classes = "classes" in patch ? patch.classes : started.classes;
|
|
536
589
|
const redos = "redos" in patch ? patch.redos : started.redos;
|
|
@@ -569,12 +622,12 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
569
622
|
},
|
|
570
623
|
mark: { walks }
|
|
571
624
|
});
|
|
572
|
-
const refs = yield* refsOf(input);
|
|
625
|
+
const { refs, roots } = yield* refsOf(input);
|
|
573
626
|
const digest = yield* readsDigest(refs, rowOids);
|
|
574
627
|
const ids = classedIds(input, read);
|
|
575
628
|
const carry = carried.r;
|
|
576
629
|
if (carry === void 0 || "saved" in carry) {
|
|
577
|
-
const walked = yield* walkOn(input, scratch, refs, rows, lost, calls, carry?.saved);
|
|
630
|
+
const walked = yield* walkOn(input, scratch, refs, rows, lost, calls, roots, carry?.saved);
|
|
578
631
|
return saving({ r: "more" in walked ? {
|
|
579
632
|
saved: walked.more,
|
|
580
633
|
refs: carry?.refs
|
|
@@ -627,7 +680,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
627
680
|
});
|
|
628
681
|
const caught = yield* Effect.scoped(Effect.map(sides, ({ reached }) => refs.filter((oid) => !reached.has(oid))));
|
|
629
682
|
if (caught.length > 0) {
|
|
630
|
-
const walked = yield* walkOn(input, scratch, caught, rows, lost, calls, void 0, reachedRuns);
|
|
683
|
+
const walked = yield* walkOn(input, scratch, caught, rows, lost, calls, roots, void 0, reachedRuns);
|
|
631
684
|
return saving({
|
|
632
685
|
...carried,
|
|
633
686
|
r: "more" in walked ? {
|
|
@@ -681,7 +734,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
681
734
|
const neededCarry = carried.n;
|
|
682
735
|
if (packs.old.length > 0 && (neededCarry === void 0 || "saved" in neededCarry)) {
|
|
683
736
|
const start = neededCarry === void 0 ? first.start : [];
|
|
684
|
-
const walked = yield* walkOn(input, named, start, rows, () => void 0, calls, neededCarry?.saved, neededCarry === void 0 ? reachedRuns : void 0);
|
|
737
|
+
const walked = yield* walkOn(input, named, start, rows, () => void 0, calls, roots, neededCarry?.saved, neededCarry === void 0 ? reachedRuns : void 0);
|
|
685
738
|
return saving({
|
|
686
739
|
...carried,
|
|
687
740
|
n: "more" in walked ? { saved: walked.more } : { done: walked.runs }
|
|
@@ -694,7 +747,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
694
747
|
return first.start.filter((oid) => !needed.has(oid));
|
|
695
748
|
}));
|
|
696
749
|
if (neededDone !== void 0 && behind.length > 0) {
|
|
697
|
-
const walked = yield* walkOn(input, named, behind, rows, () => void 0, calls, void 0, neededDone);
|
|
750
|
+
const walked = yield* walkOn(input, named, behind, rows, () => void 0, calls, roots, void 0, neededDone);
|
|
698
751
|
return saving({
|
|
699
752
|
...carried,
|
|
700
753
|
n: "more" in walked ? { saved: walked.more } : { done: walked.runs }
|
|
@@ -724,7 +777,10 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
724
777
|
}, rowOids, landed);
|
|
725
778
|
return went(yield* resumeMerge(input, merge, most, calls, listing), "kept");
|
|
726
779
|
}
|
|
727
|
-
if (redos + 1 >= 3) return {
|
|
780
|
+
if (redos + 1 >= 3) return {
|
|
781
|
+
waits: `pushes moved its refs onto what its rewrite was about to drop, 3 times in a row`,
|
|
782
|
+
busy: true
|
|
783
|
+
};
|
|
728
784
|
return {
|
|
729
785
|
step: droppedStep(merge),
|
|
730
786
|
mark: {
|
|
@@ -831,8 +887,9 @@ const passDue = (input, prune, read, objectRows) => {
|
|
|
831
887
|
* that died or failed, waits for the next period, as does one whose walk is past what one walk
|
|
832
888
|
* holds or makes no step, and one whose rewrite pushes caught up with `redosMost` times: each
|
|
833
889
|
* writes the wait to its mark and drops its merge under way, with a log line. A pass that waits
|
|
834
|
-
* before its walk logs too, and writes nothing
|
|
835
|
-
*
|
|
890
|
+
* before its walk logs too, and writes nothing but its mark's end of a count of periods pushes
|
|
891
|
+
* held it, as every wait for anything but pushes does. `step` is `undefined` when no pass is
|
|
892
|
+
* due; `next` is when the next one is, and `undefined` for a repo that holds no object.
|
|
836
893
|
*/
|
|
837
894
|
const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, repack, read, objectRows, drops, holds, retried = false, calls) {
|
|
838
895
|
const due = passDue(input, prune, read, objectRows);
|
|
@@ -848,11 +905,13 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
848
905
|
const last = read.pass?.at;
|
|
849
906
|
const markHeld = markHolds(read.mark);
|
|
850
907
|
const merge = read.merges.prune;
|
|
908
|
+
const uncounted = countEnded(read);
|
|
909
|
+
const waitsElse = (step) => uncounted === void 0 ? step : alsoPuts(step, uncounted);
|
|
851
910
|
if (holds.length > 0) {
|
|
852
911
|
const after = input.at + pruneFloor;
|
|
853
912
|
yield* Effect.logWarning(`git.repack's prune pass of repo ${input.listed.repo}, due ${iso(next)}, waits until ${iso(after)}: held by ${holds.join(", ")}, as an import's segments are reached by no ref till it publishes`);
|
|
854
913
|
return {
|
|
855
|
-
step: merge === void 0 ? void 0 : droppedStep(merge),
|
|
914
|
+
step: waitsElse(merge === void 0 ? void 0 : droppedStep(merge)),
|
|
856
915
|
next: after
|
|
857
916
|
};
|
|
858
917
|
}
|
|
@@ -880,7 +939,7 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
880
939
|
const most = (repack === false ? void 0 : repack.maxPackSize) ?? defaultRepack.maxPackSize;
|
|
881
940
|
const until = input.at + pruneWait(prune);
|
|
882
941
|
const later = (why) => Effect.as(Effect.logWarning(`git.repack's prune pass of repo ${input.listed.repo}, due ${iso(next)}, waits until ${iso(until)}: ${why}`), {
|
|
883
|
-
step: void 0,
|
|
942
|
+
step: waitsElse(void 0),
|
|
884
943
|
next: until
|
|
885
944
|
});
|
|
886
945
|
const { rows } = objectRows;
|
|
@@ -910,23 +969,34 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
910
969
|
step: void 0,
|
|
911
970
|
next: started.waits
|
|
912
971
|
};
|
|
913
|
-
const waits = (why) => {
|
|
972
|
+
const waits = (why, busy = false) => {
|
|
973
|
+
const periods = (started.periods ?? 0) + 1;
|
|
974
|
+
const value = busy ? {
|
|
975
|
+
at: started.at,
|
|
976
|
+
waits: until,
|
|
977
|
+
periods
|
|
978
|
+
} : {
|
|
979
|
+
at: started.at,
|
|
980
|
+
waits: until
|
|
981
|
+
};
|
|
914
982
|
const mark = {
|
|
915
983
|
...pruneStartedKey,
|
|
916
|
-
value
|
|
917
|
-
at: started.at,
|
|
918
|
-
waits: until
|
|
919
|
-
}
|
|
984
|
+
value
|
|
920
985
|
};
|
|
921
|
-
const
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
986
|
+
const change = merge === void 0 ? {
|
|
987
|
+
put: [mark],
|
|
988
|
+
rows: noRows
|
|
989
|
+
} : {
|
|
990
|
+
put: [mark],
|
|
991
|
+
delete: [mergeKey(merge.pack)],
|
|
992
|
+
rows: noRows
|
|
993
|
+
};
|
|
994
|
+
const step = busy ? {
|
|
995
|
+
change,
|
|
996
|
+
more: true,
|
|
997
|
+
busy: periods
|
|
998
|
+
} : {
|
|
999
|
+
change,
|
|
930
1000
|
more: true
|
|
931
1001
|
};
|
|
932
1002
|
return Effect.as(later(why), {
|
|
@@ -936,7 +1006,7 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
936
1006
|
};
|
|
937
1007
|
if (retried) return yield* waits("its last try died or failed with the pass under way");
|
|
938
1008
|
const stepped = yield* passSteps(input, read, packs, rows, most, calls).pipe(Effect.catchTag("PruneWalkTooLarge", (refused) => fail("RESOURCE_EXHAUSTED", `The prune pass is past what one walk holds: ${refused.message}`, { context: { reason: "prune-walk-too-large" } })));
|
|
939
|
-
if ("waits" in stepped) return yield* waits(stepped.waits);
|
|
1009
|
+
if ("waits" in stepped) return yield* waits(stepped.waits, "busy" in stepped);
|
|
940
1010
|
const { change } = stepped.step;
|
|
941
1011
|
const patch = "mark" in stepped ? stepped.mark : void 0;
|
|
942
1012
|
const step = patch === void 0 ? stepped.step : {
|
|
@@ -953,7 +1023,7 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
953
1023
|
const rewalk = {
|
|
954
1024
|
put: [{
|
|
955
1025
|
...pruneStartedKey,
|
|
956
|
-
value:
|
|
1026
|
+
value: periodsOf(started)
|
|
957
1027
|
}],
|
|
958
1028
|
rows: noRows
|
|
959
1029
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { millis } from "../contracts/promises.mjs";
|
|
2
|
+
import { repoRootsMost } from "../store/records.mjs";
|
|
2
3
|
import { graphBytes } from "../protocol/packs/graph.mjs";
|
|
3
4
|
import { packIndexBytes } from "../protocol/packs/idx.mjs";
|
|
4
5
|
import { packPositionsBytes } from "../protocol/packs/pos.mjs";
|
|
@@ -66,9 +67,9 @@ const receiveTableMost = /* @__PURE__ */ Math.floor((2 ** 22 - 1) * 3 / 4);
|
|
|
66
67
|
* The most boundary commits an import segment's receive takes, 10,000, as `readyShallowsMost`
|
|
67
68
|
* bounds a shallow pack's: each is held as an ID in a set, with its parents the pack leaves out.
|
|
68
69
|
* Past it the receive is refused `too-large` before its pack is read, and the import halves its
|
|
69
|
-
* step.
|
|
70
|
+
* step. It's `repoRootsMost`, since a last segment's boundary becomes the repo's roots.
|
|
70
71
|
*/
|
|
71
|
-
const receiveBoundaryMost =
|
|
72
|
+
const receiveBoundaryMost = repoRootsMost;
|
|
72
73
|
/**
|
|
73
74
|
* The most parents of its boundary commits an import holds at once, 20,000, two for each of
|
|
74
75
|
* `receiveBoundaryMost`, as a frontier of merges needs: halving a step doesn't narrow a frontier.
|
package/dist/storage/visible.mjs
CHANGED
|
@@ -30,7 +30,8 @@ const visibleTooLong = (most) => gitError("RESOURCE_EXHAUSTED", `${tooLongText}
|
|
|
30
30
|
/** Whether `error` is a set's refusal past its walk's bound, which a caller may tell in its own words. */
|
|
31
31
|
const isVisibleTooLong = (error) => error.code === "RESOURCE_EXHAUSTED" && error.message.startsWith(tooLongText);
|
|
32
32
|
/**
|
|
33
|
-
* The objects `input.tips` reach in `listed`,
|
|
33
|
+
* The objects `input.tips` reach in `listed`, through no parent of `input.roots`, read through
|
|
34
|
+
* `objects`, the repo's whole objects.
|
|
34
35
|
* Nothing is read until the set is first asked. Its walk's state is the set's own: it lives with
|
|
35
36
|
* one request's view, for one caller, and is never shared across callers. A batch of the walk
|
|
36
37
|
* that fails to read changes none of it, so an ask that fails leaves the set as it was, and the
|
|
@@ -54,7 +55,7 @@ const walkedVisible = (objects, listed, input, walk = {}) => {
|
|
|
54
55
|
const stepped = (oid) => Effect.flatMap(walk.read(listed, {
|
|
55
56
|
oid,
|
|
56
57
|
...call
|
|
57
|
-
}), (object) => object === void 0 ? Effect.succeed(void 0) : stepsOf(object, !commits));
|
|
58
|
+
}), (object) => object === void 0 ? Effect.succeed(void 0) : stepsOf(object, !commits, input.roots));
|
|
58
59
|
const found = yield* Effect.forEach(batch, stepped, { concurrency: 16 });
|
|
59
60
|
frontier = frontier.slice(walkBatch);
|
|
60
61
|
reads += batch.length;
|
package/dist/storage/walk.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import "../contracts/objects.mjs";
|
|
|
3
3
|
import "../contracts/result.mjs";
|
|
4
4
|
import "../contracts/store.mjs";
|
|
5
5
|
import "../protocol/bytes/errors.mjs";
|
|
6
|
+
import "../protocol/objects/commit.mjs";
|
|
6
7
|
import "./object-rows.mjs";
|
|
7
8
|
import "./pack-reads.mjs";
|
|
8
9
|
import "effect/Effect";
|
package/dist/storage/walk.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
|
-
import { decodeCommit } from "../protocol/objects/commit.mjs";
|
|
2
|
+
import { decodeCommit, noRepoRoots, parentsWithin } from "../protocol/objects/commit.mjs";
|
|
3
3
|
import { decodeTag } from "../protocol/objects/tag.mjs";
|
|
4
4
|
import { treeEntriesIn, treeReader } from "../protocol/objects/tree.mjs";
|
|
5
5
|
import "./links.mjs";
|
|
@@ -35,8 +35,11 @@ const treeEntriesOf = (bytes) => {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
const unreadable = (object, message) => gitError("DATA_LOSS", `The ${object.type} ${object.oid} is unreadable: ${message}`);
|
|
38
|
-
/**
|
|
39
|
-
|
|
38
|
+
/**
|
|
39
|
+
* What a plan takes from an object it read: bytes it holds that Git wouldn't take are `DATA_LOSS`.
|
|
40
|
+
* One of `roots` has no history, so no walk follows its parents, but its tree is followed.
|
|
41
|
+
*/
|
|
42
|
+
const takenOf = (object, roots) => {
|
|
40
43
|
const read = {
|
|
41
44
|
oid: object.oid,
|
|
42
45
|
type: object.type,
|
|
@@ -54,7 +57,7 @@ const takenOf = (object) => {
|
|
|
54
57
|
})), Effect.mapError(lossOf));
|
|
55
58
|
case "commit": return decodeCommit(object.bytes).pipe(Effect.map((commit) => ({
|
|
56
59
|
...read,
|
|
57
|
-
history: commit.parents,
|
|
60
|
+
history: parentsWithin(roots, object.oid, commit.parents),
|
|
58
61
|
tree: commit.tree
|
|
59
62
|
})), Effect.mapError(lossOf));
|
|
60
63
|
case "tree": return Effect.suspend(() => Effect.fromResult(treeEntriesOf(object.bytes))).pipe(Effect.map((entries) => ({
|
|
@@ -85,6 +88,7 @@ const tooManyReads = (readsMost) => gitError("RESOURCE_EXHAUSTED", `This fetch's
|
|
|
85
88
|
* what's paid for trees and into what's paid for them, so each string is counted once.
|
|
86
89
|
*/
|
|
87
90
|
const countedReads = (reads, readsMost, charge, calls, release) => {
|
|
91
|
+
const roots = reads.roots ?? noRepoRoots;
|
|
88
92
|
let counted = 0;
|
|
89
93
|
let entryBytesHeld = 0;
|
|
90
94
|
let entryBytesPaid = 0;
|
|
@@ -113,7 +117,7 @@ const countedReads = (reads, readsMost, charge, calls, release) => {
|
|
|
113
117
|
for (let at = 0; at < oids.length; at += 64) yield* each(oids.slice(at, at + 64), Effect.fnUntraced(function* (object) {
|
|
114
118
|
const entries = object.type === "tree" ? treeEntriesIn(object.bytes) : 0;
|
|
115
119
|
yield* holdEntries(entries);
|
|
116
|
-
const taken = yield* takenOf(object);
|
|
120
|
+
const taken = yield* takenOf(object, roots);
|
|
117
121
|
entryBytesHeld -= (entries - keptOf(taken)) * 70;
|
|
118
122
|
found.set(object.oid, taken);
|
|
119
123
|
}));
|