@ref0/git 0.12.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 +3 -3
- 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 +11 -1
- package/dist/contracts/git.d.mts +18 -7
- 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 +23 -18
- package/dist/contracts/result.mjs +17 -4
- 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 +79 -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.mjs +27 -5
- package/dist/core/ancestry.d.mts +9 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +42 -4
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +2 -1
- package/dist/core/events/deliver.mjs +10 -2
- package/dist/core/forks.mjs +3 -3
- package/dist/core/imports.mjs +147 -9
- 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/parts.d.mts +6 -1
- 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 +98 -26
- package/dist/core/receipts.mjs +26 -10
- package/dist/core/ref-view.mjs +59 -5
- package/dist/core/refs.mjs +13 -8
- package/dist/core/repack.mjs +11 -8
- package/dist/core/repo-info.mjs +16 -9
- package/dist/core/repos.mjs +30 -14
- 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 +3 -3
- package/dist/extend.mjs +2 -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 +114 -56
- 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/objects.d.mts +6 -0
- package/dist/lfs/objects.mjs +68 -41
- 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/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 +31 -23
- 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 +273 -240
- 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 +127 -115
- package/dist/rest/forks.d.mts +121 -97
- 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 +2 -1
- 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 +282 -226
- package/dist/rest/refs.d.mts +205 -176
- package/dist/rest/repos.d.mts +108 -80
- package/dist/rest/tags.d.mts +24 -12
- package/dist/rest/tokens.d.mts +235 -211
- package/dist/rest/topics.d.mts +53 -33
- package/dist/rest/trees.d.mts +105 -89
- 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 +3 -3
- 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 +133 -212
- 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 +28 -4
- package/dist/storage/pack-reads.mjs +8 -8
- 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-walk.mjs +54 -16
- package/dist/storage/prune.mjs +629 -196
- package/dist/storage/push-uploads.mjs +36 -12
- package/dist/storage/quarantine.mjs +9 -9
- 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 +9 -7
- package/dist/store/repo-record.mjs +102 -19
- 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 +55 -43
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +1 -0
- 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 +210 -137
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +25 -5
- package/dist/sync/tries.mjs +45 -14
- package/dist/sync.d.mts +2 -2
- 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 -5
- 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
|
@@ -11,8 +11,8 @@ import { limits } from "@ref0/infra";
|
|
|
11
11
|
* A large push's pack, uploaded to the bucket in parts before the push: its row in the repo's
|
|
12
12
|
* scope, from begin until upkeep deletes it at its `removeAt`, and its staged key, which only
|
|
13
13
|
* this upload's parts ever reach. A part link is given only while the row is `open`, complete
|
|
14
|
-
* makes it `completing` before it joins the parts, so one upload is pushed at most once,
|
|
15
|
-
* `ended` once it ran.
|
|
14
|
+
* makes it `completing` before it joins the parts, so one upload is pushed at most once, or
|
|
15
|
+
* `receiving` as it hands the pack to `git.push-upload`'s steps, and `ended` once it ran.
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
18
|
* The largest pack a push sends: 1 GiB, so each entry starts under 2^30, which a receive's records,
|
|
@@ -35,11 +35,19 @@ const pushUploadLife = /* @__PURE__ */ millis("1 hour");
|
|
|
35
35
|
/** How long a part link lasts, at most: never past the upload's `expiresAt`. */
|
|
36
36
|
const partLinkLife = /* @__PURE__ */ millis("15 minutes");
|
|
37
37
|
/**
|
|
38
|
-
* How long
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* How long a complete may hold an upload `completing`, joining its parts, before a complete sent
|
|
39
|
+
* again ends it: one that stopped there, its count spent or its host gone, hands nothing on.
|
|
40
|
+
*
|
|
41
|
+
* No host bounds it for us: Workers puts no wall limit on a handler still running, and Node's
|
|
42
|
+
* `requestTimeout` bounds only a request's receipt. So the claim bounds itself: its hand-off lands
|
|
43
|
+
* the job only before `claimedAt` plus this, and an end of the claim only after it. Each is one
|
|
44
|
+
* commit at the version it read the row `completing` with that `claimedAt`, so where clocks
|
|
45
|
+
* differ, the store takes one and refuses the other: a live upload is never ended. A claim's own
|
|
46
|
+
* work is a few calls, a join and a 12-byte read, under a second when its store and bucket answer.
|
|
41
47
|
*/
|
|
42
|
-
const
|
|
48
|
+
const completingMost = /* @__PURE__ */ millis("5 minutes");
|
|
49
|
+
/** A claim past `completingMost`, which hands nothing on: the upload ends with it. */
|
|
50
|
+
const claimLapsed = /* @__PURE__ */ gitError("FAILED_PRECONDITION", "The complete that claimed the push upload stopped before it handed its pack on", { hint: "Push again" });
|
|
43
51
|
/**
|
|
44
52
|
* How long after its last part link expires upkeep ends an upload: a signed PUT is checked only
|
|
45
53
|
* as it starts, so a slow part ends later, and complete may start until `removeAt` less
|
|
@@ -71,13 +79,17 @@ const PushUploadRow = /* @__PURE__ */ Schema.Struct({
|
|
|
71
79
|
expiresAt: Schema.Int,
|
|
72
80
|
/** When upkeep aborts its parts, and deletes its key and the row. */
|
|
73
81
|
removeAt: Schema.Int,
|
|
82
|
+
/** When a complete claimed it, once one has: `completingMost` bounds how long it holds it. */
|
|
83
|
+
claimedAt: Schema.optionalKey(Schema.Int),
|
|
74
84
|
/**
|
|
75
|
-
* `
|
|
76
|
-
*
|
|
85
|
+
* `receiving` while `git.push-upload`'s steps receive its pack, then `ended` once a complete
|
|
86
|
+
* has run: its key is deleted, but the row stays until `removeAt`, as a bucket that can't revoke
|
|
87
|
+
* a link, such as Blob, takes a PUT to the key until the link expires.
|
|
77
88
|
*/
|
|
78
89
|
state: Schema.Literals([
|
|
79
90
|
"open",
|
|
80
91
|
"completing",
|
|
92
|
+
"receiving",
|
|
81
93
|
"ended"
|
|
82
94
|
])
|
|
83
95
|
});
|
|
@@ -91,6 +103,18 @@ const pushUploadRead = (upload) => ({
|
|
|
91
103
|
collection: collections.pushUploads,
|
|
92
104
|
id: upload
|
|
93
105
|
});
|
|
106
|
+
/** An upload's rows: its own, its steps' and its answer's, which upkeep deletes together. */
|
|
107
|
+
const pushUploadKeys = (upload) => [
|
|
108
|
+
pushUploadRowKey(upload),
|
|
109
|
+
{
|
|
110
|
+
collection: collections.pushUploadSteps,
|
|
111
|
+
id: upload
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
collection: collections.pushUploadAnswers,
|
|
115
|
+
id: upload
|
|
116
|
+
}
|
|
117
|
+
];
|
|
94
118
|
/** Each part but the last of an upload of `bytes`, to a bucket that holds `maxParts` parts. */
|
|
95
119
|
const partSizeOf = (bytes, maxParts) => Math.max(pushUploadPart, Math.ceil(bytes / maxParts));
|
|
96
120
|
/** How many parts `bytes` takes, in parts of `size`. */
|
|
@@ -104,8 +128,8 @@ const partBytes = (bytes, part, size) => Math.min(size, bytes - (part - 1) * siz
|
|
|
104
128
|
const upkeepPage = /* @__PURE__ */ Math.floor(limits.answerBytes / limits.valueBytes / 2);
|
|
105
129
|
/**
|
|
106
130
|
* Ends the push uploads due at `at` in `repo`: each one's parts aborted, where the host has
|
|
107
|
-
* `uploads`, its key deleted from `bucket`, which charges each call, then its
|
|
108
|
-
* the rows were read. A crash between leaves the row, and the next step ends it again: aborting an
|
|
131
|
+
* `uploads`, its key deleted from `bucket`, which charges each call, then its rows, at the version
|
|
132
|
+
* the rows were read: a job still receiving it finds none, and stops. A crash between leaves the row, and the next step ends it again: aborting an
|
|
109
133
|
* ended upload, and deleting a key that's gone, do nothing.
|
|
110
134
|
*/
|
|
111
135
|
const pushUploadUpkeep = (bucket, uploads) => Effect.fnUntraced(function* (store, repo, at) {
|
|
@@ -147,7 +171,7 @@ const pushUploadUpkeep = (bucket, uploads) => Effect.fnUntraced(function* (store
|
|
|
147
171
|
yield* storeCall(() => store.commit(scope, {
|
|
148
172
|
id: newChangeId(),
|
|
149
173
|
expect: version,
|
|
150
|
-
delete: due.
|
|
174
|
+
delete: due.flatMap(({ id }) => pushUploadKeys(id))
|
|
151
175
|
}));
|
|
152
176
|
return { more: true };
|
|
153
177
|
});
|
|
@@ -156,4 +180,4 @@ const endUpload = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, uploads,
|
|
|
156
180
|
if (uploads !== void 0) yield* bucketCall(uploads.abortUpload(row.key, row.uploadId));
|
|
157
181
|
yield* bucketDo(bucket.remove(row.key));
|
|
158
182
|
});
|
|
159
|
-
export { PushUploadRow,
|
|
183
|
+
export { PushUploadRow, claimLapsed, completingMost, endUpload, partBytes, partLinkLife, partSizeOf, partsOf, pushPackTooLarge, pushUploadGrace, pushUploadKey, pushUploadKeys, pushUploadLife, pushUploadMost, pushUploadPart, pushUploadRead, pushUploadRowKey, pushUploadUpkeep };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { bestEffort } from "../store/errors.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { heldAddition } from "../store/repo-record.mjs";
|
|
3
3
|
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
4
4
|
import { bucketDo, bucketPut } from "./calls.mjs";
|
|
5
5
|
import { isPackId, markerKey, newPackId, packFileKeys } from "./layout.mjs";
|
|
@@ -37,16 +37,16 @@ const openQuarantine = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
37
37
|
const { store, bucket, repo, at, prune } = input;
|
|
38
38
|
const pack = newPackId();
|
|
39
39
|
const due = removeAt(at, prune);
|
|
40
|
-
yield*
|
|
40
|
+
const addition = yield* heldAddition(`The push's pack for repo ${repo}`, {
|
|
41
|
+
put: [quarantineRow(pack, {
|
|
42
|
+
removeAt: due,
|
|
43
|
+
state: "open"
|
|
44
|
+
})],
|
|
45
|
+
jobs: [repackJobRow(due)]
|
|
46
|
+
});
|
|
41
47
|
yield* store.add({
|
|
42
48
|
scope: repoScope(repo),
|
|
43
|
-
addition
|
|
44
|
-
put: [quarantineRow(pack, {
|
|
45
|
-
removeAt: due,
|
|
46
|
-
state: "open"
|
|
47
|
-
})],
|
|
48
|
-
jobs: [repackJobRow(due)]
|
|
49
|
-
}
|
|
49
|
+
addition
|
|
50
50
|
});
|
|
51
51
|
yield* putMarker(bucket, pack, repo);
|
|
52
52
|
if ((yield* quarantineState({
|
package/dist/storage/ready.mjs
CHANGED
|
@@ -2,7 +2,8 @@ import { Sha1 } from "../protocol/bytes/sha1.mjs";
|
|
|
2
2
|
import { PackWriteError } from "../protocol/packs/write-error.mjs";
|
|
3
3
|
import { handingOn } from "../protocol/packs/writer.mjs";
|
|
4
4
|
import { decodeRow, isLimitRefusal } from "../store/errors.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { rootsDigest, rootsOf } from "../store/repo-record.mjs";
|
|
6
|
+
import { repoRootsKey, repoScope } from "../store/scopes.mjs";
|
|
6
7
|
import { bucketBody, bucketTry } from "./calls.mjs";
|
|
7
8
|
import { startPut } from "./merge.mjs";
|
|
8
9
|
import { readBusy, upkeepTooLarge } from "./memory-budget.mjs";
|
|
@@ -28,20 +29,25 @@ const defaultShallow = {
|
|
|
28
29
|
* in a job that runs beside the host's requests.
|
|
29
30
|
*/
|
|
30
31
|
const readyBytesMost = 67108864;
|
|
31
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* The most shallow lines a ready row keeps, its depth's edge and the roots it sends together, so
|
|
34
|
+
* the row stays well under a store's 1 MiB.
|
|
35
|
+
*/
|
|
32
36
|
const readyShallowsMost = 1e4;
|
|
33
37
|
/** How long a ready pack's build may take to write: a third of `git.repack`'s 15 minutes. */
|
|
34
38
|
const readyMilliseconds = 3e5;
|
|
35
39
|
const PackIdText = /* @__PURE__ */ Schema.String.check(Schema.isPattern(/^p_[A-Za-z0-9_-]{16}$/));
|
|
36
40
|
/**
|
|
37
41
|
* The ready pack's row, in `ready` by `shallow`: what it was built from, the default branch's
|
|
38
|
-
* `tip`, its `depth
|
|
39
|
-
* limits keeps a row with no pack, so the next step doesn't build
|
|
42
|
+
* `tip`, its `depth`, its `tags`' digest and the repo's `roots`' (`rootsDigest`), and the pack, if
|
|
43
|
+
* one was kept. A build past its limits keeps a row with no pack, so the next step doesn't build
|
|
44
|
+
* it again.
|
|
40
45
|
*/
|
|
41
46
|
const ReadyRow = /* @__PURE__ */ Schema.Struct({
|
|
42
47
|
tip: Schema.String,
|
|
43
48
|
depth: Schema.Int,
|
|
44
49
|
tags: Schema.String,
|
|
50
|
+
roots: Schema.String,
|
|
45
51
|
pack: Schema.optionalKey(Schema.Struct({
|
|
46
52
|
id: PackIdText,
|
|
47
53
|
objects: Schema.Int,
|
|
@@ -73,13 +79,27 @@ const readyRequest = (tip, depth) => ({
|
|
|
73
79
|
depth,
|
|
74
80
|
includeTag: true
|
|
75
81
|
});
|
|
82
|
+
const decodeReady = (row) => row === void 0 ? Effect.succeed(void 0) : decodeRow(ReadyRow, row, "The ready shallow pack's row");
|
|
76
83
|
const readOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed) {
|
|
77
|
-
const
|
|
84
|
+
const snapshot = yield* store.read({
|
|
78
85
|
scope: repoScope(listed.repo),
|
|
79
86
|
reads: [readyKey]
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
});
|
|
88
|
+
return yield* decodeReady(snapshot.results[0]?.[0]);
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* The ready row and the repo's roots, in one read: a step builds over the roots as they are now,
|
|
92
|
+
* with no fetch to pass them, as `git.index`'s build reads them.
|
|
93
|
+
*/
|
|
94
|
+
const readWithRoots = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed) {
|
|
95
|
+
const snapshot = yield* store.read({
|
|
96
|
+
scope: repoScope(listed.repo),
|
|
97
|
+
reads: [readyKey, repoRootsKey]
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
ready: yield* decodeReady(snapshot.results[0]?.[0]),
|
|
101
|
+
roots: yield* rootsOf(snapshot.results[1])
|
|
102
|
+
};
|
|
83
103
|
});
|
|
84
104
|
/** The bytes of the ready pack `rows`, a read of `readyKey`, hold: 0 with none kept. */
|
|
85
105
|
const readyBytesOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
|
|
@@ -89,8 +109,8 @@ const readyBytesOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
|
|
|
89
109
|
});
|
|
90
110
|
/**
|
|
91
111
|
* Whether a ready pack answers `input` exactly, as its plan would now: the one want its tip, no
|
|
92
|
-
* haves and no shallow commits, its depth, no `deepen-relative` and no filter,
|
|
93
|
-
* over the same tags, so a tag a rule hides from the caller never reaches them. The objects a tip
|
|
112
|
+
* haves and no shallow commits, its depth, no `deepen-relative` and no filter, `include-tag`
|
|
113
|
+
* over the same tags, so a tag a rule hides from the caller never reaches them, and the same roots. The objects a tip
|
|
94
114
|
* reaches never change, so a pack built for an older tip still answers a want of that tip.
|
|
95
115
|
*/
|
|
96
116
|
const answers = (ready, input) => {
|
|
@@ -98,7 +118,8 @@ const answers = (ready, input) => {
|
|
|
98
118
|
const pack = ready.pack;
|
|
99
119
|
if (pack === void 0) return false;
|
|
100
120
|
const tags = request.includeTag ? tagsDigest(input.tags ?? []) === ready.tags : pack.tagged === 0;
|
|
101
|
-
|
|
121
|
+
const roots = () => rootsDigest(input.roots ?? []) === ready.roots;
|
|
122
|
+
return new Set(request.wants).size === 1 && request.wants[0] === ready.tip && request.haves.length === 0 && request.shallows.length === 0 && request.depth === ready.depth && request.deepenRelative !== true && request.filter === void 0 && tags && pack.objects <= limits.objects && pack.bytes <= limits.bytes && roots();
|
|
102
123
|
};
|
|
103
124
|
/**
|
|
104
125
|
* `bytes`, ended as a planned pack's stream is: when `signal` aborts, its reader gets the signal's
|
|
@@ -254,7 +275,8 @@ const readyPlan = /* @__PURE__ */ Effect.fnUntraced(function* (input, shallow, t
|
|
|
254
275
|
const planned = yield* planFetchWithin(input.reads, {
|
|
255
276
|
request,
|
|
256
277
|
limits,
|
|
257
|
-
tags: input.tags
|
|
278
|
+
tags: input.tags,
|
|
279
|
+
roots: input.roots
|
|
258
280
|
}, {
|
|
259
281
|
left,
|
|
260
282
|
charge: input.charge,
|
|
@@ -325,16 +347,20 @@ const keepPack = /* @__PURE__ */ Effect.fnUntraced(function* (input, shallow, pl
|
|
|
325
347
|
* its `quarantine` row gone; past them, or at a tip naming an object the repo lacks, its row
|
|
326
348
|
* put with no pack, so only a moved tip plans it again;
|
|
327
349
|
* - a pack the row named before leaves through a `leaving` row, so a clone still streaming it
|
|
328
|
-
* can finish, and clean-up ends its marker and bytes after
|
|
350
|
+
* can finish, and clean-up ends its marker and bytes after: at prune's time, or a deleted
|
|
351
|
+
* repo's `leaveAt` when that's sooner;
|
|
329
352
|
* - with no tip, a deleted repo's or one whose default branch isn't there, or `shallow: false`,
|
|
330
353
|
* the row is deleted, its pack leaving.
|
|
331
354
|
* `undefined` when there is nothing to do.
|
|
332
355
|
*/
|
|
333
356
|
const readyStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
334
|
-
const { shallow, tip, at, prune } = input;
|
|
335
|
-
const ready = yield*
|
|
357
|
+
const { shallow, tip, at, prune, leaveAt } = input;
|
|
358
|
+
const { ready, roots: rooted } = yield* readWithRoots(input.store, input.listed);
|
|
359
|
+
const roots = [...rooted];
|
|
336
360
|
const tags = tagsDigest(input.tags);
|
|
337
|
-
const
|
|
361
|
+
const rootsAt = rootsDigest(roots);
|
|
362
|
+
const pruned = removeAt(at, prune);
|
|
363
|
+
const due = leaveAt === void 0 ? pruned : Math.min(pruned, leaveAt);
|
|
338
364
|
const put = [];
|
|
339
365
|
const del = [];
|
|
340
366
|
const old = ready?.pack;
|
|
@@ -357,11 +383,12 @@ const readyStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
357
383
|
due
|
|
358
384
|
};
|
|
359
385
|
}
|
|
360
|
-
if (ready?.tip === tip && ready.depth === shallow.depth && ready.tags === tags) return void 0;
|
|
386
|
+
if (ready?.tip === tip && ready.depth === shallow.depth && ready.tags === tags && ready.roots === rootsAt) return void 0;
|
|
361
387
|
const kept = yield* Effect.scoped(Effect.gen(function* () {
|
|
362
388
|
const build = {
|
|
363
389
|
...input,
|
|
364
|
-
reads: yield* input.reads
|
|
390
|
+
reads: yield* input.reads,
|
|
391
|
+
roots
|
|
365
392
|
};
|
|
366
393
|
const started = yield* Clock$1.currentTimeMillis;
|
|
367
394
|
const plan = yield* readyPlan(build, shallow, tip, started);
|
|
@@ -371,7 +398,8 @@ const readyStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
371
398
|
const value = {
|
|
372
399
|
tip,
|
|
373
400
|
depth: shallow.depth,
|
|
374
|
-
tags
|
|
401
|
+
tags,
|
|
402
|
+
roots: rootsAt
|
|
375
403
|
};
|
|
376
404
|
if (kept !== void 0) {
|
|
377
405
|
value.pack = kept.pack;
|
|
@@ -30,7 +30,7 @@ const receiveLinkSpillBytes = 64 * mib;
|
|
|
30
30
|
* 300 s `cpu_ms`. A link took 810.6 ns of CPU end to end on Node 24 (25 Nov 2026: a receive of 200
|
|
31
31
|
* delta trees of 100,000 entries each, less one of 20), so 80M take 64.8 s, and 284 s at 3.5 times
|
|
32
32
|
* that, the slowest Workers ran a receive against Node, with a quarter's margin. Linux's 1M objects
|
|
33
|
-
* name about 50M, and
|
|
33
|
+
* name about 50M, and about 52M at 1,048,528, the most a push takes. Past it, the push is refused as too large by name. Its runs
|
|
34
34
|
* keep each object and type once, so links that name few objects many times, as a delta tree's
|
|
35
35
|
* copies can, reach it before `receiveLinkSpillBytes`. It's within the 2^30 places a link row holds.
|
|
36
36
|
*/
|
|
@@ -53,8 +53,8 @@ const receiveSweepHeldBytes = 16 * mib;
|
|
|
53
53
|
/**
|
|
54
54
|
* The most bytes of rows one sweep's deferred entries and their bases' holds put, 64 MiB, as
|
|
55
55
|
* `receiveLinkSpillBytes` is a push's links. svelte's first push and its whole history at
|
|
56
|
-
* `707c2814` each write 0.42 rows an object, of 12 B (25 Nov 2026), so 1,
|
|
57
|
-
* write about
|
|
56
|
+
* `707c2814` each write 0.42 rows an object, of 12 B (25 Nov 2026), so 1,048,528 objects would
|
|
57
|
+
* write about 5.3 MB. Past it, the push is refused as too large.
|
|
58
58
|
*/
|
|
59
59
|
const receiveDeferredSpillBytes = 64 * mib;
|
|
60
60
|
/**
|
|
@@ -85,15 +85,16 @@ const receiveCutParentsMost = 2 * receiveBoundaryMost;
|
|
|
85
85
|
*/
|
|
86
86
|
const receiveDropPage = 1e3;
|
|
87
87
|
/**
|
|
88
|
-
* One try of an import or a
|
|
89
|
-
* it, the queue aborts the try's signal, which every
|
|
88
|
+
* One try of an import, a mirror or a push upload: a segment of history under 100 MB, one push of
|
|
89
|
+
* a ref, or one step of an uploaded pack. At it, the queue aborts the try's signal, which every
|
|
90
|
+
* receive step's bucket and store calls take.
|
|
90
91
|
*/
|
|
91
92
|
const importTryTimeout = "13 minutes";
|
|
92
93
|
/**
|
|
93
94
|
* How long after a receive's keys may last have been put clean-up waits to delete them: its
|
|
94
95
|
* `staged` row's wait, from the landing, the end or the drop that left them. A step puts them
|
|
95
|
-
* only inside an import try, after its claim and its read of its quarantine,
|
|
96
|
-
* long that try's calls can run:
|
|
96
|
+
* only inside an import's or a push upload's try, after its claim and its read of its quarantine,
|
|
97
|
+
* so it's bound by how long that try's calls can run:
|
|
97
98
|
* - On Cloudflare, an alarm's `alarmWallTime`, 15 minutes from before the claim. R2's calls
|
|
98
99
|
* through its binding take no signal, so one started before the try's timeout runs on, but
|
|
99
100
|
* the alarm's end stops it.
|
|
@@ -116,6 +117,26 @@ const receiveStepGrace = Math.max(millis(importTryTimeout), alarmWallTime) + job
|
|
|
116
117
|
* then joins in one more.
|
|
117
118
|
*/
|
|
118
119
|
const receiveStepFloor = 12e6;
|
|
120
|
+
/** The share of a try's CPU a push upload's streaming step reads for: the rest is its reads and commit. */
|
|
121
|
+
const receiveCpuShare = .8;
|
|
122
|
+
/** The CPU a job's try may use when its host names none: Workers' 30 s with no `cpu_ms` set. */
|
|
123
|
+
const tryCpuMsDefault = 3e4;
|
|
124
|
+
/**
|
|
125
|
+
* The least a push upload's streaming step reads, 1 MiB: its share of the pack, below which the
|
|
126
|
+
* step's own reads of its stage and its commit outweigh what it receives. Unlike an import's
|
|
127
|
+
* `receiveStepFloor`, which holds an import's 8 steps to its segment, it never raises a share past
|
|
128
|
+
* the CPU its host gives: a push takes as many steps as its share needs.
|
|
129
|
+
*/
|
|
130
|
+
const pushStepLeast = mib;
|
|
131
|
+
/**
|
|
132
|
+
* The bytes a push upload's streaming step reads before it pauses, from the CPU its host gives a
|
|
133
|
+
* try, `cpuMs`: `receiveCpuShare` of it, at `receiveMsPerMiB`. At Workers' 30 s it's 60 MiB, so
|
|
134
|
+
* 1 GiB streams in 18 steps; at 300 s, 600 MiB, in 2; at 1 s, 2 MiB. It's a threshold: a step
|
|
135
|
+
* pauses only between entries, so it reads its share and at most the entry it's in, which a blob
|
|
136
|
+
* past the share costs whole, `receiveMsPerMiB` a MiB of it. Under `pushStepLeast`, at under
|
|
137
|
+
* `pushCpuMsLeast`, the job refuses the upload.
|
|
138
|
+
*/
|
|
139
|
+
const pushStepBytesOf = (cpuMs) => Math.floor(receiveCpuShare * (cpuMs ?? 3e4) / 400 * mib);
|
|
119
140
|
/**
|
|
120
141
|
* The found rows a receive's join may still write, from its `links` and the pack's `objects`: one
|
|
121
142
|
* for each ID a link names that the table finds among the pack's objects, so at most a link row
|
|
@@ -200,4 +221,4 @@ const receiveCallsAfter = (written, multipart, batch) => {
|
|
|
200
221
|
const runs = written.others + objects.length + commits.length + found.length + links.length + joined.runs + merges.reduce((sum, merge) => sum + merge.runs, 0);
|
|
201
222
|
return lastRuns.reduce((sum, length) => sum + sizedPutCalls(multipart, length), 0) + merges.reduce((sum, merge) => sum + merge.calls, 0) + files.reduce((sum, bytes) => sum + sizedPutCalls(multipart, bytes), 0) + dropRunsCalls(runs, batch);
|
|
202
223
|
};
|
|
203
|
-
export { dropRunsCalls, importTryTimeout, joinFoundMost, mergeCallsOf, receiveBoundaryMost, receiveCallsAfter, receiveCheckRunBytes, receiveCutParentsMost, receiveDeferredSpillBytes, receiveDropPage, receiveLinkSpillBytes, receiveLinksMost, receiveMergeReadBytes, receiveRunBytes, receiveStepFloor, receiveStepGrace, receiveSweepHeldBytes, receiveTableMost };
|
|
224
|
+
export { dropRunsCalls, importTryTimeout, joinFoundMost, mergeCallsOf, pushStepBytesOf, pushStepLeast, receiveBoundaryMost, receiveCallsAfter, receiveCheckRunBytes, receiveCpuShare, receiveCutParentsMost, receiveDeferredSpillBytes, receiveDropPage, receiveLinkSpillBytes, receiveLinksMost, receiveMergeReadBytes, receiveRunBytes, receiveStepFloor, receiveStepGrace, receiveSweepHeldBytes, receiveTableMost, tryCpuMsDefault };
|
|
@@ -64,6 +64,14 @@ const StepState = /* @__PURE__ */ Schema.Struct({
|
|
|
64
64
|
kind: objectType,
|
|
65
65
|
size: Schema.Int
|
|
66
66
|
})])),
|
|
67
|
+
/** The largest blobs so far, largest first, on a step that lists them, as `StepInput.largest` says. */
|
|
68
|
+
largest: Schema.optional(Schema.Struct({
|
|
69
|
+
largest: Schema.Array(Schema.Struct({
|
|
70
|
+
oid: Schema.String,
|
|
71
|
+
size: Schema.Int
|
|
72
|
+
})),
|
|
73
|
+
largestPartial: Schema.optionalKey(Schema.Literal(true))
|
|
74
|
+
})),
|
|
67
75
|
/**
|
|
68
76
|
* Past the body's end, what the joining step takes on with: the cut its join hands back, and
|
|
69
77
|
* the merges the sweeps' and checks' runs cost, for the join's share of the calls.
|
|
@@ -12,7 +12,8 @@ import { storeStep } from "./pack-receive.mjs";
|
|
|
12
12
|
import { deletePackFiles, dropRefused, openQuarantine, quarantineOf, quarantineState } from "./quarantine.mjs";
|
|
13
13
|
import { putStepState, readStepState, stepStateKeys } from "./receive-state.mjs";
|
|
14
14
|
import { markerPrefix, objectCollections, packFiles, receivePrefix } from "./layout.mjs";
|
|
15
|
-
import {
|
|
15
|
+
import { fileBytesMost } from "./file-limits.mjs";
|
|
16
|
+
import { receiveCpuShare, receiveDropPage, receiveStepFloor, receiveStepGrace } from "./receive-bounds.mjs";
|
|
16
17
|
import { decodeHeld, quarantineKey, stagedKey } from "./rows.mjs";
|
|
17
18
|
import * as Effect from "effect/Effect";
|
|
18
19
|
import * as Schema from "effect/Schema";
|
|
@@ -34,6 +35,11 @@ const ReceiveRow = /* @__PURE__ */ Schema.Struct({
|
|
|
34
35
|
step: Schema.Int,
|
|
35
36
|
/** The try whose state the next step reads: none before the first step commits. */
|
|
36
37
|
attempt: Schema.optional(Schema.String),
|
|
38
|
+
/**
|
|
39
|
+
* The streaming steps that paused on what they inflated before reading their share, as
|
|
40
|
+
* `stepInflatedMostOf` says: `streamStepsMost` doesn't count them, since each reads less (#2500).
|
|
41
|
+
*/
|
|
42
|
+
inflated: Schema.optional(Schema.Int),
|
|
37
43
|
committed: Schema.Int
|
|
38
44
|
});
|
|
39
45
|
const receiveKey = (pack) => ({
|
|
@@ -112,14 +118,15 @@ const deleteStaged = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, pack)
|
|
|
112
118
|
} while (after !== void 0);
|
|
113
119
|
});
|
|
114
120
|
/**
|
|
115
|
-
* What a receive in steps reads at each step's start, as the fetch
|
|
116
|
-
* it:
|
|
117
|
-
* and trailer, checked at staging.
|
|
121
|
+
* What a receive in steps reads at each step's start, as the fetch or the push upload that staged
|
|
122
|
+
* its pack answered it: an import segment's boundary, the commits it needs and its cut's most, or a
|
|
123
|
+
* push's `shallow` lines, and the staged pack's bytes and trailer, checked at staging.
|
|
118
124
|
*/
|
|
119
125
|
const ReceiveAnswer = /* @__PURE__ */ Schema.Struct({
|
|
120
126
|
boundary: Schema.Array(Schema.String),
|
|
121
127
|
needs: Schema.Array(Schema.String),
|
|
122
128
|
cutMost: Schema.optional(Schema.Int),
|
|
129
|
+
shallow: Schema.optional(Schema.Array(Schema.String)),
|
|
123
130
|
bytes: Schema.Int,
|
|
124
131
|
checksum: Schema.String
|
|
125
132
|
});
|
|
@@ -222,8 +229,8 @@ const dropReceive = (input) => bestEffort(Effect.gen(function* () {
|
|
|
222
229
|
})).ok) return yield* dropRefused(input);
|
|
223
230
|
}
|
|
224
231
|
}));
|
|
225
|
-
const stepsTooLarge = fail("RESOURCE_EXHAUSTED", `The
|
|
226
|
-
hint: "Import a smaller segment",
|
|
232
|
+
const stepsTooLarge = (most) => fail("RESOURCE_EXHAUSTED", `The pack needs more than ${most} steps to receive`, {
|
|
233
|
+
hint: "Import a smaller segment, or push fewer commits at a time",
|
|
227
234
|
context: { reason: "too-large" }
|
|
228
235
|
});
|
|
229
236
|
/**
|
|
@@ -233,6 +240,40 @@ const stepsTooLarge = fail("RESOURCE_EXHAUSTED", `The segment needs more than 8
|
|
|
233
240
|
*/
|
|
234
241
|
const stepShareOf = (bytes) => Math.max(Math.ceil(bytes / 8), receiveStepFloor);
|
|
235
242
|
/**
|
|
243
|
+
* The shares one entry of a push upload's step may be, 4: a step may read its share at
|
|
244
|
+
* `receiveMsPerMiB` before the entry starts, so the entry has the CPU the share leaves, the
|
|
245
|
+
* try's `1 - receiveCpuShare`, at `entryMsPerMiB` a MiB.
|
|
246
|
+
*/
|
|
247
|
+
const entrySharesMost = Math.round((1 - receiveCpuShare) / receiveCpuShare * 16);
|
|
248
|
+
/**
|
|
249
|
+
* The largest entry a push upload's step of `share` reads, as `StepInput.largest` has it: 240 MiB
|
|
250
|
+
* at Workers' 30 s, 4 MiB at 500 ms, and at most `fileBytesMost`. One past it is refused at its
|
|
251
|
+
* header, by its offset, before any of it is read, rather than read past the try's CPU (#2468).
|
|
252
|
+
*/
|
|
253
|
+
const stepEntryMostOf = (share) => Math.min(fileBytesMost, share * entrySharesMost);
|
|
254
|
+
/**
|
|
255
|
+
* The shares a push upload's step inflates before it pauses, 12: the try's whole CPU, 20 shares at
|
|
256
|
+
* `entryMsPerMiB` a MiB inflated, as a share stands for `receiveCpuShare` of it at
|
|
257
|
+
* `receiveMsPerMiB`, less the 8 its last entry may add past the pause check, a delta's
|
|
258
|
+
* instructions and its result, each to `stepEntryMostOf`.
|
|
259
|
+
*/
|
|
260
|
+
const inflatedSharesMost = Math.round(16 / receiveCpuShare) - 2 * entrySharesMost;
|
|
261
|
+
/**
|
|
262
|
+
* What a push upload's step of `share` inflates, its entries' data and its deltas' results, before
|
|
263
|
+
* it pauses between entries, though it read less than its share: 720 MiB at Workers' 30 s, 12 MiB
|
|
264
|
+
* at 500 ms. A pack of files that compress well would otherwise inflate past the try's CPU before
|
|
265
|
+
* its compressed bytes reach the share. The check is made as an entry ends, so a step inflates at
|
|
266
|
+
* most this and one more entry: 20 shares with a delta at the entry bound, the try's CPU at
|
|
267
|
+
* `entryMsPerMiB`, before its state's reads and its commit (#2500).
|
|
268
|
+
*/
|
|
269
|
+
const stepInflatedMostOf = (share) => share * inflatedSharesMost;
|
|
270
|
+
/**
|
|
271
|
+
* The most streaming steps a staged pack of `bytes` takes: with a caller's `share`, as many as it
|
|
272
|
+
* takes to read them, since each step that pauses reads at least that much; with none,
|
|
273
|
+
* `receiveStreamStepsMost`, which `stepShareOf` keeps any pack within.
|
|
274
|
+
*/
|
|
275
|
+
const streamStepsMost = (bytes, share) => share === void 0 ? 8 : Math.max(1, Math.ceil(bytes / share));
|
|
276
|
+
/**
|
|
236
277
|
* A step whose quarantine isn't open, its stage over (#1502): what it and clean-up left deleted now,
|
|
237
278
|
* not only at its `staged` row's sweep, every key under its prefix but its markers, and its pack's
|
|
238
279
|
* files once no marker holds it. A pack gone with a marker left landed, by another try, so its
|
|
@@ -252,9 +293,10 @@ const stageOver = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, pack, sta
|
|
|
252
293
|
* stops it or past its body's end, its sweeps and checks run, to the join. Either puts what it
|
|
253
294
|
* carries, then commits its record at the version it read, at `streaming` or `joining`. A try
|
|
254
295
|
* that lost the commit deletes the state keys it put. The joining step joins and writes the
|
|
255
|
-
* files, and ends the receive. Past `
|
|
256
|
-
*
|
|
257
|
-
*
|
|
296
|
+
* files, and ends the receive. Past `streamStepsMost` streaming steps, the pack is `too-large`,
|
|
297
|
+
* and dropped, since no try of it lands: a caller's `share` counts by the staged answer it
|
|
298
|
+
* passes, which it must pass with one. A join refused `too-large` keeps its record at `joining`,
|
|
299
|
+
* for a try with more calls. A step whose quarantine isn't open fails `stage-gone`, as `stageOver` says.
|
|
258
300
|
*/
|
|
259
301
|
const receiveStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
260
302
|
const { receiving, opened, pointers } = input;
|
|
@@ -267,14 +309,15 @@ const receiveStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
267
309
|
const read = yield* readReceive(record);
|
|
268
310
|
const step = read.row?.step ?? 0;
|
|
269
311
|
if (read.quarantine !== "open") return yield* stageGone(`A receive in steps found its quarantine ${read.quarantine}`);
|
|
270
|
-
|
|
312
|
+
const most = input.answer === void 0 ? 8 : streamStepsMost(input.answer.bytes, input.share);
|
|
313
|
+
if (read.row?.phase !== "joining" && step - (read.row?.inflated ?? 0) >= most) {
|
|
271
314
|
yield* dropReceive({
|
|
272
315
|
...record,
|
|
273
316
|
bucket,
|
|
274
317
|
indexes,
|
|
275
318
|
at
|
|
276
319
|
});
|
|
277
|
-
return yield* stepsTooLarge;
|
|
320
|
+
return yield* stepsTooLarge(most);
|
|
278
321
|
}
|
|
279
322
|
const attempt = newAttempt();
|
|
280
323
|
const keys = stepStateKeys(opened.pack, step, attempt);
|
|
@@ -285,14 +328,21 @@ const receiveStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
285
328
|
const before = read.row?.attempt;
|
|
286
329
|
const carried = before === void 0 ? void 0 : yield* readStepState(bucket, stepStateKeys(opened.pack, step - 1, before), pointers);
|
|
287
330
|
const start = carried?.state.resume.offset ?? 0;
|
|
288
|
-
const share = stepShareOf(answer.bytes);
|
|
289
|
-
const
|
|
290
|
-
|
|
331
|
+
const share = input.share ?? stepShareOf(answer.bytes);
|
|
332
|
+
const inflatedMost = input.largest === true ? stepInflatedMostOf(share) : void 0;
|
|
333
|
+
let pausedInflated = false;
|
|
334
|
+
const pause = input.pause ?? ((_, offset, inflated) => {
|
|
335
|
+
if (offset - start >= share) return true;
|
|
336
|
+
pausedInflated = inflatedMost !== void 0 && inflated >= inflatedMost;
|
|
337
|
+
return pausedInflated;
|
|
338
|
+
});
|
|
339
|
+
const { cutMost, boundary, needs, shallow } = answer;
|
|
291
340
|
const receive = {
|
|
292
341
|
...receiving.receive,
|
|
293
342
|
boundary,
|
|
294
343
|
needs,
|
|
295
|
-
...cutMost !== void 0 && { cutMost }
|
|
344
|
+
...cutMost !== void 0 && { cutMost },
|
|
345
|
+
...shallow !== void 0 && shallow.length > 0 && { shallow }
|
|
296
346
|
};
|
|
297
347
|
const memory = {
|
|
298
348
|
...receiving.memory,
|
|
@@ -311,15 +361,18 @@ const receiveStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
311
361
|
attempt,
|
|
312
362
|
staged,
|
|
313
363
|
pause,
|
|
314
|
-
...carried && { carried }
|
|
364
|
+
...carried && { carried },
|
|
365
|
+
...input.largest === true && { largest: { entryMost: stepEntryMostOf(share) } }
|
|
315
366
|
});
|
|
316
367
|
if (!("paused" in stored)) return { received: stored };
|
|
317
368
|
const { state, table } = stored.paused;
|
|
318
369
|
yield* putStepState(bucket, keys, state, table, stored.paused.pointers, stored.paused.checked);
|
|
370
|
+
const inflated = (read.row?.inflated ?? 0) + (pausedInflated ? 1 : 0);
|
|
319
371
|
const next = {
|
|
320
372
|
phase: state.joining === void 0 ? "streaming" : "joining",
|
|
321
373
|
cursor: state.resume.offset,
|
|
322
|
-
objects: receive.objects
|
|
374
|
+
objects: receive.objects,
|
|
375
|
+
...inflated > 0 && { inflated }
|
|
323
376
|
};
|
|
324
377
|
return {
|
|
325
378
|
committed: yield* commitStep({
|
|
@@ -341,4 +394,4 @@ const receiveStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
341
394
|
yield* bestEffort(bucketDeleteMany(bucket, Object.values(keys)));
|
|
342
395
|
return ended;
|
|
343
396
|
});
|
|
344
|
-
export { ReceiveAnswer, ReceiveRow, answerKey, commitStep, deleteStaged, dropReceive, newAttempt, putAnswer, readAnswer, readReceive, receiveKey, receiveStep, stageReceive, stagedRow, stepShareOf };
|
|
397
|
+
export { ReceiveAnswer, ReceiveRow, answerKey, commitStep, deleteStaged, dropReceive, newAttempt, putAnswer, readAnswer, readReceive, receiveKey, receiveStep, stageReceive, stagedRow, stepEntryMostOf, stepInflatedMostOf, stepShareOf, streamStepsMost };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "../index.mjs";
|
|
2
|
-
import "./pack-reads.mjs";
|
|
3
2
|
import "./merge.mjs";
|
|
4
3
|
import "../contracts/objects.mjs";
|
|
5
4
|
import "../contracts/promises.mjs";
|
|
@@ -8,6 +7,7 @@ import "../contracts/services.mjs";
|
|
|
8
7
|
import "../contracts/store.mjs";
|
|
9
8
|
import "./memory-budget.mjs";
|
|
10
9
|
import "./object-rows.mjs";
|
|
10
|
+
import "./pack-reads.mjs";
|
|
11
11
|
import "./rows.mjs";
|
|
12
12
|
import "effect/Effect";
|
|
13
13
|
import { Key, Moment, Row } from "@ref0/infra";
|
package/dist/storage/repack.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { repoScope } from "../store/scopes.mjs";
|
|
2
2
|
import { isPackId, objectCollections } from "./layout.mjs";
|
|
3
|
-
import { upkeepTooLarge } from "./memory-budget.mjs";
|
|
4
3
|
import { backlogPacksMost } from "./repack-backlog.mjs";
|
|
5
4
|
import { foldedRows } from "./merge-choose.mjs";
|
|
6
5
|
import "./merge-cut.mjs";
|
|
7
6
|
import { writeMerged } from "./merge.mjs";
|
|
8
7
|
import { largeBatch, objectKey, objectOfRow, rowsMoved, tooLargeRead } from "./object-rows.mjs";
|
|
9
|
-
import { indexBytes } from "./pack-reads.mjs";
|
|
10
8
|
import { leavingRow, pruneFloor } from "./rows.mjs";
|
|
11
9
|
import * as Effect from "effect/Effect";
|
|
12
10
|
import { byBytes, limits } from "@ref0/infra";
|
|
@@ -152,11 +150,6 @@ const namedOf = (pack) => isPackId(pack.id) ? Effect.succeed({
|
|
|
152
150
|
...pack,
|
|
153
151
|
id: pack.id
|
|
154
152
|
}) : Effect.die(/* @__PURE__ */ new Error(`The pack row '${pack.id}' doesn't name a pack`));
|
|
155
|
-
/**
|
|
156
|
-
* `packs`' indexes, each charged to the step's allotment while its scope holds it, as a reader's
|
|
157
|
-
* are: the index cache may let go of one the step still holds.
|
|
158
|
-
*/
|
|
159
|
-
const loadAll = (input, packs) => Effect.forEach(packs, (pack) => Effect.andThen(Effect.acquireRelease(input.allotment.grow(indexBytes(pack), upkeepTooLarge), () => Effect.sync(() => input.allotment.shrink(indexBytes(pack))), { interruptible: true }), input.indexes.load(input.bucket, pack)));
|
|
160
153
|
/** `writeMerged` of `merge`, the step's object rows, with the step's store, bucket and repo. */
|
|
161
154
|
const mergeWith = (input, merge) => writeMerged({
|
|
162
155
|
store: input.store,
|
|
@@ -265,4 +258,4 @@ const geometricGroup = (members, options, inputsMost = Number.POSITIVE_INFINITY,
|
|
|
265
258
|
}
|
|
266
259
|
return group.length < 2 ? [] : group;
|
|
267
260
|
};
|
|
268
|
-
export { burstGroupBytes, burstOptions, burstPacksMost, burstQuietMs, defaultRepack, geometricGroup, groupWrites, holdingsOf, holdsOf, leavingRows,
|
|
261
|
+
export { burstGroupBytes, burstOptions, burstPacksMost, burstQuietMs, defaultRepack, geometricGroup, groupWrites, holdingsOf, holdsOf, leavingRows, maxPackSizeMost, mergeWith, namedOf, optionFor, readObjectRows, replacing, rowsBytes, shareOf, swapsOf, wholeRows };
|
package/dist/storage/rows.mjs
CHANGED
|
@@ -115,6 +115,17 @@ const defaultPrune = "14 days";
|
|
|
115
115
|
const pruneWait = (prune) => Math.max(millis(prune), pruneFloor);
|
|
116
116
|
/** When a row written at `at` is due, from `prune` as it is now. */
|
|
117
117
|
const removeAt = (at, prune) => at + pruneWait(prune);
|
|
118
|
+
/**
|
|
119
|
+
* When a deleted repo's packs may go, whatever their rows' own times: `fetchLimits` past its
|
|
120
|
+
* delete, at `deletedAt`. A deleted repo answers no open, so no fetch begins after the delete, and
|
|
121
|
+
* a push's writes begin by its first read plus `fetchLimits` less `jobLeaseMargin`, `heldUntil`'s
|
|
122
|
+
* bound (#2326), a read that came before the delete. So no fetch reads its packs and no push adds
|
|
123
|
+
* one past it: its listed packs' `leaving` rows (#2432) and its open `quarantine` rows (#2476)
|
|
124
|
+
* are due then. The `staged` row each abandoned `quarantine` row leaves waits its own
|
|
125
|
+
* `receiveStepGrace` after, for a step that read it open (#1558), so not every key of the repo's
|
|
126
|
+
* is gone at this time.
|
|
127
|
+
*/
|
|
128
|
+
const deletedLeaveAt = (deletedAt, fetchLimits) => deletedAt + fetchLimits.milliseconds;
|
|
118
129
|
/** A stored row as `schema`, keyed by a pack's ID; anything else is `DATA_LOSS`. */
|
|
119
130
|
const decodeHeld = (schema, row) => {
|
|
120
131
|
const what = `The ${row.collection} row '${row.id}'`;
|
|
@@ -140,4 +151,4 @@ const decodeLeft = (row) => {
|
|
|
140
151
|
value
|
|
141
152
|
}));
|
|
142
153
|
};
|
|
143
|
-
export { LeavingRow, QuarantineRow, StagedRow, coverKey, coverRow, decodeHeld, decodeLeft, defaultPrune, isLeftKey, leavingKey, leavingLate, leavingRow, leftPack, pruneFloor, pruneWait, quarantineKey, quarantineRow, removeAt, stagedKey };
|
|
154
|
+
export { LeavingRow, QuarantineRow, StagedRow, coverKey, coverRow, decodeHeld, decodeLeft, defaultPrune, deletedLeaveAt, isLeftKey, leavingKey, leavingLate, leavingRow, leftPack, pruneFloor, pruneWait, quarantineKey, quarantineRow, removeAt, stagedKey };
|