@ref0/git 0.14.0 → 0.20.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/auth/access-jwt.mjs +2 -2
- package/dist/auth/authorize.mjs +3 -3
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.mjs +4 -4
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/token-cleanup.mjs +67 -0
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/token-text.mjs +9 -1
- package/dist/auth/tokens-base.d.mts +35 -0
- package/dist/auth/tokens-base.mjs +13 -0
- package/dist/auth/tokens-layer.d.mts +2 -27
- package/dist/auth/tokens-layer.mjs +6 -11
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -10
- package/dist/auth/tokens.mjs +9 -80
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +17 -7
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +9 -8
- package/dist/client/remote.mjs +8 -10
- package/dist/client/run-remote-helper.d.mts +1 -0
- package/dist/client/run-remote-helper.mjs +58 -24
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +105 -46
- package/dist/contracts/blobs.d.mts +55 -8
- package/dist/contracts/blobs.mjs +16 -2
- package/dist/contracts/call-allowance.d.mts +13 -0
- package/dist/contracts/call-allowance.mjs +44 -0
- package/dist/contracts/calls-spent.mjs +8 -3
- package/dist/contracts/client.d.mts +15 -16
- package/dist/contracts/commits.d.mts +24 -24
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +10 -10
- package/dist/contracts/forks.d.mts +17 -17
- package/dist/contracts/git-events.d.mts +29 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +21 -0
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -2
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +23 -25
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +26 -23
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +4 -1
- package/dist/contracts/repos.d.mts +29 -138
- package/dist/contracts/repos.mjs +5 -3
- package/dist/contracts/result.d.mts +35 -16
- package/dist/contracts/result.mjs +35 -7
- package/dist/contracts/server.d.mts +25 -50
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +11 -7
- package/dist/contracts/sync.mjs +12 -2
- package/dist/contracts/tags.d.mts +10 -10
- package/dist/contracts/time.d.mts +3 -0
- package/dist/contracts/{promises.mjs → time.mjs} +1 -1
- package/dist/contracts/tokens.d.mts +15 -17
- package/dist/contracts/tokens.mjs +3 -2
- package/dist/contracts/topics.d.mts +1 -1
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +24 -13
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +20 -9
- package/dist/core/ancestry.d.mts +1 -0
- package/dist/core/asked.mjs +1 -1
- package/dist/core/call-names.mjs +6 -1
- package/dist/core/call-services.mjs +11 -3
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +43 -36
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +928 -432
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +29 -23
- package/dist/core/index-job.mjs +122 -34
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/lines.mjs +2 -2
- package/dist/core/objects/merges.mjs +4 -1
- package/dist/core/objects/objects-layer.d.mts +1 -1
- package/dist/core/objects/objects-layer.mjs +3 -3
- package/dist/core/objects/reading.mjs +24 -13
- package/dist/core/objects/tags.mjs +4 -1
- package/dist/core/objects/trees.mjs +2 -2
- package/dist/core/objects/writing.mjs +2 -2
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +4 -5
- package/dist/core/parts.mjs +3 -8
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +287 -83
- package/dist/core/push-decide.mjs +2 -0
- package/dist/core/push-files.d.mts +1 -1
- package/dist/core/push.mjs +58 -47
- package/dist/core/receipts.mjs +8 -3
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +2 -2
- package/dist/core/refs.mjs +5 -5
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +36 -21
- package/dist/core/repo-info.mjs +3 -3
- package/dist/core/repos.mjs +21 -9
- package/dist/core/rules/commit-changes.d.mts +0 -1
- package/dist/core/saved-caller-views.d.mts +7 -2
- package/dist/core/saved-caller-views.mjs +2 -2
- package/dist/core/saved-callers.d.mts +19 -2
- package/dist/core/seam.d.mts +16 -26
- package/dist/core/seam.mjs +7 -28
- package/dist/core/tokens.mjs +1 -1
- package/dist/core/view.mjs +7 -15
- package/dist/core/work.mjs +59 -14
- package/dist/effect.d.mts +3 -12
- package/dist/effect.mjs +1 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +4 -4
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +37 -14
- package/dist/extend.d.mts +2 -3
- package/dist/extend.mjs +2 -1
- package/dist/http/answers.mjs +8 -5
- package/dist/http/core-parts.mjs +95 -79
- package/dist/http/handler.mjs +34 -7
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +56 -27
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +30 -26
- package/dist/http/push-uploads.mjs +36 -21
- package/dist/http/upload-pack.mjs +3 -3
- package/dist/index.d.mts +14 -14
- package/dist/index.mjs +2 -2
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +2 -0
- package/dist/lfs/base.mjs +25 -1
- package/dist/lfs/copy.d.mts +21 -7
- package/dist/lfs/copy.mjs +89 -6
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +24 -11
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -0
- package/dist/lfs/objects.mjs +87 -17
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/streams.mjs +27 -1
- package/dist/protocol/diff/read.d.mts +4 -3
- package/dist/protocol/diff/read.mjs +8 -3
- package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
- package/dist/protocol/objects/lfs-pointer.mjs +1 -3
- package/dist/protocol/objects/links-raw.mjs +24 -10
- package/dist/protocol/objects/tag.d.mts +1 -1
- package/dist/protocol/objects/tree.mjs +23 -6
- package/dist/protocol/packs/delta.d.mts +6 -3
- package/dist/protocol/packs/delta.mjs +96 -32
- package/dist/protocol/packs/idx.d.mts +2 -1
- package/dist/protocol/packs/idx.mjs +22 -3
- package/dist/protocol/packs/parts.d.mts +4 -1
- package/dist/protocol/packs/parts.mjs +10 -7
- package/dist/protocol/packs/reader.d.mts +5 -0
- package/dist/protocol/packs/reader.mjs +3 -2
- package/dist/protocol/packs/writer.mjs +26 -8
- package/dist/queue/advance.mjs +21 -24
- package/dist/queue/base.d.mts +55 -0
- package/dist/queue/base.mjs +44 -0
- package/dist/queue/calls.mjs +51 -54
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -15
- package/dist/queue/host.mjs +2 -7
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +10 -3
- package/dist/queue/limits.mjs +2 -0
- package/dist/queue/push-option.mjs +9 -24
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/state.mjs +2 -10
- package/dist/queue/trim.mjs +5 -3
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4271
- package/dist/rest/caller.mjs +4 -0
- package/dist/rest/client.d.mts +8 -5
- package/dist/rest/client.mjs +19 -2
- package/dist/rest/handlers.mjs +50 -5
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +5 -12
- package/dist/rest/me.d.mts +3 -432
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +11 -8
- package/dist/server/edge-node.mjs +9 -6
- package/dist/server/edge.d.mts +21 -7
- package/dist/server/edge.mjs +32 -11
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +5 -5
- package/dist/server/git-layer.mjs +28 -22
- package/dist/server/git-namespace.d.mts +4 -3
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +6 -18
- package/dist/server/joined.mjs +9 -36
- package/dist/server/lifecycle.mjs +18 -106
- package/dist/server/registry.mjs +24 -7
- package/dist/server/server.mjs +205 -346
- package/dist/signin/context.d.mts +1 -2
- package/dist/signin/layer.d.mts +1 -1
- package/dist/signin/layer.mjs +1 -1
- package/dist/storage/allotted.mjs +18 -3
- package/dist/storage/batch-upkeep.mjs +274 -0
- package/dist/storage/batches.d.mts +8 -0
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/calls.d.mts +1 -2
- package/dist/storage/calls.mjs +144 -158
- package/dist/storage/chunks.d.mts +9 -0
- package/dist/storage/chunks.mjs +297 -0
- package/dist/storage/clean-up.mjs +72 -9
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +287 -210
- package/dist/storage/host-bucket.mjs +1 -2
- package/dist/storage/id-mix.mjs +19 -5
- package/dist/storage/index-bitmaps.mjs +9 -2
- package/dist/storage/index-build.d.mts +0 -1
- package/dist/storage/index-build.mjs +80 -23
- package/dist/storage/index-fetch.mjs +113 -72
- package/dist/storage/index-files.d.mts +3 -0
- package/dist/storage/index-files.mjs +10 -5
- package/dist/storage/index-graph.mjs +72 -22
- package/dist/storage/index-remap.mjs +200 -64
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +1 -1
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +212 -67
- package/dist/storage/memory-budget.mjs +16 -4
- package/dist/storage/merge-plan.mjs +3 -2
- package/dist/storage/merge-row.mjs +7 -1
- package/dist/storage/merge-stream.mjs +164 -25
- package/dist/storage/merge-walk.mjs +8 -4
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +1 -0
- package/dist/storage/object-rows.mjs +385 -65
- package/dist/storage/oid-table.mjs +171 -0
- package/dist/storage/pack-order.mjs +8 -4
- package/dist/storage/pack-ranges.d.mts +1 -2
- package/dist/storage/pack-ranges.mjs +4 -5
- package/dist/storage/pack-reads.d.mts +2 -1
- package/dist/storage/pack-reads.mjs +158 -42
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +2 -2
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +136 -66
- package/dist/storage/placed-reads.mjs +1 -1
- package/dist/storage/plan-columns.d.mts +4 -0
- package/dist/storage/plan-columns.mjs +238 -0
- package/dist/storage/prune-keep.mjs +134 -41
- package/dist/storage/prune-walk.mjs +202 -62
- package/dist/storage/prune.mjs +194 -91
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +4 -4
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +8 -6
- package/dist/storage/receive-bounds.mjs +23 -8
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.mjs +195 -43
- package/dist/storage/send-list.d.mts +1 -0
- package/dist/storage/send-list.mjs +54 -10
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +127 -26
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +2 -2
- package/dist/storage/walk.mjs +192 -38
- package/dist/storage/wants.mjs +5 -5
- package/dist/store/bodies.mjs +38 -0
- package/dist/store/call-count.d.mts +8 -12
- package/dist/store/call-count.mjs +34 -46
- package/dist/store/catalogue.d.mts +2 -2
- package/dist/store/catalogue.mjs +145 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal.d.mts +1 -2
- package/dist/store/cursor-seal.mjs +16 -6
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +15 -33
- package/dist/store/git-store.mjs +25 -7
- package/dist/store/job-try.mjs +9 -32
- package/dist/store/list-job.mjs +44 -8
- package/dist/store/records.d.mts +3 -0
- package/dist/store/records.mjs +3 -0
- package/dist/store/repo-record.d.mts +1 -2
- package/dist/store/repo-record.mjs +32 -20
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +11 -0
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/github.mjs +3 -3
- package/dist/sync/import.mjs +31 -18
- package/dist/sync/lfs-batch.mjs +4 -5
- package/dist/sync/lfs-copy.mjs +17 -6
- package/dist/sync/mirror.mjs +34 -31
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/step.mjs +33 -25
- package/dist/sync/tries.mjs +9 -9
- package/dist/topics/advance.mjs +10 -11
- package/dist/topics/base.d.mts +15 -0
- package/dist/topics/base.mjs +8 -0
- package/dist/topics/host.mjs +1 -1
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +2 -3
- package/dist/topics/members.mjs +4 -4
- package/dist/topics/public.d.mts +2 -1
- package/dist/topics/topic.mjs +2 -2
- package/package.json +5 -4
- package/dist/contracts/promises.d.mts +0 -39
- package/dist/core/call-names.d.mts +0 -3
- package/dist/core/clock.mjs +0 -18
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -833
- package/dist/rest/commits.d.mts +0 -3543
- package/dist/rest/errors.d.mts +0 -2124
- package/dist/rest/events.d.mts +0 -426
- package/dist/rest/files.d.mts +0 -1342
- package/dist/rest/forks.d.mts +0 -2160
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -477
- package/dist/rest/queue.d.mts +0 -5917
- package/dist/rest/refs.d.mts +0 -2988
- package/dist/rest/repos.d.mts +0 -2567
- package/dist/rest/tags.d.mts +0 -1316
- package/dist/rest/tokens.d.mts +0 -2614
- package/dist/rest/topics.d.mts +0 -2224
- package/dist/rest/trees.d.mts +0 -1709
- package/dist/rest/work.d.mts +0 -1695
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
package/dist/storage/loose.mjs
CHANGED
|
@@ -1,29 +1,51 @@
|
|
|
1
|
+
import { streamThen } from "../protocol/bytes/streams.mjs";
|
|
1
2
|
import { handingOn } from "../protocol/packs/writer.mjs";
|
|
2
3
|
import { newChangeId } from "../store/scopes.mjs";
|
|
3
4
|
import { callScope } from "../store/call-count.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { cancelsBody, objectReader } from "./calls.mjs";
|
|
5
6
|
import { fetchPack } from "./fetch.mjs";
|
|
6
7
|
import { pushedCommitsPage } from "./pushed-commits.mjs";
|
|
7
|
-
import { copyRowsPage, eachHeldRow, gitObjectOf, heldRows, rowHeaders, rowSizes, rowsStartingWith, startingOf } from "./object-rows.mjs";
|
|
8
|
+
import { copyRowsPage, eachHeldRow, gitObjectOf, heldRows, readsOwnChunks, rowHeaders, rowSizes, rowsStartingWith, startingOf } from "./object-rows.mjs";
|
|
8
9
|
import { allotmentWithin } from "../contracts/object-values.mjs";
|
|
9
10
|
import { allottedRows } from "./allotted.mjs";
|
|
11
|
+
import { looseUpkeep } from "./batch-upkeep.mjs";
|
|
12
|
+
import { abandonBatch, openBatch, rowsChange } from "./batches.mjs";
|
|
13
|
+
import { allottableOf, defaultMemory, readReserveBytes } from "./budget.mjs";
|
|
14
|
+
import { ChunkReader, chunkRawBytes, chunkedReadBytes, chunkedRow, fitsRow, stageChunk } from "./chunks.mjs";
|
|
15
|
+
import { MemoryBudget } from "./memory-budget.mjs";
|
|
10
16
|
import { pointersOfObjects } from "./lfs-pointers.mjs";
|
|
11
17
|
import { largestOf } from "./largest-files.mjs";
|
|
12
18
|
import { wholeRoots } from "./roots.mjs";
|
|
13
19
|
import { commitBytes, unpackObjects } from "./unpack.mjs";
|
|
14
20
|
import { gitError } from "../contracts/result.mjs";
|
|
21
|
+
import * as Clock from "effect/Clock";
|
|
15
22
|
import * as Effect from "effect/Effect";
|
|
23
|
+
import * as Exit from "effect/Exit";
|
|
24
|
+
import * as Scope from "effect/Scope";
|
|
16
25
|
// src/storage/loose.ts
|
|
17
26
|
/** The most objects one push may carry into `loose()` storage, each a row of its commit. */
|
|
18
27
|
const looseObjectsMost = 1e4;
|
|
28
|
+
/** The bytes one object takes in `loose()` storage at most, as Cloudflare Artifacts takes a file. */
|
|
29
|
+
const looseFileBytesMost = 33554432;
|
|
19
30
|
/**
|
|
20
|
-
* What one push may carry into `loose()` storage: its `objects`,
|
|
21
|
-
*
|
|
31
|
+
* What one push may carry into `loose()` storage: its `objects`, the `bytes` of its rows as JSON,
|
|
32
|
+
* which its commit holds, and the bytes of each object, `fileBytes`, one past a row kept as chunks.
|
|
22
33
|
*/
|
|
23
34
|
const looseLimits = {
|
|
24
35
|
objects: looseObjectsMost,
|
|
25
|
-
bytes: commitBytes
|
|
36
|
+
bytes: commitBytes,
|
|
37
|
+
fileBytes: looseFileBytesMost
|
|
26
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* The bytes a push's objects past one row take in all, a delta's results among them: eight of the
|
|
41
|
+
* largest. Without it, a pack of small deltas, each making a large object, could make gigabytes.
|
|
42
|
+
*/
|
|
43
|
+
const largeBytesMost = 8 * looseFileBytesMost;
|
|
44
|
+
/**
|
|
45
|
+
* What a receive holds before any object past a row: its entries, their objects read whole and
|
|
46
|
+
* their rows, each within `bytes`, its reader's buffers, and a chunk filling, waiting and encoded.
|
|
47
|
+
*/
|
|
48
|
+
const receiveFloorOf = (bytes) => 3 * bytes + 1048576 + 3 * chunkRawBytes;
|
|
27
49
|
/** `limits` checked, each a whole number from 1 to `looseLimits`' own, or a `RangeError`. */
|
|
28
50
|
const checkedLoose = (limits) => {
|
|
29
51
|
const each = (kind) => {
|
|
@@ -33,7 +55,8 @@ const checkedLoose = (limits) => {
|
|
|
33
55
|
};
|
|
34
56
|
return {
|
|
35
57
|
objects: each("objects"),
|
|
36
|
-
bytes: each("bytes")
|
|
58
|
+
bytes: each("bytes"),
|
|
59
|
+
fileBytes: each("fileBytes")
|
|
37
60
|
};
|
|
38
61
|
};
|
|
39
62
|
const tooMany = (most) => (count) => gitError("RESOURCE_EXHAUSTED", `push has ${count.toLocaleString("en-US")} objects; this server takes ${most.toLocaleString("en-US")} per push`, {
|
|
@@ -52,29 +75,63 @@ const received = /* @__PURE__ */ new WeakSet();
|
|
|
52
75
|
* as Git's HTTP does; `packs()`'s, whose small pushes are rows too, isn't one.
|
|
53
76
|
*/
|
|
54
77
|
const isLoose = (quarantine) => received.has(quarantine);
|
|
55
|
-
/**
|
|
56
|
-
|
|
78
|
+
/**
|
|
79
|
+
* A push's pack as rows for its commit, its objects past one row as chunks, in its memory's
|
|
80
|
+
* allotment of `budget`: no quarantine row within one commit's rows, and a batch's past them, or
|
|
81
|
+
* once its first chunk opens one. A receive that fails after it opened one abandons it.
|
|
82
|
+
*/
|
|
83
|
+
const receiveRows = (store, listed, receive, limits, budget) => Effect.scoped(Effect.gen(function* () {
|
|
84
|
+
const allotment = yield* budget.admit(receiveFloorOf(limits.bytes));
|
|
85
|
+
const { repo } = listed;
|
|
86
|
+
let opened;
|
|
87
|
+
const large = {
|
|
88
|
+
fileBytes: limits.fileBytes,
|
|
89
|
+
totalBytes: largeBytesMost,
|
|
90
|
+
stage: Effect.fnUntraced(function* (part, index, bytes) {
|
|
91
|
+
opened ??= yield* openBatch({
|
|
92
|
+
store,
|
|
93
|
+
repo,
|
|
94
|
+
at: yield* Clock.currentTimeMillis
|
|
95
|
+
});
|
|
96
|
+
yield* stageChunk(store, repo, opened, part, index, bytes);
|
|
97
|
+
}),
|
|
98
|
+
hold: (bytes) => allotment.grow(bytes),
|
|
99
|
+
staged: (object) => Effect.map(new ChunkReader(store, repo, object.oid, rowOf(object).value, () => Effect.succeed(void 0)).whole(), ({ bytes }) => bytes),
|
|
100
|
+
row: (object) => rowOf(object)
|
|
101
|
+
};
|
|
102
|
+
const rowOf = (object) => chunkedRow(object.oid, object.type, object.size, opened.batch, object.part);
|
|
103
|
+
return yield* receivedRows(store, listed, receive, limits, large, () => opened).pipe(Effect.onError(() => opened === void 0 ? Effect.void : abandonBatch(store, repo, opened.batch)));
|
|
104
|
+
}));
|
|
105
|
+
/** `receiveRows`' receive, its batch `opened()` once its first chunk is staged. */
|
|
106
|
+
const receivedRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed, receive, limits, large, opened) {
|
|
107
|
+
const heldWhole = heldRows(store, listed);
|
|
57
108
|
const unpacked = yield* unpackObjects({
|
|
58
109
|
receive,
|
|
59
110
|
limits,
|
|
60
111
|
tooMany: tooMany(limits.objects),
|
|
61
|
-
held:
|
|
62
|
-
|
|
112
|
+
held: Effect.fnUntraced(function* (oids) {
|
|
113
|
+
const chunked = [...(yield* rowHeaders(store, listed)(oids)).values()].filter(({ type, size }) => !fitsRow(type, size));
|
|
114
|
+
yield* large.hold(chunked.reduce((sum, { size }) => sum + size, 0));
|
|
115
|
+
return yield* heldWhole(oids);
|
|
116
|
+
}),
|
|
117
|
+
headers: rowHeaders(store, listed),
|
|
118
|
+
offsetDeltas: "resolve",
|
|
119
|
+
large
|
|
63
120
|
});
|
|
121
|
+
const staged = yield* rowsChange(store, listed.repo, unpacked.rows, unpacked.moved, opened());
|
|
122
|
+
readsOwnChunks(staged.change, (oid, chunked) => new ChunkReader(store, listed.repo, oid, chunked, () => Effect.succeed(void 0)));
|
|
64
123
|
const quarantine = {
|
|
65
124
|
id: newChangeId(),
|
|
66
|
-
change:
|
|
67
|
-
put: unpacked.rows,
|
|
68
|
-
rows: unpacked.moved
|
|
69
|
-
},
|
|
125
|
+
change: staged.change,
|
|
70
126
|
bytes: unpacked.bytes,
|
|
71
|
-
objects: unpacked.
|
|
127
|
+
objects: unpacked.count,
|
|
72
128
|
lfsPointers: yield* pointersOfObjects(unpacked.objects),
|
|
73
|
-
...largestOf(unpacked.objects)
|
|
129
|
+
...largestOf([...unpacked.objects, ...unpacked.chunked])
|
|
74
130
|
};
|
|
75
131
|
if (unpacked.cut.length > 0) quarantine.cut = unpacked.cut;
|
|
132
|
+
if (staged.quarantine !== void 0) quarantine.quarantine = staged.quarantine;
|
|
76
133
|
received.add(quarantine);
|
|
77
|
-
const whole = receive.partial === true || receive.boundary !== void 0 ? void 0 : wholeRoots(unpacked.objects);
|
|
134
|
+
const whole = receive.partial === true || receive.boundary !== void 0 || unpacked.chunked.length > 0 ? void 0 : wholeRoots(unpacked.objects);
|
|
78
135
|
if (whole === void 0) return quarantine;
|
|
79
136
|
quarantine.roots = whole.roots;
|
|
80
137
|
if (whole.outside.length > 64) return quarantine;
|
|
@@ -85,15 +142,112 @@ const receiveRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed,
|
|
|
85
142
|
};
|
|
86
143
|
return quarantine;
|
|
87
144
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
145
|
+
/**
|
|
146
|
+
* What reading a chunked object of `size` bytes whole holds, allotted from `budget` before its
|
|
147
|
+
* first chunk, and handed to `own` in the step the allot ends in: held until its allotment's
|
|
148
|
+
* `release`, which no scope makes for it. The allot's scope is closed by its failure, so an
|
|
149
|
+
* interrupt or a refusal leaves nothing allotted that no one owns.
|
|
150
|
+
*/
|
|
151
|
+
const chunkedCharge = (budget, size, own) => Effect.uninterruptibleMask((restore) => Effect.flatMap(Scope.make(), (scope) => restore(Scope.provide(scope)(budget.allot(chunkedReadBytes(size)))).pipe(Effect.onError(() => Scope.close(scope, Exit.void)), Effect.map((allotment) => {
|
|
152
|
+
own(allotment);
|
|
153
|
+
return allotment;
|
|
154
|
+
}))));
|
|
155
|
+
/**
|
|
156
|
+
* A reader's charges for the chunked objects `objects` reads whole, each a `chunkedCharge`, held
|
|
157
|
+
* until `give` gives it back, or the reader's `release`.
|
|
158
|
+
*/
|
|
159
|
+
const readerCharges = (budget) => {
|
|
160
|
+
const held = /* @__PURE__ */ new Set();
|
|
161
|
+
const charge = (size) => chunkedCharge(budget, size, (allotment) => void held.add(allotment));
|
|
162
|
+
const give = (allotment) => {
|
|
163
|
+
held.delete(allotment);
|
|
164
|
+
allotment.release();
|
|
165
|
+
};
|
|
166
|
+
const release = () => {
|
|
167
|
+
for (const allotment of held) allotment.release();
|
|
168
|
+
held.clear();
|
|
169
|
+
};
|
|
170
|
+
return {
|
|
171
|
+
charge,
|
|
172
|
+
give,
|
|
173
|
+
release
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* `oid`'s object, or `undefined`. One kept as chunks is read whole once `budget` allots what that
|
|
178
|
+
* holds, and handed on as its body, uncopied, its charge given back once the body is read to its
|
|
179
|
+
* end or cancelled, as every caller does with a body it leaves: not at the reader's release, which
|
|
180
|
+
* comes before a caller streams the body on.
|
|
181
|
+
*/
|
|
182
|
+
const readObject = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed, oid, budget) {
|
|
183
|
+
const read = {};
|
|
184
|
+
const before = (_, size) => Effect.as(chunkedCharge(budget, size, (allotment) => void (read.charged = allotment)), true);
|
|
185
|
+
yield* eachHeldRow(store, listed, before)([oid], (object) => Effect.sync(() => void (read.object = object))).pipe(Effect.onError(() => Effect.sync(() => read.charged?.release())));
|
|
186
|
+
const { object, charged } = read;
|
|
187
|
+
if (object === void 0) return void 0;
|
|
188
|
+
if (charged === void 0) return gitObjectOf(object);
|
|
189
|
+
return {
|
|
190
|
+
oid: object.oid,
|
|
191
|
+
type: object.type,
|
|
192
|
+
size: object.bytes.byteLength,
|
|
193
|
+
bytes: streamThen(object.bytes, () => charged.release())
|
|
194
|
+
};
|
|
91
195
|
});
|
|
92
196
|
/**
|
|
197
|
+
* `before`, with each chunked object's bytes charged to `charges` first: given back if `before`
|
|
198
|
+
* leaves it, and held, if it keeps it, until the reader's release.
|
|
199
|
+
*/
|
|
200
|
+
const chargedFirst = (charges, before) => (oid, size) => Effect.flatMap(charges.charge(size), (allotment) => before(oid, size).pipe(Effect.tap((kept) => kept ? Effect.void : Effect.sync(() => charges.give(allotment))), Effect.onError(() => Effect.sync(() => charges.give(allotment)))));
|
|
201
|
+
/**
|
|
202
|
+
* A fetch's reads of `listed`'s rows. A chunked object is read whole, what that holds allotted
|
|
203
|
+
* from `budget` before its first chunk: for a window, until the writer's next window or the fetch's
|
|
204
|
+
* end, which `ended` gives back; for `each`, until its callback ends, so a walk past several holds
|
|
205
|
+
* one at a time.
|
|
206
|
+
*/
|
|
207
|
+
const fetchReads = (calls, listed, budget) => {
|
|
208
|
+
let window;
|
|
209
|
+
const ended = Effect.suspend(() => {
|
|
210
|
+
const open = window;
|
|
211
|
+
window = void 0;
|
|
212
|
+
return open === void 0 ? Effect.void : Scope.close(open, Exit.void);
|
|
213
|
+
});
|
|
214
|
+
const allotted = (scope) => (_, size) => Effect.as(Scope.provide(scope)(budget.allot(chunkedReadBytes(size))), true);
|
|
215
|
+
const held = Effect.fnUntraced(function* (oids) {
|
|
216
|
+
yield* ended;
|
|
217
|
+
const scope = yield* Scope.make();
|
|
218
|
+
window = scope;
|
|
219
|
+
const objects = /* @__PURE__ */ new Map();
|
|
220
|
+
yield* eachHeldRow(calls, listed, allotted(scope))(oids, (object) => Effect.sync(() => void objects.set(object.oid, object)));
|
|
221
|
+
return objects;
|
|
222
|
+
});
|
|
223
|
+
const each = (oids, take) => {
|
|
224
|
+
let open;
|
|
225
|
+
const closed = Effect.suspend(() => {
|
|
226
|
+
const scope = open;
|
|
227
|
+
open = void 0;
|
|
228
|
+
return scope === void 0 ? Effect.void : Scope.close(scope, Exit.void);
|
|
229
|
+
});
|
|
230
|
+
const before = (oid, size) => Effect.flatMap(closed, () => Effect.flatMap(Scope.make(), (scope) => {
|
|
231
|
+
open = scope;
|
|
232
|
+
return allotted(scope)(oid, size);
|
|
233
|
+
}));
|
|
234
|
+
return Effect.ensuring(eachHeldRow(calls, listed, before)(oids, (object) => Effect.ensuring(take(object), closed)), closed);
|
|
235
|
+
};
|
|
236
|
+
return {
|
|
237
|
+
reads: {
|
|
238
|
+
held,
|
|
239
|
+
each,
|
|
240
|
+
sizes: rowSizes(calls, listed)
|
|
241
|
+
},
|
|
242
|
+
ended
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
93
246
|
* `loose()`: each object a row of the repo's scope, with no bucket. A push of more than
|
|
94
247
|
* `options.objects` objects, 10,000 by default, is refused whole, and so is one whose rows pass
|
|
95
|
-
* `options.bytes`, one commit's 8 MiB by default,
|
|
96
|
-
*
|
|
248
|
+
* `options.bytes`, one commit's 8 MiB by default, of rows within one row's 1 MiB. An object past
|
|
249
|
+
* one row is kept as chunk rows, to `options.fileBytes`, 32 MiB by default, and one past that is
|
|
250
|
+
* refused as `object-too-large`. A whole push names its roots and the rows it links to, so it can
|
|
97
251
|
* keep a repo's whole-clone mark. The client's default.
|
|
98
252
|
*/
|
|
99
253
|
const loose = (options = {}) => {
|
|
@@ -101,59 +255,50 @@ const loose = (options = {}) => {
|
|
|
101
255
|
return {
|
|
102
256
|
needsBucket: false,
|
|
103
257
|
open: ({ store: calls, fetchLimits }) => {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
258
|
+
const budget = new MemoryBudget(allottableOf(defaultMemory), readReserveBytes);
|
|
259
|
+
const openReader = (listed, scope, listedOnly) => {
|
|
260
|
+
const charges = readerCharges(budget);
|
|
261
|
+
return objectReader(listedOnly === true ? {
|
|
262
|
+
object: () => Effect.succeed(void 0),
|
|
263
|
+
sizes: () => Effect.succeed(/* @__PURE__ */ new Map()),
|
|
264
|
+
headers: () => Effect.succeed(/* @__PURE__ */ new Map()),
|
|
265
|
+
has: () => Effect.succeed(/* @__PURE__ */ new Set()),
|
|
266
|
+
startingWith: () => Effect.succeed({
|
|
267
|
+
oids: [],
|
|
268
|
+
more: false
|
|
269
|
+
}),
|
|
270
|
+
objects: () => Effect.succeed({
|
|
271
|
+
objects: /* @__PURE__ */ new Map(),
|
|
272
|
+
left: []
|
|
273
|
+
}),
|
|
274
|
+
allotment: allotmentWithin,
|
|
275
|
+
release: () => {}
|
|
276
|
+
} : {
|
|
277
|
+
object: (oid) => readObject(calls, listed, oid, budget),
|
|
278
|
+
sizes: rowSizes(calls, listed),
|
|
279
|
+
headers: rowHeaders(calls, listed),
|
|
280
|
+
has: (oids) => Effect.map(rowHeaders(calls, listed)(oids), (headers) => new Set(headers.keys())),
|
|
281
|
+
startingWith: (prefix, most) => Effect.map(rowsStartingWith(calls, listed.repo, prefix, most + 1), ({ oids }) => startingOf([oids], most)),
|
|
282
|
+
objects: (oids, bytes) => allottedRows((before) => eachHeldRow(calls, listed, chargedFirst(charges, before)), oids, bytes),
|
|
283
|
+
allotment: allotmentWithin,
|
|
284
|
+
release: charges.release
|
|
285
|
+
}, scope);
|
|
286
|
+
};
|
|
287
|
+
return {
|
|
130
288
|
reader: (listed, input) => Effect.map(callScope, (scope) => openReader(listed, scope, input?.listedOnly)),
|
|
131
289
|
pushedCommits: (_, input) => pushedCommitsPage(void 0, input),
|
|
132
|
-
receive: (listed, input) => cancelsBody(input.pack, receiveRows(calls, listed, input, limits)),
|
|
290
|
+
receive: (listed, input) => cancelsBody(input.pack, receiveRows(calls, listed, input, limits, budget)),
|
|
133
291
|
fetch: (listed, input) => {
|
|
134
|
-
const reads =
|
|
135
|
-
|
|
136
|
-
each: eachHeldRow(calls, listed),
|
|
137
|
-
sizes: rowSizes(calls, listed)
|
|
138
|
-
};
|
|
139
|
-
return handingOn(fetchPack(reads, input, fetchLimits));
|
|
292
|
+
const { reads, ended } = fetchReads(calls, listed, budget);
|
|
293
|
+
return handingOn(Effect.onError(fetchPack(reads, input, fetchLimits, { ended }), () => ended));
|
|
140
294
|
},
|
|
141
|
-
maintain: () =>
|
|
295
|
+
maintain: (listed, input) => looseUpkeep(input.store, listed, input.at),
|
|
142
296
|
share: () => Effect.void,
|
|
143
|
-
copyRows: (listed, input) => copyRowsPage(calls, listed, input)
|
|
144
|
-
};
|
|
145
|
-
return {
|
|
146
|
-
reader: answering(face.reader),
|
|
147
|
-
pushedCommits: answering(face.pushedCommits),
|
|
148
|
-
receive: answering(face.receive),
|
|
149
|
-
fetch: answering(face.fetch),
|
|
150
|
-
maintain: answering(face.maintain),
|
|
151
|
-
share: answering(face.share),
|
|
152
|
-
copyRows: answering(face.copyRows),
|
|
297
|
+
copyRows: (listed, input) => copyRowsPage(calls, listed, input),
|
|
153
298
|
readyShallow: false,
|
|
154
299
|
pushObjectsMost: limits.objects
|
|
155
300
|
};
|
|
156
301
|
}
|
|
157
302
|
};
|
|
158
303
|
};
|
|
159
|
-
export { isLoose, loose, looseLimits, looseObjectsMost };
|
|
304
|
+
export { isLoose, loose, looseFileBytesMost, looseLimits, looseObjectsMost };
|
|
@@ -562,9 +562,10 @@ var MemoryBudget = class {
|
|
|
562
562
|
}
|
|
563
563
|
/**
|
|
564
564
|
* The queue's one wake, run wherever bytes or a waiter leave, granted, refused, interrupted or
|
|
565
|
-
* released: it lets in one waiter at a time by `#next`, until none fits. A grant
|
|
566
|
-
* waiter in
|
|
567
|
-
*
|
|
565
|
+
* released: it lets in one waiter at a time by `#next`, until none fits. A grant hands its
|
|
566
|
+
* waiter what it's granted in this step, and resumes the waiter's fiber a turn later, in its own
|
|
567
|
+
* request (#2719). Bytes given back in this step, by a refusal or a release a grant leads to,
|
|
568
|
+
* wake the queue again inside this one. Two things keep that safe. `#next` reads the queues as they are after every grant, so no
|
|
568
569
|
* waiter is granted twice. A wake inside a wake returns at once, marking another pass due, so a
|
|
569
570
|
* release that lets in a burst of waiters, each giving its bytes back at once, runs flat in this
|
|
570
571
|
* loop instead of a stack frame for each, which would overflow at about a thousand.
|
|
@@ -598,10 +599,21 @@ var MemoryBudget = class {
|
|
|
598
599
|
* Waits in `queue` as the waiter `enter` makes, `ms` at most; `None` past it. A wait interrupted,
|
|
599
600
|
* by its timeout too, leaves the queue and wakes it, since the waiter may have held up others,
|
|
600
601
|
* and runs its `left`.
|
|
602
|
+
*
|
|
603
|
+
* A grant comes in the step of whatever freed the bytes, often another request's. The waiter
|
|
604
|
+
* takes what it's granted in that step, through `enter`'s own bookkeeping, but its fiber resumes
|
|
605
|
+
* through a promise whose `then` it registered as it parked, so on a Worker it runs again in its
|
|
606
|
+
* own request: workerd refuses to resume one request's fiber in another's step, and the step
|
|
607
|
+
* that freed the bytes would fail instead (#2719). An interrupt between the grant and the resume
|
|
608
|
+
* finds the grant taken, as one after the resume does.
|
|
601
609
|
*/
|
|
602
610
|
#queued(queue, ms, enter) {
|
|
603
611
|
return Effect.callback((resume) => {
|
|
604
|
-
|
|
612
|
+
let grant = () => void 0;
|
|
613
|
+
new Promise((settle) => {
|
|
614
|
+
grant = settle;
|
|
615
|
+
}).then((granted) => resume(Effect.succeed(granted)));
|
|
616
|
+
const { waiter, left } = enter(grant);
|
|
605
617
|
queue.push(waiter);
|
|
606
618
|
if (!("room" in waiter) && waiter.grower !== void 0) this.#wakeRooms();
|
|
607
619
|
return Effect.sync(() => {
|
|
@@ -28,9 +28,10 @@ var PastMost = class extends Data.TaggedError("PastMost") {};
|
|
|
28
28
|
const plan = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
29
29
|
const { inputs, limits, bounds = upkeepRuns } = input;
|
|
30
30
|
const total = inputs.reduce((sum, each) => sum + each.objects, 0);
|
|
31
|
+
const maxEntries = total + input.rows.length;
|
|
31
32
|
const packs = [];
|
|
32
33
|
const spent = [];
|
|
33
|
-
let pack = openPack(input.readers());
|
|
34
|
+
let pack = openPack(input.readers(), maxEntries);
|
|
34
35
|
let spend = packStart;
|
|
35
36
|
let opened = input.from ?? {
|
|
36
37
|
kind: "commit",
|
|
@@ -73,7 +74,7 @@ const plan = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
73
74
|
bytes: spend.bytes
|
|
74
75
|
});
|
|
75
76
|
spent.push(spend);
|
|
76
|
-
pack = openPack(input.readers());
|
|
77
|
+
pack = openPack(input.readers(), maxEntries);
|
|
77
78
|
spend = packStart;
|
|
78
79
|
opened = {
|
|
79
80
|
...at,
|
|
@@ -129,8 +129,14 @@ const MergeRow = Schema.Struct({
|
|
|
129
129
|
/** The packs the plan has cut so far, in write order, at most `mergePacksMost`. */
|
|
130
130
|
planned: Schema.Array(PlannedPack).check(Schema.isMaxLength(mergePacksMost)),
|
|
131
131
|
/** The packs written so far, in write order. */
|
|
132
|
-
written: Schema.Array(WrittenPack).check(Schema.isMaxLength(mergePacksMost))
|
|
132
|
+
written: Schema.Array(WrittenPack).check(Schema.isMaxLength(mergePacksMost)),
|
|
133
|
+
/**
|
|
134
|
+
* A prune merge's: the number of the pass's classes object its keep was read from. A later try
|
|
135
|
+
* reads that keep again for its remap only from the object of this number (#2196).
|
|
136
|
+
*/
|
|
137
|
+
classes: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))
|
|
133
138
|
}).check(Schema.makeFilter((row) => {
|
|
139
|
+
if (row.classes !== void 0 && row.owner !== "prune") return "only a prune merge's keep comes from a classes object";
|
|
134
140
|
if ((row.pass === "plan" || row.pass === "write") !== (row.cursor !== void 0)) return "only its plan and write passes have a cursor";
|
|
135
141
|
if (row.pass === "plan" ? row.written.length > 0 : row.planned.length === 0) return "it writes a pack before its plan is done";
|
|
136
142
|
const left = row.planned.length - row.written.length;
|