@ref0/git 0.11.0 → 0.14.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/access/private-refs.mjs +8 -7
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +1 -17
- package/dist/auth/helpers.mjs +3 -11
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- package/dist/auth/tokens-layer.d.mts +1 -2
- package/dist/auth/tokens-layer.mjs +2 -3
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +1 -8
- package/dist/auth/tokens.mjs +1 -8
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/git-http.mjs +18 -4
- package/dist/client/push-upload.mjs +33 -7
- package/dist/client/remote.mjs +94 -28
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +2 -2
- package/dist/contracts/client.d.mts +8 -3
- package/dist/contracts/commits.d.mts +10 -2
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/files.d.mts +2 -2
- package/dist/contracts/forks.d.mts +14 -3
- package/dist/contracts/git.d.mts +41 -12
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/lfs.d.mts +0 -7
- package/dist/contracts/objects.d.mts +80 -10
- package/dist/contracts/operations.d.mts +3 -0
- package/dist/contracts/operations.mjs +12 -2
- package/dist/contracts/push-uploads.d.mts +44 -5
- package/dist/contracts/push-uploads.mjs +7 -3
- package/dist/contracts/refs.d.mts +28 -6
- package/dist/contracts/remote.mjs +1 -3
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +90 -2
- package/dist/contracts/repos.mjs +29 -2
- package/dist/contracts/result.d.mts +30 -23
- package/dist/contracts/result.mjs +24 -9
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +28 -77
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/sync.d.mts +90 -19
- package/dist/contracts/sync.mjs +34 -10
- package/dist/contracts/tokens.d.mts +1 -6
- package/dist/contracts/tokens.mjs +1 -2
- package/dist/contracts/topics.d.mts +0 -5
- package/dist/contracts/work.d.mts +66 -2
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.d.mts +1 -0
- package/dist/core/access.mjs +34 -13
- package/dist/core/ancestry.d.mts +9 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +68 -0
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +2 -1
- package/dist/core/events/deliver.d.mts +1 -0
- package/dist/core/events/deliver.mjs +15 -3
- package/dist/core/forks.mjs +42 -16
- package/dist/core/imports.mjs +156 -13
- package/dist/core/index-job.mjs +9 -6
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/commits.mjs +16 -6
- package/dist/core/objects/reading.mjs +17 -9
- package/dist/core/parts.d.mts +8 -2
- package/dist/core/parts.mjs +1 -4
- package/dist/core/purge.mjs +76 -6
- package/dist/core/push-decide.mjs +1 -1
- package/dist/core/push-files.d.mts +12 -0
- package/dist/core/push-files.mjs +225 -0
- package/dist/core/push-repo.d.mts +8 -0
- package/dist/core/push-repo.mjs +56 -0
- package/dist/core/push.d.mts +17 -0
- package/dist/core/push.mjs +107 -32
- package/dist/core/receipts.mjs +26 -10
- package/dist/core/ref-view.mjs +59 -5
- package/dist/core/refs.mjs +18 -10
- package/dist/core/registered-rows.mjs +7 -5
- package/dist/core/repack.mjs +16 -11
- package/dist/core/repo-info.mjs +16 -9
- package/dist/core/repos.mjs +30 -14
- package/dist/core/saved-caller-views.d.mts +18 -0
- package/dist/core/saved-caller-views.mjs +17 -4
- package/dist/core/saved-callers-public.d.mts +3 -3
- package/dist/core/saved-callers-public.mjs +3 -2
- package/dist/core/saved-callers.d.mts +7 -0
- package/dist/core/seam.mjs +2 -2
- package/dist/core/view.d.mts +6 -0
- package/dist/core/view.mjs +45 -12
- package/dist/core/work.mjs +47 -22
- package/dist/effect.d.mts +3 -1
- package/dist/effect.mjs +3 -1
- package/dist/engine/reads.mjs +13 -6
- package/dist/engine/walk.mjs +4 -4
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +1 -1
- package/dist/event-streams/stream.mjs +1 -1
- package/dist/extend.d.mts +4 -3
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +4 -2
- package/dist/http/core-parts.mjs +64 -15
- package/dist/http/handler.mjs +2 -2
- package/dist/http/node.mjs +5 -4
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +503 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +120 -59
- package/dist/http/upload-pack.mjs +7 -6
- package/dist/index.d.mts +23 -24
- package/dist/index.mjs +4 -7
- package/dist/lfs/base.d.mts +7 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/copy.d.mts +46 -0
- package/dist/lfs/copy.mjs +26 -0
- package/dist/lfs/layer.mjs +4 -2
- package/dist/lfs/locks.mjs +14 -9
- package/dist/lfs/objects.d.mts +6 -0
- package/dist/lfs/objects.mjs +95 -61
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
- package/dist/protocol/bytes/sha256.d.mts +32 -0
- package/dist/protocol/bytes/sha256.mjs +105 -49
- package/dist/protocol/wire/advertisement.mjs +9 -4
- package/dist/protocol/wire/lines.d.mts +4 -2
- package/dist/protocol/wire/lines.mjs +11 -5
- package/dist/protocol/wire/push-uploads.mjs +13 -1
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/protocol.d.mts +3 -1
- package/dist/protocol.mjs +3 -1
- package/dist/queue/advance.mjs +1 -1
- package/dist/queue/calls.mjs +21 -1
- package/dist/queue/host.d.mts +1 -7
- package/dist/queue/host.mjs +1 -7
- package/dist/queue/layer.mjs +1 -1
- package/dist/queue/trim.mjs +1 -1
- package/dist/rest/blobs.d.mts +16 -8
- package/dist/rest/blobs.mjs +1 -1
- package/dist/rest/caller.d.mts +49 -9
- package/dist/rest/caller.mjs +1 -1
- package/dist/rest/client.d.mts +10 -3
- package/dist/rest/client.mjs +4 -0
- package/dist/rest/commits.d.mts +272 -239
- package/dist/rest/errors.d.mts +24 -4
- package/dist/rest/events.d.mts +9 -6
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/files.d.mts +112 -100
- package/dist/rest/forks.d.mts +146 -122
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.d.mts +1 -1
- package/dist/rest/handlers.mjs +18 -4
- package/dist/rest/layer.mjs +10 -2
- package/dist/rest/me.d.mts +8 -4
- package/dist/rest/merges.d.mts +8 -4
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/queue.d.mts +292 -236
- package/dist/rest/refs.d.mts +98 -69
- package/dist/rest/repos.d.mts +133 -105
- package/dist/rest/tags.d.mts +100 -88
- package/dist/rest/tokens.d.mts +192 -168
- package/dist/rest/topics.d.mts +154 -134
- package/dist/rest/trees.d.mts +32 -16
- package/dist/rest/work.d.mts +467 -20
- package/dist/rest/work.mjs +8 -0
- package/dist/server/edge-node.d.mts +9 -13
- package/dist/server/edge-node.mjs +9 -12
- package/dist/server/git-layer.d.mts +1 -6
- package/dist/server/git-layer.mjs +2 -2
- package/dist/server/git-namespace.d.mts +4 -4
- package/dist/server/joined.d.mts +15 -22
- package/dist/server/joined.mjs +5 -29
- package/dist/server/lifecycle.mjs +107 -23
- package/dist/server/registry.mjs +9 -1
- package/dist/server/server.mjs +139 -216
- package/dist/storage/budget.mjs +2 -2
- package/dist/storage/clean-up.mjs +13 -10
- package/dist/storage/fetch.mjs +13 -8
- package/dist/storage/file-limits.mjs +24 -0
- package/dist/storage/index-build.d.mts +1 -0
- package/dist/storage/index-build.mjs +106 -62
- package/dist/storage/index-fetch.mjs +16 -3
- package/dist/storage/index-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +8 -1
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.mjs +3 -1
- package/dist/storage/memory-budget.mjs +154 -8
- package/dist/storage/merge-cut.mjs +5 -4
- package/dist/storage/pack-reads.mjs +246 -34
- package/dist/storage/pack-receive.mjs +83 -25
- package/dist/storage/packs.mjs +37 -21
- package/dist/storage/prune-keep.mjs +203 -34
- package/dist/storage/prune-seen.mjs +11 -6
- package/dist/storage/prune-walk.mjs +219 -81
- package/dist/storage/prune.mjs +629 -196
- package/dist/storage/push-uploads.mjs +36 -12
- package/dist/storage/quarantine.mjs +9 -7
- package/dist/storage/ready.mjs +47 -19
- package/dist/storage/receive-bounds.mjs +29 -8
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.mjs +12 -1
- package/dist/storage/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/stream-whole.mjs +5 -2
- package/dist/storage/visible.mjs +29 -1
- package/dist/storage/walk.mjs +2 -1
- package/dist/store/catalogue.mjs +1 -0
- package/dist/store/cursor-seal-namespace.d.mts +2 -0
- package/dist/store/cursor-seal-public.d.mts +5 -0
- package/dist/store/cursor-seal-public.mjs +5 -0
- package/dist/store/cursor-seal.d.mts +16 -2
- package/dist/store/cursor-seal.mjs +26 -14
- package/dist/store/errors.mjs +9 -1
- package/dist/store/records.d.mts +2 -0
- package/dist/store/records.mjs +9 -6
- package/dist/store/repo-record.d.mts +27 -0
- package/dist/store/repo-record.mjs +141 -4
- package/dist/store/scopes.mjs +10 -2
- package/dist/sync/bound.d.mts +2 -0
- package/dist/sync/bound.mjs +11 -2
- package/dist/sync/github.d.mts +6 -1
- package/dist/sync/github.mjs +63 -42
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +4 -2
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +119 -0
- package/dist/sync/lfs-copy.mjs +251 -0
- package/dist/sync/mirror.mjs +227 -147
- package/dist/sync/said.mjs +204 -0
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +33 -13
- package/dist/sync/tries.mjs +71 -24
- package/dist/sync.d.mts +2 -2
- package/dist/topics/advance.mjs +10 -3
- package/dist/topics/host.mjs +1 -19
- package/dist/topics/layer.mjs +1 -1
- package/package.json +3 -8
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- package/dist/core/purge.d.mts +0 -8
- package/dist/core/registered-rows.d.mts +0 -4
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- package/dist/server/registry.d.mts +0 -16
- package/dist/server/server.d.mts +0 -36
- package/dist/storage/repack-job.d.mts +0 -3
- package/dist/topics/host.d.mts +0 -7
|
@@ -7,10 +7,10 @@ import { readerFloors, readerMost } from "./budget.mjs";
|
|
|
7
7
|
import { readWhole } from "./calls.mjs";
|
|
8
8
|
import { putOnce } from "./index-build.mjs";
|
|
9
9
|
import { runKey } from "./layout.mjs";
|
|
10
|
-
import { pruneSeenBytes, upkeepMemoryOf, upkeepRuns, upkeepTooLarge } from "./memory-budget.mjs";
|
|
11
|
-
import { blockBytes, blocksHeld, indexBytes, packReader } from "./pack-reads.mjs";
|
|
10
|
+
import { pruneIndexFloor, pruneSeenBytes, upkeepMemoryOf, upkeepRuns, upkeepTooLarge } from "./memory-budget.mjs";
|
|
11
|
+
import { blockBytes, blocksHeld, indexBytes, isIndexReloaded, isIndexShort, packReader } from "./pack-reads.mjs";
|
|
12
12
|
import { SeenSaved, seenSet } from "./prune-seen.mjs";
|
|
13
|
-
import { StoredRuns, dedupeTableBytes, dropRuns, mergeHeld, mergeRuns, narrowed, narrowedCalls, runWriter, writerHeld } from "./runs.mjs";
|
|
13
|
+
import { StoredRuns, dedupeTableBytes, dropRuns, mergeHeld, mergeRuns, narrowed, narrowedCalls, runWriter, wholeRows, writerHeld } from "./runs.mjs";
|
|
14
14
|
import { countedReads } from "./walk.mjs";
|
|
15
15
|
import * as Effect from "effect/Effect";
|
|
16
16
|
import * as Schema from "effect/Schema";
|
|
@@ -80,6 +80,15 @@ const pruneWalkSizes = (objects, blocks) => {
|
|
|
80
80
|
blocks: blocksHeld(Math.min(8, Math.max(1, blocks)))
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* The calls a walk `spent` makes, at most, to save where it starts, from at most `start` IDs over
|
|
85
|
+
* `objects` objects: its refs' put, and the save its first admission reserves, `5` and the IDs'
|
|
86
|
+
* puts. A try reserves them before the merge a walk follows, so the walk's start save fits.
|
|
87
|
+
*/
|
|
88
|
+
const pruneWalkStartCalls = (objects, start) => {
|
|
89
|
+
const { runBytes } = pruneWalkSizes(objects, 1);
|
|
90
|
+
return 6 + 2 * Math.ceil(Math.max(1, start) * rowBytes / runBytes);
|
|
91
|
+
};
|
|
83
92
|
/** A walk's sizes at its bounds, the most any repo's take. */
|
|
84
93
|
const boundSizes = /* @__PURE__ */ pruneWalkSizes(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
85
94
|
/**
|
|
@@ -122,6 +131,10 @@ const WalkSaved = /* @__PURE__ */ Schema.Union([Schema.Struct({
|
|
|
122
131
|
frontier: StoredRuns,
|
|
123
132
|
at: Schema.optional(Schema.Struct({
|
|
124
133
|
last: LastId,
|
|
134
|
+
merge: Schema.Struct({
|
|
135
|
+
runs: StoredRuns,
|
|
136
|
+
places: Schema.Array(Count)
|
|
137
|
+
}),
|
|
125
138
|
reached: StoredRuns,
|
|
126
139
|
frontier: StoredRuns,
|
|
127
140
|
trees: StoredRuns
|
|
@@ -152,7 +165,8 @@ const walkKeys = (saved) => {
|
|
|
152
165
|
saved.frontier,
|
|
153
166
|
saved.at?.reached,
|
|
154
167
|
saved.at?.frontier,
|
|
155
|
-
saved.at?.trees
|
|
168
|
+
saved.at?.trees,
|
|
169
|
+
saved.at?.merge.runs
|
|
156
170
|
]).flatMap((each) => each?.keys ?? []);
|
|
157
171
|
return saved.phase === "history" ? [...keys, saved.seen.key] : keys;
|
|
158
172
|
};
|
|
@@ -169,18 +183,20 @@ const droppedOnRefusal = (walk, input, pack, _start, _missing, options = {}) =>
|
|
|
169
183
|
* frontier merged against the runs reached so far, which the merge carries on as the next
|
|
170
184
|
* level's, so a tree is read once and a blob put once, by the ID its tree names and never read.
|
|
171
185
|
* `missing` says what an object the repo doesn't hold does to the walk: a tree it passes over is
|
|
172
|
-
* marked reached, unread, so a keep of these runs is given the same `missing` (`
|
|
173
|
-
* fails on the mark. The empty tree is the reader's, held or not, as `
|
|
186
|
+
* marked reached, unread, so a keep of these runs is given the same `missing` (`keepBitsOn`), or
|
|
187
|
+
* fails on the mark. The empty tree is the reader's, held or not, as `keepBitsOn` holds it.
|
|
174
188
|
*
|
|
175
189
|
* With `calls`, a step whose forecast passes what the try has left isn't started: the walk ends
|
|
176
190
|
* with `more`, where it stopped, a history batch, a tree level or a tree partway through one, and a
|
|
177
191
|
* try given it as `saved` goes on from there, never from `start`. A batch reads as many objects as
|
|
178
|
-
* their delta chains' gets fit. A step that passes a whole try is refused by name
|
|
192
|
+
* their delta chains' gets fit. A step that passes a whole try is refused by name, but in a walk
|
|
193
|
+
* `spent`, after the try's other calls: it ends with `more`, where it was given or where it
|
|
194
|
+
* starts, for a fresh try to go on from.
|
|
179
195
|
* `known`'s rows, from an earlier walk, are reached already: a tree they hold isn't read again.
|
|
180
196
|
* A refused fresh walk drops its runs; one given `saved` or `known` keeps them. A test sets
|
|
181
197
|
* `treesAtOnce` below its bound.
|
|
182
198
|
*/
|
|
183
|
-
const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, start, missing, { rows = 0, treesAtOnce = pruneTreesAtOnce, calls, saved, known, roots } = {}) {
|
|
199
|
+
const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, start, missing, { rows = 0, treesAtOnce = pruneTreesAtOnce, calls, saved, known, roots, spent = false } = {}) {
|
|
184
200
|
const { allotment, listed } = input;
|
|
185
201
|
const objects = listed.packs.reduce((sum, each) => sum + each.objects, 0) + rows;
|
|
186
202
|
const blocks = listed.packs.reduce((sum, each) => sum + Math.ceil(each.bytes / blockBytes), 0);
|
|
@@ -196,14 +212,34 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
196
212
|
const outsideMost = rows + named;
|
|
197
213
|
const namesBytes = (saved === void 0 ? named : history?.pending.rows ?? 0) * 70;
|
|
198
214
|
const seenBytes = saved?.phase === "trees" ? 0 : pruneSeenBytes(listed.packs, outsideMost);
|
|
215
|
+
const past = listed.packs.find((each) => indexBytes(each) > pruneIndexFloor);
|
|
216
|
+
if (past !== void 0) return yield* new PruneWalkTooLarge({ message: `pack ${past.id}'s index takes ${indexBytes(past)} bytes, past the ${pruneIndexFloor} a prune walk's reader holds` });
|
|
199
217
|
const indexes = listed.packs.reduce((sum, each) => sum + indexBytes(each), 0);
|
|
200
|
-
|
|
218
|
+
let loadNeeds = () => 3;
|
|
219
|
+
let shortBy;
|
|
220
|
+
let loads = 0;
|
|
221
|
+
const canLoad = () => {
|
|
222
|
+
const needs = loadNeeds();
|
|
223
|
+
loads += 1;
|
|
224
|
+
if (loads === 1 && !spent || fits(calls, needs)) return true;
|
|
225
|
+
shortBy = needs;
|
|
226
|
+
return false;
|
|
227
|
+
};
|
|
228
|
+
const room = {
|
|
229
|
+
bytes: Math.min(indexes, pruneIndexFloor),
|
|
230
|
+
unlisted: outsideMost,
|
|
231
|
+
canLoad
|
|
232
|
+
};
|
|
233
|
+
const evicts = room.bytes < indexes;
|
|
234
|
+
const unlistedBytes = outsideMost * 70;
|
|
235
|
+
const charge = pruneWalkHeld(sizes) + namesBytes + seenBytes + room.bytes + unlistedBytes;
|
|
201
236
|
if (charge - own > allotment.growable) return yield* new PruneWalkTooLarge({ message: `its walk charges ${charge} bytes with its packs' indexes, past the ${own + allotment.growable} its allotment holds: the repo is past what one prune walk holds` });
|
|
202
|
-
const heldBytes = namesBytes + seenBytes;
|
|
237
|
+
const heldBytes = namesBytes + seenBytes + unlistedBytes;
|
|
203
238
|
yield* Effect.acquireRelease(allotment.grow(heldBytes, upkeepTooLarge), () => Effect.sync(() => allotment.shrink(heldBytes)));
|
|
204
239
|
const reader = packReader({
|
|
205
240
|
...input,
|
|
206
|
-
memory
|
|
241
|
+
memory,
|
|
242
|
+
indexFloor: room
|
|
207
243
|
});
|
|
208
244
|
let held = 0;
|
|
209
245
|
yield* Effect.addFinalizer(() => Effect.sync(() => allotment.shrink(held)));
|
|
@@ -218,25 +254,43 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
218
254
|
...reader,
|
|
219
255
|
roots
|
|
220
256
|
}, objects + 1e6, charged, void 0, release);
|
|
221
|
-
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return false;
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
return at;
|
|
257
|
+
/**
|
|
258
|
+
* `lookup`'s answer, or `undefined` once it needs a pack whose index the reader's room let go
|
|
259
|
+
* of, or a load past `loadNeeds`, which ends the try where it is, as one short of calls does
|
|
260
|
+
* (#2230).
|
|
261
|
+
*/
|
|
262
|
+
const unlessReloaded = (lookup) => lookup.pipe(Effect.catchIf((error) => isIndexReloaded(error) || isIndexShort(error), () => Effect.succeed(void 0)));
|
|
263
|
+
/** A level stopped before `trees` on a lookup `unlessReloaded` ended: past the room or the calls. */
|
|
264
|
+
const stoppedOn = (trees) => shortBy === void 0 ? new WalkStopped({
|
|
265
|
+
trees,
|
|
266
|
+
needs: 0,
|
|
267
|
+
reloaded: true
|
|
268
|
+
}) : new WalkStopped({
|
|
269
|
+
trees,
|
|
270
|
+
needs: shortBy
|
|
239
271
|
});
|
|
272
|
+
/** `groups` as one list, and the end of each in it, so a batch takes from one group. */
|
|
273
|
+
const grouped = (groups) => {
|
|
274
|
+
const ends = [];
|
|
275
|
+
let end = 0;
|
|
276
|
+
for (const group of groups) {
|
|
277
|
+
end += group.length;
|
|
278
|
+
ends.push(end);
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
oids: groups.flat(),
|
|
282
|
+
ends
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* `ids` split in two, those to look up now and those after: a try's first alone while the room
|
|
287
|
+
* may let packs go, so its lookups need one pack's index, or every pack's once for an ID none
|
|
288
|
+
* holds, and the try moves. Many at once may let go of a pack they're in, which a try that
|
|
289
|
+
* moved ends on, to go on in the next (#2230).
|
|
290
|
+
*/
|
|
291
|
+
const alone = (ids) => !moved && evicts && ids.length > 1 ? [ids.slice(0, 1), ids.slice(1)] : [ids, []];
|
|
292
|
+
/** The end of the group `at` is in, of `ends`. */
|
|
293
|
+
const groupEnd = (ends, at) => ends.find((end) => end > at) ?? at;
|
|
240
294
|
/** Lets go of what `found` holds of `batch`, once each of it is put. */
|
|
241
295
|
const letGo = (found, batch) => {
|
|
242
296
|
for (const object of found.values()) reads.letGo(object);
|
|
@@ -282,6 +336,17 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
282
336
|
const reads = merged.lengths.reduce((sum, length) => sum + Math.ceil(length / readBytes), 0);
|
|
283
337
|
return reads + (merged.keys.length > ways ? reads + Math.ceil(merged.keys.length / ways) : 0) + putCalls(objects) + 1;
|
|
284
338
|
};
|
|
339
|
+
/**
|
|
340
|
+
* What a merge going on from its save's places calls yet, a forecast: each run's reads from its
|
|
341
|
+
* place's read, as `mergeRuns` seeks it, none narrowing, and its reached writer's puts (#2231).
|
|
342
|
+
*/
|
|
343
|
+
const restCalls = (merge) => {
|
|
344
|
+
const readBytes = wholeRows(rowBytes, sizes.runs.readBytes);
|
|
345
|
+
return merge.runs.lengths.reduce((sum, length, run) => {
|
|
346
|
+
const start = (merge.places[run] ?? 0) * rowBytes;
|
|
347
|
+
return start >= length ? sum : sum + Math.ceil((length - start + start % readBytes) / readBytes);
|
|
348
|
+
}, 0) + putCalls(objects) + 1;
|
|
349
|
+
};
|
|
285
350
|
const saveCalls = 3 + putCalls(atOnce);
|
|
286
351
|
const findCalls = 2;
|
|
287
352
|
const headerGets = 2;
|
|
@@ -346,6 +411,8 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
346
411
|
let moved = false;
|
|
347
412
|
const most = calls === void 0 ? 0 : Math.min(calls.most.bucket, calls.most.subrequests);
|
|
348
413
|
const tooMany = (step, needs) => new PruneWalkTooLarge({ message: `${step} needs about ${needs} calls, past the ${most} a try makes` });
|
|
414
|
+
const given = spent && saved !== void 0 ? { more: saved } : void 0;
|
|
415
|
+
const pastRoom = (step) => new PruneWalkTooLarge({ message: `${step} needs more packs' indexes than the ${room.bytes} bytes its reader holds` });
|
|
349
416
|
let refs;
|
|
350
417
|
if (saved === void 0) {
|
|
351
418
|
const refsWriter = writer("refs", sizes.runBytes);
|
|
@@ -367,8 +434,8 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
367
434
|
let prior;
|
|
368
435
|
let seenFrom;
|
|
369
436
|
if (history !== void 0) {
|
|
370
|
-
const rebuild = narrowedCalls(history.reached.lengths, rowBytes, sizes.runs, input.bucket.multipart).calls + narrowedCalls(history.frontier.lengths, rowBytes, sizes.runs, input.bucket.multipart).calls + mergeCalls(history.pending) + 1;
|
|
371
|
-
if (!fits(calls, rebuild + 6)) return yield* tooMany("a history resume", rebuild + 6);
|
|
437
|
+
const rebuild = narrowedCalls(history.reached.lengths, rowBytes, sizes.runs, input.bucket.multipart).calls + narrowedCalls(history.frontier.lengths, rowBytes, sizes.runs, input.bucket.multipart).calls + mergeCalls(history.pending) + 1 + (history.seen.outside === 0 ? 0 : 3 * listed.packs.filter(({ id }) => !history.seen.packs.some((each) => each.id === id)).length);
|
|
438
|
+
if (!fits(calls, rebuild + 6)) return given ?? (yield* tooMany("a history resume", rebuild + 6));
|
|
372
439
|
const bytes = yield* readWhole(input.bucket, history.seen.key);
|
|
373
440
|
if (bytes === void 0) return yield* Effect.fail(gitError("DATA_LOSS", `The walk's seen object ${history.seen.key} is gone`));
|
|
374
441
|
seenFrom = {
|
|
@@ -388,59 +455,108 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
388
455
|
}
|
|
389
456
|
const seen = yield* seenSet(listed.packs, outsideMost, seenFrom === void 0 ? void 0 : {
|
|
390
457
|
...seenFrom,
|
|
391
|
-
place:
|
|
458
|
+
place: (oids) => reader.ranks(oids, new Set(seenFrom?.saved.packs.map(({ id }) => id)))
|
|
392
459
|
});
|
|
460
|
+
if (seenFrom !== void 0) reader.release();
|
|
461
|
+
loadNeeds = () => 8 + putCalls(names.length + parents.length);
|
|
393
462
|
const reached = writer("reached-0", sizes.runBytes);
|
|
394
463
|
const frontier = frontierWriter("frontier-0");
|
|
464
|
+
/** Where the history is, saved for the next try: its runs, the IDs yet to read, and its seen set. */
|
|
465
|
+
const savedHistory = Effect.fnUntraced(function* () {
|
|
466
|
+
const reachedRuns = yield* reached.finish;
|
|
467
|
+
const frontierRuns = yield* frontier.finish;
|
|
468
|
+
const pending = writer("pending", sizes.runBytes);
|
|
469
|
+
for (const oid of names) yield* put(pending, oidBytes(oid), tags.tree);
|
|
470
|
+
for (const oid of parents) yield* put(pending, oidBytes(oid), tags.reached);
|
|
471
|
+
const key = runKey(pack, `seen.${tried}`, 0);
|
|
472
|
+
const { layout, bytes } = seen.saved(key);
|
|
473
|
+
yield* putOnce(input.bucket, key, bytes);
|
|
474
|
+
return { more: {
|
|
475
|
+
phase: "history",
|
|
476
|
+
count: seen.size(),
|
|
477
|
+
seen: layout,
|
|
478
|
+
refs,
|
|
479
|
+
reached: after(prior?.reached, reachedRuns),
|
|
480
|
+
frontier: after(prior?.frontier, frontierRuns),
|
|
481
|
+
pending: yield* pending.finish,
|
|
482
|
+
known: knownRuns
|
|
483
|
+
} };
|
|
484
|
+
});
|
|
485
|
+
/** The try ended where it is: saved, or refused if it walked nothing. */
|
|
486
|
+
const stopHere = () => moved || spent ? given !== void 0 && !moved ? Effect.succeed(given) : savedHistory() : Effect.fail(shortBy === void 0 ? pastRoom("a history batch") : tooMany("a history batch", shortBy));
|
|
487
|
+
/**
|
|
488
|
+
* The next IDs to read, the names' before the parents': those the first pack that holds some
|
|
489
|
+
* of them holds, as `nextPack` finds it, or all of them once no listed pack holds any;
|
|
490
|
+
* `undefined` once only packs the room let go of may hold what's left, which the next try
|
|
491
|
+
* reads.
|
|
492
|
+
*/
|
|
493
|
+
const nextLevel = Effect.fnUntraced(function* () {
|
|
494
|
+
for (const fromNames of [true, false]) {
|
|
495
|
+
const pool = fromNames ? names : parents;
|
|
496
|
+
if (pool.length === 0) continue;
|
|
497
|
+
const { placed, unlisted } = yield* reader.nextPack(pool);
|
|
498
|
+
if (placed.size === 0 && !unlisted) continue;
|
|
499
|
+
const level = unlisted ? [...new Set(pool)] : [...placed.keys()];
|
|
500
|
+
const rest = unlisted ? [] : pool.filter((oid) => !placed.has(oid));
|
|
501
|
+
if (fromNames) names = rest;
|
|
502
|
+
else parents = rest;
|
|
503
|
+
return {
|
|
504
|
+
fromNames,
|
|
505
|
+
level,
|
|
506
|
+
placed
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
});
|
|
395
510
|
while (names.length > 0 || parents.length > 0) {
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
511
|
+
const step = yield* unlessReloaded(nextLevel());
|
|
512
|
+
if (step === void 0) return yield* stopHere();
|
|
513
|
+
const { fromNames, level, placed } = step;
|
|
514
|
+
const back = (at) => {
|
|
515
|
+
if (fromNames) names = [...level.slice(at), ...names];
|
|
516
|
+
else parents = [...level.slice(at), ...parents];
|
|
517
|
+
};
|
|
400
518
|
for (let at = 0; at < level.length;) {
|
|
401
519
|
const left = level.length - at + names.length + parents.length;
|
|
402
|
-
const
|
|
520
|
+
const admission = yield* unlessReloaded(admitted(level.slice(at, at + 64), 5 + putCalls(left)));
|
|
521
|
+
if (admission === void 0) {
|
|
522
|
+
back(at);
|
|
523
|
+
return yield* stopHere();
|
|
524
|
+
}
|
|
525
|
+
const { count: admits, needs } = admission;
|
|
403
526
|
if (admits === 0) {
|
|
404
|
-
if (!moved
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
const rest = level.slice(at);
|
|
409
|
-
for (const oid of fromNames ? [...rest, ...names] : names) yield* put(pending, oidBytes(oid), tags.tree);
|
|
410
|
-
for (const oid of fromNames ? parents : [...rest, ...parents]) yield* put(pending, oidBytes(oid), tags.reached);
|
|
411
|
-
const key = runKey(pack, `seen.${tried}`, 0);
|
|
412
|
-
const { layout, bytes } = seen.saved(key);
|
|
413
|
-
yield* putOnce(input.bucket, key, bytes);
|
|
414
|
-
return { more: {
|
|
415
|
-
phase: "history",
|
|
416
|
-
count: seen.size(),
|
|
417
|
-
seen: layout,
|
|
418
|
-
refs,
|
|
419
|
-
reached: after(prior?.reached, reachedRuns),
|
|
420
|
-
frontier: after(prior?.frontier, frontierRuns),
|
|
421
|
-
pending: yield* pending.finish,
|
|
422
|
-
known: knownRuns
|
|
423
|
-
} };
|
|
527
|
+
if (!moved && given !== void 0) return given;
|
|
528
|
+
if (!moved && !spent) return yield* tooMany("a history batch", needs);
|
|
529
|
+
back(at);
|
|
530
|
+
return yield* savedHistory();
|
|
424
531
|
}
|
|
425
|
-
moved = true;
|
|
426
532
|
const slice = level.slice(at, at + admits);
|
|
533
|
+
const looked = yield* unlessReloaded(Effect.gen(function* () {
|
|
534
|
+
const blobs = fromNames ? yield* reader.wholeBlobs(slice) : /* @__PURE__ */ new Set();
|
|
535
|
+
const unread = [...new Set(slice)].filter((oid) => !blobs.has(oid) && !seen.has(oid, placed.get(oid)));
|
|
536
|
+
return {
|
|
537
|
+
blobs,
|
|
538
|
+
unread,
|
|
539
|
+
found: unread.length === 0 ? /* @__PURE__ */ new Map() : yield* reads(unread)
|
|
540
|
+
};
|
|
541
|
+
}));
|
|
542
|
+
if (looked === void 0) {
|
|
543
|
+
back(at);
|
|
544
|
+
return yield* stopHere();
|
|
545
|
+
}
|
|
546
|
+
const { blobs, unread, found } = looked;
|
|
547
|
+
moved = true;
|
|
427
548
|
at += admits;
|
|
428
|
-
const blobs = fromNames ? yield* reader.wholeBlobs(slice) : /* @__PURE__ */ new Set();
|
|
429
|
-
const ranked = yield* ranksOf(slice);
|
|
430
|
-
const batch = [];
|
|
431
549
|
for (const oid of slice) {
|
|
432
|
-
const
|
|
433
|
-
const added = seen.add(oid, ranked.get(oid));
|
|
550
|
+
const added = seen.add(oid, placed.get(oid));
|
|
434
551
|
if (added === "full") return yield* Effect.fail(gitError("DATA_LOSS", `The walk reaches more than ${outsideMost} objects no listed pack holds: past its rows and refs`));
|
|
435
552
|
if (!added) continue;
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
553
|
+
const id = oidBytes(oid);
|
|
554
|
+
if (blobs.has(oid)) {
|
|
555
|
+
yield* put(reached, id, tags.reached);
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
441
558
|
const object = yield* foundOf(found, oid);
|
|
442
559
|
if (object === void 0) continue;
|
|
443
|
-
const id = oidBytes(oid);
|
|
444
560
|
if (object.type === "tree") {
|
|
445
561
|
yield* put(frontier, id, tags.tree);
|
|
446
562
|
continue;
|
|
@@ -450,7 +566,7 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
450
566
|
if (object.type === "tag") names.push(...object.history);
|
|
451
567
|
else parents.push(...object.history);
|
|
452
568
|
}
|
|
453
|
-
if (
|
|
569
|
+
if (unread.length > 0) yield* letGo(found, unread);
|
|
454
570
|
}
|
|
455
571
|
}
|
|
456
572
|
runs = after(prior?.reached, yield* reached.finish);
|
|
@@ -461,12 +577,14 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
461
577
|
let within = saved?.phase === "trees" ? saved.at : void 0;
|
|
462
578
|
for (let depth = from + 1; next.rows > 0; depth += 1) {
|
|
463
579
|
const merged = joined(runs, next, `join-${depth}.${tried}`);
|
|
464
|
-
const reserve = mergeCalls(merged);
|
|
465
580
|
const goesOn = within;
|
|
466
581
|
within = void 0;
|
|
582
|
+
const reserve = goesOn === void 0 ? mergeCalls(merged) : restCalls(goesOn.merge);
|
|
467
583
|
const needs = reserve + 2 + saveCalls;
|
|
584
|
+
loadNeeds = () => 3 + reserve + saveCalls;
|
|
468
585
|
if (!fits(calls, needs)) {
|
|
469
|
-
if (!moved
|
|
586
|
+
if (!moved && given !== void 0) return given;
|
|
587
|
+
if (!moved && !spent) return yield* tooMany(`level ${depth}`, needs);
|
|
470
588
|
return { more: {
|
|
471
589
|
phase: "trees",
|
|
472
590
|
commits,
|
|
@@ -480,18 +598,32 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
480
598
|
const frontier = frontierWriter(`frontier-${depth}`);
|
|
481
599
|
let trees = [];
|
|
482
600
|
const last = goesOn === void 0 ? /* @__PURE__ */ new Uint8Array(20) : oidBytes(goesOn.last);
|
|
601
|
+
const few = goesOn?.merge.runs ?? (yield* narrowed(input.bucket, pack, merged, sizes.runs));
|
|
602
|
+
let placesOf;
|
|
483
603
|
const readTrees = Effect.fnUntraced(function* () {
|
|
484
|
-
|
|
485
|
-
|
|
604
|
+
while (trees.length > 0) {
|
|
605
|
+
const [asked, rest] = alone(trees);
|
|
606
|
+
trees = rest;
|
|
607
|
+
yield* readSome(asked);
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
const readSome = Effect.fnUntraced(function* (asked) {
|
|
611
|
+
const groups = yield* unlessReloaded(reader.inPackGroups(asked));
|
|
612
|
+
if (groups === void 0) return yield* stoppedOn(asked);
|
|
613
|
+
const { oids: ordered, ends } = grouped(groups);
|
|
614
|
+
const stoppedAt = (at) => stoppedOn(ordered.slice(at));
|
|
486
615
|
for (let at = 0; at < ordered.length;) {
|
|
487
|
-
const next = ordered.slice(at, at + 64);
|
|
488
|
-
const
|
|
616
|
+
const next = ordered.slice(at, Math.min(at + 64, groupEnd(ends, at)));
|
|
617
|
+
const admission = yield* unlessReloaded(admitted(next, reserve + saveCalls));
|
|
618
|
+
if (admission === void 0) return yield* stoppedAt(at);
|
|
619
|
+
const { count, needs } = admission;
|
|
489
620
|
if (count === 0) return yield* new WalkStopped({
|
|
490
621
|
trees: ordered.slice(at),
|
|
491
622
|
needs
|
|
492
623
|
});
|
|
493
624
|
const batch = next.slice(0, count);
|
|
494
|
-
const found = yield* reads(batch);
|
|
625
|
+
const found = yield* unlessReloaded(reads(batch));
|
|
626
|
+
if (found === void 0) return yield* stoppedAt(at);
|
|
495
627
|
for (const [index, oid] of batch.entries()) {
|
|
496
628
|
const object = yield* foundOf(found, oid);
|
|
497
629
|
if (object === void 0) continue;
|
|
@@ -521,7 +653,8 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
521
653
|
yield* eachOf(goesOn.trees, (id) => void trees.push(hexOf(id)));
|
|
522
654
|
yield* readTrees();
|
|
523
655
|
}
|
|
524
|
-
yield* mergeRuns(input.bucket, pack,
|
|
656
|
+
yield* mergeRuns(input.bucket, pack, few, (bytes, at, _run, places) => {
|
|
657
|
+
placesOf = places;
|
|
525
658
|
if (!pastId(bytes, at, last)) return void 0;
|
|
526
659
|
const id = bytes.subarray(at, at + 20);
|
|
527
660
|
last.set(id);
|
|
@@ -531,18 +664,23 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
531
664
|
if (tag !== tags.tree) return marked;
|
|
532
665
|
trees.push(hexOf(id));
|
|
533
666
|
return trees.length < atOnce ? marked : Effect.andThen(marked, readTrees());
|
|
534
|
-
}, sizes.runs);
|
|
667
|
+
}, sizes.runs, void 0, goesOn?.merge.places);
|
|
535
668
|
if (trees.length > 0) yield* readTrees();
|
|
536
669
|
});
|
|
537
670
|
const stopped = yield* Effect.as(walked, void 0).pipe(Effect.catchTag("WalkStopped", (stop) => Effect.succeed(stop)));
|
|
538
671
|
if (stopped !== void 0) {
|
|
539
|
-
if (!moved
|
|
672
|
+
if (!moved && given !== void 0) return given;
|
|
673
|
+
if (!moved && !spent) return yield* stopped.reloaded === true ? pastRoom(`a tree at level ${depth}`) : tooMany(`a tree at level ${depth}`, stopped.needs);
|
|
540
674
|
const levelRuns = after(goesOn?.reached, yield* level.finish);
|
|
541
675
|
const frontierRuns = after(goesOn?.frontier, yield* frontier.finish);
|
|
542
676
|
const pending = writer(`trees-${depth}`, sizes.runBytes);
|
|
543
677
|
for (const oid of [...stopped.trees, ...trees]) yield* put(pending, oidBytes(oid), tags.tree);
|
|
544
678
|
const at = {
|
|
545
679
|
last: hexOf(last),
|
|
680
|
+
merge: {
|
|
681
|
+
runs: few,
|
|
682
|
+
places: placesOf?.() ?? goesOn?.merge.places ?? few.keys.map(() => 0)
|
|
683
|
+
},
|
|
546
684
|
reached: levelRuns,
|
|
547
685
|
frontier: frontierRuns,
|
|
548
686
|
trees: yield* pending.finish
|
|
@@ -566,4 +704,4 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
566
704
|
refs
|
|
567
705
|
};
|
|
568
706
|
}, droppedOnRefusal);
|
|
569
|
-
export { PruneWalkTooLarge, WalkSaved, pruneTreesAtOnce, pruneWalk, pruneWalkHeld, pruneWalkSizes, pruneWalkTables, reachedRunBytes, walkKeys };
|
|
707
|
+
export { PruneWalkTooLarge, WalkSaved, fits, pruneTreesAtOnce, pruneWalk, pruneWalkHeld, pruneWalkSizes, pruneWalkStartCalls, pruneWalkTables, reachedRunBytes, walkKeys };
|