@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
|
@@ -265,8 +265,9 @@ const indexShallow = /* @__PURE__ */ Effect.fnUntraced(function* (walk, request)
|
|
|
265
265
|
});
|
|
266
266
|
/** What it held, given back, but for the lines it returns: nothing, when it held nothing. */
|
|
267
267
|
const given = Effect.suspend(() => Effect.andThen(heldBytes > 0 ? read.release(heldBytes) : Effect.void, readsHeld > 0 ? read.letGoReads(readsHeld) : Effect.void));
|
|
268
|
-
const
|
|
269
|
-
const clientShallows = new Set(
|
|
268
|
+
const held = yield* clientShallowsOf(request.shallows);
|
|
269
|
+
const clientShallows = new Set(held.map((shallow) => shallow.oid));
|
|
270
|
+
const shallows = held.filter((shallow) => !read.roots.has(shallow.oid));
|
|
270
271
|
const depth = request.depth;
|
|
271
272
|
if (depth === void 0) {
|
|
272
273
|
yield* given;
|
|
@@ -297,7 +298,8 @@ const indexShallow = /* @__PURE__ */ Effect.fnUntraced(function* (walk, request)
|
|
|
297
298
|
yield* keep(2 * (edge.numbers.length + edge.extras.length) * 70);
|
|
298
299
|
const edgeOids = yield* oidsOf(edge);
|
|
299
300
|
const unshallowed = shallows.filter((shallow) => hasMet(within, shallow));
|
|
300
|
-
const
|
|
301
|
+
const unshallowedIds = new Set(unshallowed.map((shallow) => shallow.oid));
|
|
302
|
+
const kept = [...clientShallows].filter((oid) => !unshallowedIds.has(oid));
|
|
301
303
|
const starts = yield* startsOf(unshallowed);
|
|
302
304
|
yield* given;
|
|
303
305
|
return {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A receive's largest blobs, as they're settled: a blob no larger than the smallest of a full list
|
|
3
|
+
* costs one compare, so a push of many small files keeps nothing.
|
|
4
|
+
*/
|
|
5
|
+
var LargestFiles = class {
|
|
6
|
+
#kept = [];
|
|
7
|
+
#least = 0;
|
|
8
|
+
#partial = false;
|
|
9
|
+
/** A list going on from `from`, what a receive's step before this one kept. */
|
|
10
|
+
constructor(from) {
|
|
11
|
+
if (from === void 0) return;
|
|
12
|
+
this.#kept.push(...from.largest);
|
|
13
|
+
this.#partial = from.largestPartial === true;
|
|
14
|
+
this.#least = this.#kept.at(-1)?.size ?? 0;
|
|
15
|
+
}
|
|
16
|
+
add(oid, size) {
|
|
17
|
+
const kept = this.#kept;
|
|
18
|
+
if (kept.length === 64 && size <= this.#least) {
|
|
19
|
+
this.#partial = true;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
kept.push({
|
|
23
|
+
oid,
|
|
24
|
+
size
|
|
25
|
+
});
|
|
26
|
+
kept.sort((a, b) => b.size - a.size);
|
|
27
|
+
if (kept.length > 64) {
|
|
28
|
+
kept.pop();
|
|
29
|
+
this.#partial = true;
|
|
30
|
+
}
|
|
31
|
+
this.#least = kept.at(-1)?.size ?? 0;
|
|
32
|
+
}
|
|
33
|
+
/** The list, largest first, and `largestPartial` when it left a blob out. */
|
|
34
|
+
finish() {
|
|
35
|
+
const largest = [...this.#kept];
|
|
36
|
+
return this.#partial ? {
|
|
37
|
+
largest,
|
|
38
|
+
largestPartial: true
|
|
39
|
+
} : { largest };
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
/** The largest of `objects`' blobs, as `LargestFiles` keeps them: a receive kept as rows. */
|
|
43
|
+
const largestOf = (objects) => {
|
|
44
|
+
const largest = new LargestFiles();
|
|
45
|
+
for (const object of objects) if (object.type === "blob") largest.add(object.oid, object.bytes.byteLength);
|
|
46
|
+
return largest.finish();
|
|
47
|
+
};
|
|
48
|
+
export { LargestFiles, largestOf };
|
|
@@ -209,9 +209,18 @@ var ReceivedPointers = class {
|
|
|
209
209
|
};
|
|
210
210
|
/** At a step's end, the pointers `found` as their table holds them, for the next step's `carried`. */
|
|
211
211
|
const pointersRecords = (found) => LfsPointers.pagesOf(found).map((page, at) => page.subarray(0, Math.min(pageEntries, found.count - at * pageEntries) * 57));
|
|
212
|
+
/**
|
|
213
|
+
* One page `pointersRecords` gave, read as pointers again, as import keeps them between its
|
|
214
|
+
* segments and its copy: `undefined` for bytes that aren't whole entries, or more than a page.
|
|
215
|
+
*/
|
|
216
|
+
const pointersOfRecord = (record) => {
|
|
217
|
+
const count = record.byteLength / 57;
|
|
218
|
+
if (!Number.isInteger(count) || count > 1024) return void 0;
|
|
219
|
+
return LfsPointers.made(count, [record]);
|
|
220
|
+
};
|
|
212
221
|
/** The pointers among a receive's whole objects, found by `pointers`. */
|
|
213
222
|
const pointersOfObjects = /* @__PURE__ */ Effect.fnUntraced(function* (objects, pointers = new ReceivedPointers()) {
|
|
214
223
|
for (const object of objects) if (object.type === "blob") yield* pointers.add(object.oid, object.bytes);
|
|
215
224
|
return pointers.finish();
|
|
216
225
|
});
|
|
217
|
-
export { ReceivedPointers, lfsOidAt, lfsPointers, lfsPointersMost, lfsSizeAt, noLfsPointers, pageEntries, pointerSizeMost, pointersOfBlob, pointersOfObjects, pointersRecords };
|
|
226
|
+
export { ReceivedPointers, lfsOidAt, lfsPointers, lfsPointersMost, lfsSizeAt, noLfsPointers, pageEntries, pointerSizeMost, pointersOfBlob, pointersOfObjects, pointersOfRecord, pointersRecords };
|
package/dist/storage/loose.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { copyRowsPage, eachHeldRow, gitObjectOf, heldRows, rowHeaders, rowSizes,
|
|
|
8
8
|
import { allotmentWithin } from "../contracts/object-values.mjs";
|
|
9
9
|
import { allottedRows } from "./allotted.mjs";
|
|
10
10
|
import { pointersOfObjects } from "./lfs-pointers.mjs";
|
|
11
|
+
import { largestOf } from "./largest-files.mjs";
|
|
11
12
|
import { wholeRoots } from "./roots.mjs";
|
|
12
13
|
import { commitBytes, unpackObjects } from "./unpack.mjs";
|
|
13
14
|
import { gitError } from "../contracts/result.mjs";
|
|
@@ -68,7 +69,8 @@ const receiveRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed,
|
|
|
68
69
|
},
|
|
69
70
|
bytes: unpacked.bytes,
|
|
70
71
|
objects: unpacked.objects.length,
|
|
71
|
-
lfsPointers: yield* pointersOfObjects(unpacked.objects)
|
|
72
|
+
lfsPointers: yield* pointersOfObjects(unpacked.objects),
|
|
73
|
+
...largestOf(unpacked.objects)
|
|
72
74
|
};
|
|
73
75
|
if (unpacked.cut.length > 0) quarantine.cut = unpacked.cut;
|
|
74
76
|
received.add(quarantine);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { RequestHolding } from "../store/call-count.mjs";
|
|
3
|
-
import { pushFloorsOf, readerFloors, readerMost } from "./budget.mjs";
|
|
4
|
-
import { packIndexerLimits } from "./pack-reads.mjs";
|
|
3
|
+
import { pushFloorsOf, readerFloors, readerMost, receiveObjectsMostOf } from "./budget.mjs";
|
|
4
|
+
import { indexBytes, packIndexerLimits } from "./pack-reads.mjs";
|
|
5
5
|
import { ReceivedPointers, lfsPointersMost, pageEntries } from "./lfs-pointers.mjs";
|
|
6
6
|
import { receiveRoomAdmitted } from "./receive-admission.mjs";
|
|
7
7
|
import { ReceiveRoom } from "./runs.mjs";
|
|
@@ -310,6 +310,14 @@ var MemoryBudget = class {
|
|
|
310
310
|
#indexes = /* @__PURE__ */ new Set();
|
|
311
311
|
/** The clock of the last operation that asked, so a release's wake reads the same time. */
|
|
312
312
|
#now = Date.now;
|
|
313
|
+
/**
|
|
314
|
+
* Each admitted push's place in admission order, which upkeep's allotments, counted with pushes,
|
|
315
|
+
* never take: when two pushes' grows wait on each other's room, the newer yields (#2361).
|
|
316
|
+
*/
|
|
317
|
+
#order = /* @__PURE__ */ new WeakMap();
|
|
318
|
+
#admissions = 0;
|
|
319
|
+
/** Push allotments whose grow yielded to an older push's, released in that step, by what each held (#2361). */
|
|
320
|
+
#yielders = /* @__PURE__ */ new WeakMap();
|
|
313
321
|
constructor(total, reserve) {
|
|
314
322
|
this.total = total;
|
|
315
323
|
this.reserve = reserve;
|
|
@@ -584,6 +592,7 @@ var MemoryBudget = class {
|
|
|
584
592
|
} finally {
|
|
585
593
|
this.#waking = false;
|
|
586
594
|
}
|
|
595
|
+
this.#yieldFor(void 0, 0);
|
|
587
596
|
}
|
|
588
597
|
/**
|
|
589
598
|
* Waits in `queue` as the waiter `enter` makes, `ms` at most; `None` past it. A wait interrupted,
|
|
@@ -610,7 +619,7 @@ var MemoryBudget = class {
|
|
|
610
619
|
* by its timeout too, gives back an allotment granted it that it never took.
|
|
611
620
|
*/
|
|
612
621
|
#wait(queue, push, bytes, ms, busy, own, asker, grower) {
|
|
613
|
-
|
|
622
|
+
const waited = this.#queued(queue, ms, (resume) => {
|
|
614
623
|
let granted;
|
|
615
624
|
return {
|
|
616
625
|
waiter: {
|
|
@@ -624,11 +633,13 @@ var MemoryBudget = class {
|
|
|
624
633
|
granted = allotment;
|
|
625
634
|
own(allotment);
|
|
626
635
|
resume(allotment);
|
|
627
|
-
}
|
|
636
|
+
},
|
|
637
|
+
refuse: () => resume(void 0)
|
|
628
638
|
},
|
|
629
639
|
left: () => granted?.release()
|
|
630
640
|
};
|
|
631
641
|
});
|
|
642
|
+
return Effect.map(waited, Option.flatMap(Option.fromUndefinedOr));
|
|
632
643
|
}
|
|
633
644
|
/**
|
|
634
645
|
* An allotment released when the scope ends, on every exit. Its finalizer is added first, and
|
|
@@ -654,8 +665,12 @@ var MemoryBudget = class {
|
|
|
654
665
|
admit(bytes) {
|
|
655
666
|
return this.#scoped((own) => {
|
|
656
667
|
if (bytes > this.total - this.reserve) return Effect.fail(pushTooLarge);
|
|
657
|
-
|
|
658
|
-
|
|
668
|
+
const admitted = (allotment) => {
|
|
669
|
+
this.#order.set(allotment, this.#admissions += 1);
|
|
670
|
+
return own(allotment);
|
|
671
|
+
};
|
|
672
|
+
if (this.#stuck(this.#now()) === void 0 && this.#admits(bytes)) return Effect.succeed(admitted(this.#grant(bytes, true)));
|
|
673
|
+
return this.#wait(this.#pushes, true, bytes, pushWaitMs, void 0, admitted).pipe(Effect.flatMap(Option.match({
|
|
659
674
|
onNone: () => Effect.fail(pushBusy),
|
|
660
675
|
onSome: Effect.succeed
|
|
661
676
|
})));
|
|
@@ -724,6 +739,9 @@ var MemoryBudget = class {
|
|
|
724
739
|
if (allotment.released || bytes <= 0) return Effect.void;
|
|
725
740
|
if (allotment.bytes + bytes > this.mostOf(allotment.push)) return Effect.fail(tooLarge ?? busy);
|
|
726
741
|
if (this.tryGrow(allotment, bytes)) return Effect.void;
|
|
742
|
+
const yielded = this.#yieldFor(allotment, bytes);
|
|
743
|
+
if (yielded === "refused") return Effect.andThen(this.#refusedGrow(allotment, bytes), Effect.fail(busy));
|
|
744
|
+
if (yielded === "granted" || yielded === "others" && this.tryGrow(allotment, bytes)) return Effect.void;
|
|
727
745
|
const adopt = (granted) => {
|
|
728
746
|
granted.adopted();
|
|
729
747
|
allotment.added(granted.bytes);
|
|
@@ -736,11 +754,104 @@ var MemoryBudget = class {
|
|
|
736
754
|
})));
|
|
737
755
|
});
|
|
738
756
|
}
|
|
757
|
+
/** Whether `allotment` is an admitted push's, and `other`'s admitted before it. */
|
|
758
|
+
#older(other, allotment) {
|
|
759
|
+
const mine = this.#order.get(allotment);
|
|
760
|
+
const theirs = this.#order.get(other);
|
|
761
|
+
return mine !== void 0 && theirs !== void 0 && theirs < mine;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Whether a push's grow of `bytes` fits once `newer`, pushes' allotments, give back all they
|
|
765
|
+
* hold and every other room shrinks to its floor: `newer` are then what the grow waits on. Never
|
|
766
|
+
* while a push is stuck at the head, which no release passes.
|
|
767
|
+
*/
|
|
768
|
+
#fitsWithout(newer, bytes) {
|
|
769
|
+
if (this.#stuck(this.#now()) !== void 0) return false;
|
|
770
|
+
let admitted = 0;
|
|
771
|
+
let held = 0;
|
|
772
|
+
let shrinks = 0;
|
|
773
|
+
for (const each of newer) {
|
|
774
|
+
admitted += each.admitted;
|
|
775
|
+
held += each.held;
|
|
776
|
+
}
|
|
777
|
+
for (const room of this.#rooms) if (room.owner === void 0 || !newer.includes(room.owner)) shrinks += room.extra;
|
|
778
|
+
return this.#admitted - admitted + bytes <= this.total - this.reserve && this.#allotted - held - shrinks + bytes <= this.total;
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Whether the pushes' holdings leave no room for a push's grow of `bytes`: it waits on their
|
|
782
|
+
* bytes, which no read's end frees. A grow that waits only on a read's or a fetch's allotment
|
|
783
|
+
* lands once it ends, so it neither yields nor is yielded to.
|
|
784
|
+
*/
|
|
785
|
+
#pushesBlock(bytes) {
|
|
786
|
+
return this.#admitted + bytes > this.total - this.reserve;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* `asker`'s grow of `bytes`, which doesn't fit, beside every push's grow that waits (#2361), or,
|
|
790
|
+
* at the end of the queue's wake, with no `asker`, the waiting grows alone. When
|
|
791
|
+
* the oldest of them waits on the pushes' holdings, the newest that do too yield, as few as fit
|
|
792
|
+
* the oldest's: each is refused busy, its bytes back in this step, and the oldest's grow is
|
|
793
|
+
* granted in it, before the queue's wake serves anything else. That early grant can start the
|
|
794
|
+
* oldest push's next grow, and its `growWaitMs`, sooner, so a fetch holding room past it can
|
|
795
|
+
* refuse that grow where a later grant wouldn't, as on main a holder past 5 s refuses a grow.
|
|
796
|
+
* What became of `asker`'s grow: `granted`, `refused`, `others` when only others' were, or
|
|
797
|
+
* undefined.
|
|
798
|
+
*/
|
|
799
|
+
#yieldFor(asker, bytes) {
|
|
800
|
+
if (asker !== void 0 && !this.#order.has(asker)) return void 0;
|
|
801
|
+
const grows = asker === void 0 ? [] : [{
|
|
802
|
+
grower: asker,
|
|
803
|
+
bytes,
|
|
804
|
+
waiter: void 0
|
|
805
|
+
}];
|
|
806
|
+
for (const waiter of this.#reads) if (!("room" in waiter) && waiter.grower !== void 0 && this.#order.has(waiter.grower)) grows.push({
|
|
807
|
+
grower: waiter.grower,
|
|
808
|
+
bytes: waiter.bytes,
|
|
809
|
+
waiter
|
|
810
|
+
});
|
|
811
|
+
grows.sort((one, other) => this.#older(one.grower, other.grower) ? 1 : -1);
|
|
812
|
+
const oldest = grows.pop();
|
|
813
|
+
if (oldest === void 0 || !this.#pushesBlock(oldest.bytes)) return void 0;
|
|
814
|
+
const yielding = [];
|
|
815
|
+
for (const each of grows) {
|
|
816
|
+
if (!this.#pushesBlock(each.bytes)) continue;
|
|
817
|
+
yielding.push(each);
|
|
818
|
+
const newer = yielding.map(({ grower }) => grower);
|
|
819
|
+
if (this.#fitsWithout(newer, oldest.bytes)) return this.#yielded(asker, oldest, yielding);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
/** `#yieldFor`'s step: `yielding` refused and released, then `oldest`'s grow granted. */
|
|
823
|
+
#yielded(asker, oldest, yielding) {
|
|
824
|
+
const waking = this.#waking;
|
|
825
|
+
this.#waking = true;
|
|
826
|
+
let granted = false;
|
|
827
|
+
try {
|
|
828
|
+
for (const { grower, waiter } of yielding) {
|
|
829
|
+
if (waiter !== void 0) this.#reads.splice(this.#reads.indexOf(waiter), 1);
|
|
830
|
+
this.#yielders.set(grower, grower.bytes);
|
|
831
|
+
grower.release();
|
|
832
|
+
waiter?.refuse();
|
|
833
|
+
}
|
|
834
|
+
const { grower, waiter } = oldest;
|
|
835
|
+
if (waiter === void 0) granted = this.tryGrow(grower, oldest.bytes);
|
|
836
|
+
else if (this.#fits(waiter.bytes, true, waiter.asker)) {
|
|
837
|
+
this.#reads.splice(this.#reads.indexOf(waiter), 1);
|
|
838
|
+
waiter.admitted(this.#grant(waiter.bytes, true, waiter.busy, waiter.asker));
|
|
839
|
+
}
|
|
840
|
+
} finally {
|
|
841
|
+
this.#waking = waking;
|
|
842
|
+
}
|
|
843
|
+
this.#wake();
|
|
844
|
+
if (yielding.some(({ grower }) => grower === asker)) return "refused";
|
|
845
|
+
return granted ? "granted" : "others";
|
|
846
|
+
}
|
|
739
847
|
/**
|
|
740
848
|
* A grow refused busy, one line in the log with who asked and what was free as its wait ended,
|
|
741
|
-
* so a refusal beside upkeep shows as a pattern (#1300)
|
|
849
|
+
* so a refusal beside upkeep shows as a pattern (#1300), or, for a push's that yielded to an
|
|
850
|
+
* older push's, that it did and what it held.
|
|
742
851
|
*/
|
|
743
852
|
#refusedGrow(allotment, bytes) {
|
|
853
|
+
const held = this.#yielders.get(allotment);
|
|
854
|
+
if (held !== void 0) return Effect.logWarning(`The push allotment's grow of ${bytes} B, holding ${held} B, yielded to an older push whose grow waits on its room, and was refused busy`);
|
|
744
855
|
const kind = this.#upkeeps.has(allotment) ? "upkeep" : allotment.push ? "push" : "read";
|
|
745
856
|
const free = this.total - this.#allotted;
|
|
746
857
|
const beside = this.total - this.reserve - this.#admitted;
|
|
@@ -834,6 +945,41 @@ const upkeepRuns = {
|
|
|
834
945
|
ways: 32
|
|
835
946
|
};
|
|
836
947
|
/**
|
|
948
|
+
* The room a prune walk's reader holds its packs' `.idx` and `.rev` in, whatever their sum: a
|
|
949
|
+
* fixed size, never sized up to what's spare, which a walk charges once in place of each pack's
|
|
950
|
+
* (#2230). About 1,050,000 objects' indexes at 32 B an object. A merge cuts each pack it writes so
|
|
951
|
+
* its index fits, a push takes no more objects than `pruneIndexObjectsMost`, and a walk refuses a
|
|
952
|
+
* listed pack whose index alone passes it.
|
|
953
|
+
*
|
|
954
|
+
* It fits beside the rest of a walk at its bounds: `pruneWalkHeld()`'s 47,844,271, this
|
|
955
|
+
* 33,554,432 and the read reserve's 4,194,688 come to 85,593,391, under the default memory's
|
|
956
|
+
* 103,284,736 allottable, which leaves 17,691,345 for the seen bits: about 141,500,000 objects.
|
|
957
|
+
*/
|
|
958
|
+
const pruneIndexFloor = 33554432;
|
|
959
|
+
/**
|
|
960
|
+
* The most objects whose pack's index fits `pruneIndexFloor`, 1,048,528: 32 B an object past its
|
|
961
|
+
* fixed 1,508, in a pack under 2 GiB, whose index takes no large offsets (#2402). Every pack prune
|
|
962
|
+
* meets is: a received one's entries each start under `pushUploadMost` and take at most
|
|
963
|
+
* `packFileBytes`, and a merge cuts under `maxPackSizeMost`.
|
|
964
|
+
*/
|
|
965
|
+
const pruneIndexObjectsMost = Math.floor((pruneIndexFloor - indexBytes({
|
|
966
|
+
objects: 0,
|
|
967
|
+
bytes: 0
|
|
968
|
+
})) / (indexBytes({
|
|
969
|
+
objects: 1,
|
|
970
|
+
bytes: 0
|
|
971
|
+
}) - indexBytes({
|
|
972
|
+
objects: 0,
|
|
973
|
+
bytes: 0
|
|
974
|
+
})));
|
|
975
|
+
/**
|
|
976
|
+
* The most objects one push of `size`'s length takes in a `packs()` instance of `memory`: what its
|
|
977
|
+
* memory takes, `receiveObjectsMostOf`, and no more than `pruneIndexObjectsMost`, so a prune walk
|
|
978
|
+
* holds its pack's index, which no merge cuts while it's alone. Past it, a push is refused before
|
|
979
|
+
* it waits, by the most. In a Worker's 128 MB, 1,048,528, whatever its length.
|
|
980
|
+
*/
|
|
981
|
+
const pushObjectsMostOf = (memory, size = {}) => Math.min(receiveObjectsMostOf(memory, size), pruneIndexObjectsMost);
|
|
982
|
+
/**
|
|
837
983
|
* What a prune walk's seen set holds (#2019): a bit for each object of each of `packs`, at its rank,
|
|
838
984
|
* and for each of `outside` objects no listed pack holds, its ID, at `fetchEntryBytes`. A part's
|
|
839
985
|
* save puts the same bytes, the IDs at 20 each, so its read holds no more.
|
|
@@ -977,4 +1123,4 @@ var AllottedPointers = class {
|
|
|
977
1123
|
return this.#pointers.finish();
|
|
978
1124
|
}
|
|
979
1125
|
};
|
|
980
|
-
export { AllottedPointers, MemoryAllotment, MemoryBudget, allottedWithin, fetchBusy, growWaitMs, headStuckMs, joinRoomOf, outsideOn, pruneSeenBytes, pushBusy, pushEntryTooLarge, pushIndexTooLarge, pushMemoryOf, pushTooLarge, pushWaitMs, readBusy, readerMemoryOf, upkeepMemoryOf, upkeepRuns, upkeepTooLarge };
|
|
1126
|
+
export { AllottedPointers, MemoryAllotment, MemoryBudget, allottedWithin, fetchBusy, growWaitMs, headStuckMs, joinRoomOf, outsideOn, pruneIndexFloor, pruneIndexObjectsMost, pruneSeenBytes, pushBusy, pushEntryTooLarge, pushIndexTooLarge, pushMemoryOf, pushObjectsMostOf, pushTooLarge, pushWaitMs, readBusy, readerMemoryOf, upkeepMemoryOf, upkeepRuns, upkeepTooLarge };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sizedPutCalls } from "./calls.mjs";
|
|
2
2
|
import { upkeepRuns } from "./memory-budget.mjs";
|
|
3
3
|
import { searchReads } from "./pack-ranges.mjs";
|
|
4
|
-
import { packIndexerLimits } from "./pack-reads.mjs";
|
|
4
|
+
import { indexBytes, packIndexerLimits } from "./pack-reads.mjs";
|
|
5
5
|
// src/storage/merge-cut.ts
|
|
6
6
|
/** A pack before its first entry: its 12-byte header and 20-byte trailer. */
|
|
7
7
|
const packStart = {
|
|
@@ -44,10 +44,11 @@ const passObjectsMost = 15e5;
|
|
|
44
44
|
const writeCallsOf = (spend, multipart, bounds = upkeepRuns) => spend.reads + sizedPutCalls(multipart, spend.bytes) + Math.ceil(spend.objects * indexRecordBytes / bounds.runBytes) * sizedPutCalls(multipart, bounds.runBytes) + Math.ceil(spend.pairs * 8 / pairRunBytes) * sizedPutCalls(multipart, pairRunBytes);
|
|
45
45
|
/**
|
|
46
46
|
* Whether a pack at `spend` ends before the entry that would take it to `next`: past
|
|
47
|
-
* `maxPackSize`,
|
|
48
|
-
*
|
|
47
|
+
* `maxPackSize`, an index past `pruneIndexFloor`, so a prune walk holds any pack a merge writes
|
|
48
|
+
* (#2230), a write try's calls or the index pass's. Never before its first entry, so an entry past
|
|
49
|
+
* them alone goes in a pack of its own.
|
|
49
50
|
*/
|
|
50
|
-
const cutsBefore = (spend, next, limits, bounds = upkeepRuns) => spend.objects > 0 && (next.bytes > limits.maxPackSize || limits.writeCalls !== void 0 && writeCallsOf(next, limits.multipart, bounds) > limits.writeCalls || limits.indexMost !== void 0 && limits.indexCalls(next.objects, next.bytes) > limits.indexMost);
|
|
51
|
+
const cutsBefore = (spend, next, limits, bounds = upkeepRuns) => spend.objects > 0 && (next.bytes > limits.maxPackSize || indexBytes(next) > 33554432 || limits.writeCalls !== void 0 && writeCallsOf(next, limits.multipart, bounds) > limits.writeCalls || limits.indexMost !== void 0 && limits.indexCalls(next.objects, next.bytes) > limits.indexMost);
|
|
51
52
|
/**
|
|
52
53
|
* The bucket calls resolving one entry written whole takes in an input of `objects`, its chain read
|
|
53
54
|
* in `blocks` block reads: the indexer reads at most `chainReads` entries, and finds each base but
|