@ref0/git 0.20.0 → 0.26.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 +1 -1
- package/dist/auth/access-jwt.mjs +3 -3
- package/dist/auth/auth-namespace.d.mts +3 -3
- package/dist/auth/auth-namespace.mjs +3 -2
- package/dist/auth/auth.d.mts +3 -3
- package/dist/auth/auth.mjs +9 -8
- package/dist/auth/authorize.mjs +1 -1
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +1 -1
- package/dist/auth/host-services.mjs +4 -6
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +6 -0
- package/dist/auth/token-cleanup.mjs +2 -2
- package/dist/auth/token-rows.mjs +6 -1
- package/dist/auth/token-text.mjs +1 -1
- package/dist/auth/tokens-base.d.mts +1 -1
- package/dist/auth/tokens.d.mts +1 -1
- package/dist/auth/tokens.mjs +1 -1
- package/dist/client/client.d.mts +15 -7
- package/dist/client/client.mjs +21 -12
- package/dist/client/git-http.mjs +1 -1
- package/dist/client/local.mjs +60 -24
- package/dist/client/negotiate.mjs +3 -3
- package/dist/client/push-upload.mjs +26 -10
- package/dist/client/remote.mjs +4 -3
- package/dist/client/run-remote-helper.d.mts +2 -2
- package/dist/client/run-remote-helper.mjs +6 -6
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +3 -3
- package/dist/contracts/blobs.d.mts +3 -3
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/calls-spent.mjs +5 -33
- package/dist/contracts/client.d.mts +15 -14
- package/dist/contracts/commits.d.mts +4 -4
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +2 -2
- package/dist/contracts/events.d.mts +1 -1
- package/dist/contracts/events.mjs +1 -1
- package/dist/contracts/files.d.mts +4 -4
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +4 -4
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +9 -5
- package/dist/contracts/grants.d.mts +1 -1
- package/dist/contracts/merges.d.mts +1 -1
- package/dist/contracts/object-values.d.mts +1 -0
- package/dist/contracts/object-values.mjs +16 -1
- package/dist/contracts/objects.d.mts +30 -18
- package/dist/contracts/opaque.mjs +1 -1
- package/dist/contracts/operations.mjs +1 -1
- package/dist/contracts/queue.d.mts +208 -44
- package/dist/contracts/queue.mjs +5 -5
- package/dist/contracts/refs.d.mts +5 -5
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +3 -6
- package/dist/contracts/repos.d.mts +3 -3
- package/dist/contracts/repos.mjs +1 -1
- package/dist/contracts/result.d.mts +10 -7
- package/dist/contracts/result.mjs +8 -3
- package/dist/contracts/rules.d.mts +13 -12
- package/dist/contracts/server.d.mts +8 -10
- package/dist/contracts/services.d.mts +6 -9
- package/dist/contracts/services.mjs +1 -2
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +2 -2
- package/dist/contracts/sync.d.mts +63 -6
- package/dist/contracts/sync.mjs +3 -2
- package/dist/contracts/tags.d.mts +3 -3
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +2 -2
- package/dist/contracts/tokens.mjs +1 -1
- package/dist/contracts/topics.d.mts +9 -9
- package/dist/contracts/trees.d.mts +4 -4
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +4 -4
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +1 -1
- package/dist/core/ancestry.mjs +30 -34
- package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
- package/dist/core/call-services.mjs +1 -1
- package/dist/core/events/deliver.d.mts +2 -2
- package/dist/core/events/deliver.mjs +3 -3
- package/dist/core/events/retired.mjs +1 -1
- package/dist/core/forks.mjs +5 -5
- package/dist/core/hooks/groups.mjs +2 -2
- package/dist/core/imports.mjs +101 -21
- package/dist/core/index-job.mjs +14 -9
- package/dist/core/index-lost.d.mts +1 -1
- package/dist/core/loose-tally.mjs +38 -15
- package/dist/core/merge-parts.d.mts +17 -4
- package/dist/core/merge-parts.mjs +7 -2
- package/dist/core/mirror-rows.mjs +31 -1
- package/dist/core/objects/blobs.mjs +8 -10
- package/dist/core/objects/files.mjs +20 -17
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/peel.mjs +1 -7
- package/dist/core/objects/reading.mjs +19 -18
- package/dist/core/objects/tree-edits.mjs +1 -1
- package/dist/core/objects/trees.mjs +257 -58
- package/dist/core/objects/writing.mjs +3 -9
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +8 -1
- package/dist/core/parts.mjs +8 -4
- package/dist/core/purge.mjs +31 -18
- package/dist/core/push.d.mts +2 -2
- package/dist/core/push.mjs +145 -98
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +9 -2
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +74 -31
- package/dist/core/refs.mjs +3 -3
- package/dist/core/repack.mjs +25 -30
- package/dist/core/repo-info.mjs +1 -1
- package/dist/core/repos.mjs +1 -1
- package/dist/core/rules/changes.mjs +18 -40
- package/dist/core/rules/check.mjs +6 -5
- package/dist/core/rules/commit-changes.mjs +114 -58
- package/dist/core/rules/context.d.mts +3 -3
- package/dist/core/rules/context.mjs +18 -14
- package/dist/core/rules/fetch.mjs +1 -1
- package/dist/core/rules/protect.mjs +30 -17
- package/dist/core/saved-caller-views.d.mts +1 -1
- package/dist/core/saved-caller-views.mjs +3 -3
- package/dist/core/saved-callers.d.mts +1 -1
- package/dist/core/saved-callers.mjs +1 -1
- package/dist/core/seam.d.mts +1 -2
- package/dist/core/view.d.mts +6 -3
- package/dist/core/view.mjs +11 -10
- package/dist/core/work.mjs +2 -2
- package/dist/engine/allotted-xdiff.mjs +3 -16
- package/dist/engine/combined.d.mts +3 -0
- package/dist/engine/combined.mjs +200 -185
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/merge.mjs +7 -9
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +22 -14
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +1 -1
- 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 +2 -2
- package/dist/event-streams/stream.mjs +3 -3
- package/dist/extend.d.mts +2 -6
- package/dist/extend.mjs +1 -5
- package/dist/http/core-parts.mjs +83 -26
- package/dist/http/handler.mjs +54 -9
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +138 -24
- package/dist/http/push-uploads.mjs +2 -2
- package/dist/http/receive-pack.mjs +14 -53
- package/dist/http/request-snapshot.mjs +258 -0
- package/dist/http/upload-pack.mjs +23 -18
- package/dist/index.d.mts +29 -21
- package/dist/index.mjs +11 -2
- package/dist/lfs/base.d.mts +1 -1
- package/dist/lfs/copy.d.mts +49 -1
- package/dist/lfs/copy.mjs +135 -22
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +4 -5
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -1
- package/dist/lfs/objects.mjs +3 -3
- package/dist/lfs/pointers.mjs +1 -1
- package/dist/lfs/rows.d.mts +1 -1
- package/dist/lfs/rows.mjs +11 -4
- package/dist/lfs/upkeep.mjs +40 -9
- package/dist/lfs/uploaded.mjs +1 -1
- package/dist/lfs/wire.mjs +1 -1
- package/dist/merges/merges.mjs +17 -2
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +1 -1
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +1 -1
- package/dist/protocol/diff/read.d.mts +2 -1
- package/dist/protocol/diff/read.mjs +102 -8
- package/dist/protocol/packs/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +1 -1
- package/dist/protocol/packs/idx.mjs +1 -1
- package/dist/protocol/packs/parts.mjs +1 -1
- package/dist/protocol/packs/reader.d.mts +1 -1
- package/dist/protocol/packs/reader.mjs +1 -1
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +3 -3
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +3 -2
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +9 -1
- package/dist/protocol/wire/lines.mjs +28 -1
- package/dist/protocol/wire/push-uploads.mjs +10 -7
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +1 -1
- package/dist/protocol/wire/v2.mjs +1 -1
- package/dist/queue/advance.mjs +31 -24
- package/dist/queue/base.d.mts +5 -3
- package/dist/queue/calls.mjs +5 -5
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -1
- package/dist/queue/layer.d.mts +0 -1
- package/dist/queue/layer.mjs +9 -5
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +1 -1
- package/dist/queue/state.mjs +1 -1
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/client.d.mts +1 -1
- package/dist/rest/client.mjs +6 -6
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/handler.mjs +2 -2
- package/dist/rest/handlers.mjs +16 -6
- package/dist/rest/layer.mjs +1 -1
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/refs.mjs +1 -1
- package/dist/server/edge.mjs +27 -3
- package/dist/server/git-layer.d.mts +1 -2
- package/dist/server/git-layer.mjs +4 -5
- package/dist/server/lifecycle.mjs +1 -1
- package/dist/server/registry.mjs +2 -8
- package/dist/server/server.mjs +62 -43
- package/dist/signin/context.d.mts +1 -1
- package/dist/signin/context.mjs +1 -1
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -2
- package/dist/signin/grants.mjs +1 -1
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/allotted.mjs +4 -9
- package/dist/storage/batch-upkeep.mjs +31 -12
- package/dist/storage/batches.d.mts +2 -3
- package/dist/storage/batches.mjs +52 -49
- package/dist/storage/budget.mjs +23 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +41 -43
- package/dist/storage/charged-cache.mjs +180 -0
- package/dist/storage/chunks.d.mts +3 -3
- package/dist/storage/chunks.mjs +121 -8
- package/dist/storage/counted-bucket.mjs +32 -10
- package/dist/storage/fetch-row-cache.d.mts +6 -0
- package/dist/storage/fetch-row-cache.mjs +211 -0
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +54 -242
- package/dist/storage/held-types.d.mts +0 -1
- package/dist/storage/held-types.mjs +13 -4
- package/dist/storage/host-bucket.mjs +9 -4
- package/dist/storage/index-bitmaps.mjs +340 -65
- package/dist/storage/index-build.d.mts +2 -3
- package/dist/storage/index-build.mjs +274 -56
- package/dist/storage/index-fetch.d.mts +3 -1
- package/dist/storage/index-fetch.mjs +60 -21
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +55 -25
- package/dist/storage/index-reach.mjs +15 -22
- package/dist/storage/index-whole.d.mts +7 -0
- package/dist/storage/index-whole.mjs +145 -37
- package/dist/storage/largest-files.mjs +1 -7
- package/dist/storage/layout.mjs +17 -1
- package/dist/storage/lfs-pointers.mjs +1 -6
- package/dist/storage/link-join.mjs +55 -16
- package/dist/storage/list-source.d.mts +7 -0
- package/dist/storage/list-source.mjs +288 -0
- package/dist/storage/loose.d.mts +8 -8
- package/dist/storage/loose.mjs +157 -91
- package/dist/storage/memory-budget.mjs +226 -22
- package/dist/storage/merge-cut.mjs +9 -6
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-row.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -3
- package/dist/storage/merge.mjs +2 -2
- package/dist/storage/object-rows.d.mts +3 -3
- package/dist/storage/object-rows.mjs +179 -38
- package/dist/storage/pack-order.mjs +97 -44
- package/dist/storage/pack-ranges.mjs +44 -16
- package/dist/storage/pack-reads.d.mts +5 -3
- package/dist/storage/pack-reads.mjs +236 -72
- package/dist/storage/pack-receive.d.mts +1 -2
- package/dist/storage/pack-receive.mjs +24 -18
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +477 -116
- package/dist/storage/placed-reads.mjs +33 -16
- package/dist/storage/prune-seen.mjs +1 -1
- package/dist/storage/prune-walk.mjs +1 -1
- package/dist/storage/prune.mjs +4 -31
- package/dist/storage/push-allotment.mjs +26 -14
- package/dist/storage/push-uploads.mjs +195 -57
- package/dist/storage/pushed-commits.mjs +20 -1
- package/dist/storage/quarantine.d.mts +2 -3
- package/dist/storage/range-cache.mjs +175 -40
- package/dist/storage/raw-ids.mjs +39 -10
- package/dist/storage/ready.d.mts +2 -3
- package/dist/storage/ready.mjs +114 -38
- package/dist/storage/receive-bounds.mjs +31 -9
- package/dist/storage/receive-cache.d.mts +7 -0
- package/dist/storage/receive-cache.mjs +147 -0
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +6 -8
- package/dist/storage/receive-steps.d.mts +20 -0
- package/dist/storage/receive-steps.mjs +298 -13
- package/dist/storage/repack-backlog.mjs +1 -6
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.mjs +1 -1
- package/dist/storage/repack.d.mts +2 -3
- package/dist/storage/repack.mjs +54 -9
- package/dist/storage/request-cache.mjs +57 -0
- package/dist/storage/roots.mjs +1 -24
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +1 -1
- package/dist/storage/send-list.mjs +62 -25
- package/dist/storage/stream-whole.mjs +84 -63
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +878 -450
- package/dist/storage/visible.mjs +110 -32
- package/dist/storage/walk.mjs +1 -0
- package/dist/storage/wants.mjs +22 -58
- package/dist/store/call-count.d.mts +2 -2
- package/dist/store/call-count.mjs +24 -11
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +19 -7
- package/dist/store/crossing.mjs +1 -7
- package/dist/store/cursor-seal.d.mts +1 -1
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/door.mjs +9 -4
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +107 -19
- package/dist/store/git-store.mjs +7 -2
- package/dist/store/job-try.mjs +90 -9
- package/dist/store/list-job.mjs +10 -34
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +2 -2
- package/dist/store/queue-jobs.mjs +6 -12
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +2 -2
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +2 -2
- package/dist/store/repo-record.d.mts +2 -2
- package/dist/store/repo-record.mjs +3 -3
- package/dist/store/request-snapshot.mjs +5 -0
- package/dist/store/reservations.mjs +2 -2
- package/dist/store/topic-jobs.mjs +5 -11
- package/dist/sync/bound.d.mts +3 -3
- package/dist/sync/bound.mjs +10 -7
- package/dist/sync/github.mjs +65 -67
- package/dist/sync/http.mjs +1 -1
- package/dist/sync/import.mjs +201 -66
- package/dist/sync/layer.d.mts +1 -1
- package/dist/sync/layer.mjs +6 -6
- package/dist/sync/lfs-batch.mjs +1 -1
- package/dist/sync/lfs-copy.mjs +175 -15
- package/dist/sync/mirror.mjs +5 -10
- package/dist/sync/said.mjs +1 -1
- package/dist/sync/step.mjs +268 -86
- package/dist/sync/tries.mjs +25 -6
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +3 -3
- package/dist/topics/calls.mjs +1 -1
- package/dist/topics/layer.d.mts +15 -14
- package/dist/topics/members.mjs +1 -1
- package/dist/topics/topic.mjs +1 -1
- package/package.json +3 -13
- package/dist/auth/helpers.mjs +0 -17
- package/dist/auth.d.mts +0 -5
- package/dist/auth.mjs +0 -5
- package/dist/core/rules/commit-changes.d.mts +0 -12
- package/dist/effect.d.mts +0 -9
- package/dist/effect.mjs +0 -7
- package/dist/server/joined.d.mts +0 -70
- package/dist/server/joined.mjs +0 -41
package/dist/storage/loose.mjs
CHANGED
|
@@ -1,51 +1,59 @@
|
|
|
1
|
-
import { streamThen } from "../protocol/bytes/streams.mjs";
|
|
2
1
|
import { handingOn } from "../protocol/packs/writer.mjs";
|
|
3
2
|
import { newChangeId } from "../store/scopes.mjs";
|
|
4
3
|
import { callScope } from "../store/call-count.mjs";
|
|
5
4
|
import { cancelsBody, objectReader } from "./calls.mjs";
|
|
6
5
|
import { fetchPack } from "./fetch.mjs";
|
|
7
6
|
import { pushedCommitsPage } from "./pushed-commits.mjs";
|
|
8
|
-
import { copyRowsPage, eachHeldRow, gitObjectOf, heldRows, readsOwnChunks, rowHeaders, rowSizes, rowsStartingWith, startingOf } from "./object-rows.mjs";
|
|
7
|
+
import { copyRowsPage, eachHeldRow, gitObjectOf, heldRows, readStagedRows, readsOwnChunks, rowAt, rowHeaders, rowSizes, rowsStartingWith, startingOf } from "./object-rows.mjs";
|
|
9
8
|
import { allotmentWithin } from "../contracts/object-values.mjs";
|
|
10
9
|
import { allottedRows } from "./allotted.mjs";
|
|
11
10
|
import { looseUpkeep } from "./batch-upkeep.mjs";
|
|
12
|
-
import { abandonBatch, openBatch,
|
|
11
|
+
import { abandonBatch, batchStager, fastPath, openBatch, stageBytes, streamedChange } from "./batches.mjs";
|
|
13
12
|
import { allottableOf, defaultMemory, readReserveBytes } from "./budget.mjs";
|
|
14
|
-
import { ChunkReader, chunkRawBytes,
|
|
15
|
-
import { MemoryBudget } from "./memory-budget.mjs";
|
|
16
|
-
import {
|
|
17
|
-
import { largestOf } from "./largest-files.mjs";
|
|
18
|
-
import { wholeRoots } from "./roots.mjs";
|
|
19
|
-
import { commitBytes, unpackObjects } from "./unpack.mjs";
|
|
13
|
+
import { ChunkReader, chunkPageBytes, chunkRawBytes, chunkStream, chunkedRow, fitsRow, stageChunk } from "./chunks.mjs";
|
|
14
|
+
import { MemoryBudget, withMemoryBudget } from "./memory-budget.mjs";
|
|
15
|
+
import { baseLruBytes, pendingHeldMost, roundReadBytes, unpackObjects } from "./unpack.mjs";
|
|
20
16
|
import { gitError } from "../contracts/result.mjs";
|
|
21
|
-
import
|
|
17
|
+
import { limits } from "@ref0/infra";
|
|
22
18
|
import * as Effect from "effect/Effect";
|
|
23
19
|
import * as Exit from "effect/Exit";
|
|
24
|
-
import * as Scope from "effect/Scope";
|
|
20
|
+
import * as Scope$1 from "effect/Scope";
|
|
21
|
+
import * as Clock from "effect/Clock";
|
|
25
22
|
// src/storage/loose.ts
|
|
26
|
-
/** The most objects one push may carry into `loose()` storage
|
|
27
|
-
const looseObjectsMost =
|
|
23
|
+
/** The most objects one push may carry into `loose()` storage. */
|
|
24
|
+
const looseObjectsMost = 5e4;
|
|
25
|
+
/** The most pack wire bytes one push may carry into `loose()` storage, before inflation. */
|
|
26
|
+
const looseBytesMost = 67108864;
|
|
28
27
|
/** The bytes one object takes in `loose()` storage at most, as Cloudflare Artifacts takes a file. */
|
|
29
28
|
const looseFileBytesMost = 33554432;
|
|
30
29
|
/**
|
|
31
|
-
* What one push may carry into `loose()` storage: its `objects`,
|
|
32
|
-
*
|
|
30
|
+
* What one push may carry into `loose()` storage: its `objects`, its pack's `bytes` on the wire
|
|
31
|
+
* before inflation, and the bytes of each object, `fileBytes`, one past a row kept as chunks.
|
|
33
32
|
*/
|
|
34
33
|
const looseLimits = {
|
|
35
34
|
objects: looseObjectsMost,
|
|
36
|
-
bytes:
|
|
35
|
+
bytes: looseBytesMost,
|
|
37
36
|
fileBytes: looseFileBytesMost
|
|
38
37
|
};
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
38
|
+
/** A receive's memory caps and floor, scaled by `bytes` and `objects` so fixed buffers fit admission. */
|
|
39
|
+
const receiveCapsOf = (bytes, objects) => {
|
|
40
|
+
const full = baseLruBytes + pendingHeldMost + roundReadBytes + stageBytes;
|
|
41
|
+
const oneRow = limits.valueBytes;
|
|
42
|
+
const most = Math.min(bytes, Math.max(0, objects) * oneRow);
|
|
43
|
+
const scale = Math.min(3 * most, full) / full;
|
|
44
|
+
const lruBytes = Math.floor(baseLruBytes * scale);
|
|
45
|
+
const pendingHeld = Math.floor(pendingHeldMost * scale);
|
|
46
|
+
const roundBytes = Math.max(Math.floor(roundReadBytes * scale), oneRow);
|
|
47
|
+
const stagerBytes = Math.min(stageBytes, Math.max(Math.floor(stageBytes * scale), most, oneRow));
|
|
48
|
+
return {
|
|
49
|
+
lruBytes,
|
|
50
|
+
pendingHeld,
|
|
51
|
+
roundBytes,
|
|
52
|
+
stagerBytes,
|
|
53
|
+
inlineBytes: 3 * bytes < full ? stagerBytes >> 1 : fastPath.bytes,
|
|
54
|
+
floor: lruBytes + pendingHeld + roundBytes + stagerBytes + 1048576 + 3 * chunkRawBytes
|
|
55
|
+
};
|
|
56
|
+
};
|
|
49
57
|
/** `limits` checked, each a whole number from 1 to `looseLimits`' own, or a `RangeError`. */
|
|
50
58
|
const checkedLoose = (limits) => {
|
|
51
59
|
const each = (kind) => {
|
|
@@ -81,29 +89,41 @@ const isLoose = (quarantine) => received.has(quarantine);
|
|
|
81
89
|
* once its first chunk opens one. A receive that fails after it opened one abandons it.
|
|
82
90
|
*/
|
|
83
91
|
const receiveRows = (store, listed, receive, limits, budget) => Effect.scoped(Effect.gen(function* () {
|
|
84
|
-
const
|
|
92
|
+
const caps = receiveCapsOf(limits.bytes, receive.objects);
|
|
93
|
+
const allotment = yield* budget.admit(caps.floor);
|
|
85
94
|
const { repo } = listed;
|
|
86
95
|
let opened;
|
|
96
|
+
let stager;
|
|
97
|
+
const ensureOpened = Effect.fnUntraced(function* () {
|
|
98
|
+
opened ??= yield* openBatch({
|
|
99
|
+
store,
|
|
100
|
+
repo,
|
|
101
|
+
at: yield* Clock.currentTimeMillis
|
|
102
|
+
});
|
|
103
|
+
return opened;
|
|
104
|
+
});
|
|
105
|
+
const staging = {
|
|
106
|
+
stager: Effect.fnUntraced(function* () {
|
|
107
|
+
stager ??= batchStager(store, repo, yield* ensureOpened(), caps.stagerBytes);
|
|
108
|
+
return stager;
|
|
109
|
+
}),
|
|
110
|
+
readStaged: readStagedRows(store, repo)
|
|
111
|
+
};
|
|
87
112
|
const large = {
|
|
88
113
|
fileBytes: limits.fileBytes,
|
|
89
|
-
totalBytes: largeBytesMost,
|
|
90
114
|
stage: Effect.fnUntraced(function* (part, index, bytes) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
repo,
|
|
94
|
-
at: yield* Clock.currentTimeMillis
|
|
95
|
-
});
|
|
96
|
-
yield* stageChunk(store, repo, opened, part, index, bytes);
|
|
115
|
+
const batch = yield* ensureOpened();
|
|
116
|
+
yield* stageChunk(store, repo, batch, part, index, bytes);
|
|
97
117
|
}),
|
|
98
118
|
hold: (bytes) => allotment.grow(bytes),
|
|
99
119
|
staged: (object) => Effect.map(new ChunkReader(store, repo, object.oid, rowOf(object).value, () => Effect.succeed(void 0)).whole(), ({ bytes }) => bytes),
|
|
100
120
|
row: (object) => rowOf(object)
|
|
101
121
|
};
|
|
102
122
|
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)));
|
|
123
|
+
return yield* receivedRows(store, listed, receive, limits, caps, large, staging, () => opened).pipe(Effect.onError(() => opened === void 0 ? Effect.void : abandonBatch(store, repo, opened.batch)));
|
|
104
124
|
}));
|
|
105
|
-
/** `receiveRows`' receive, its batch `opened()` once
|
|
106
|
-
const receivedRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed, receive, limits, large, opened) {
|
|
125
|
+
/** `receiveRows`' receive, its batch `opened()` once staging or a chunk opens one. */
|
|
126
|
+
const receivedRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed, receive, limits, caps, large, staging, opened) {
|
|
107
127
|
const heldWhole = heldRows(store, listed);
|
|
108
128
|
const unpacked = yield* unpackObjects({
|
|
109
129
|
receive,
|
|
@@ -114,41 +134,46 @@ const receivedRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed,
|
|
|
114
134
|
yield* large.hold(chunked.reduce((sum, { size }) => sum + size, 0));
|
|
115
135
|
return yield* heldWhole(oids);
|
|
116
136
|
}),
|
|
137
|
+
eachHeld: (oids, take) => eachHeldRow(store, listed, (_, size) => Effect.as(large.hold(size), true))(oids, take),
|
|
117
138
|
headers: rowHeaders(store, listed),
|
|
118
139
|
offsetDeltas: "resolve",
|
|
119
|
-
large
|
|
140
|
+
large,
|
|
141
|
+
staging,
|
|
142
|
+
lruBytes: caps.lruBytes,
|
|
143
|
+
pendingHeld: caps.pendingHeld,
|
|
144
|
+
roundBytes: caps.roundBytes,
|
|
145
|
+
stageBytes: caps.inlineBytes
|
|
120
146
|
});
|
|
121
|
-
const staged =
|
|
147
|
+
const staged = streamedChange(opened(), unpacked.inlineRows, unpacked.own, unpacked.moved, yield* Clock.currentTimeMillis);
|
|
122
148
|
readsOwnChunks(staged.change, (oid, chunked) => new ChunkReader(store, listed.repo, oid, chunked, () => Effect.succeed(void 0)));
|
|
123
149
|
const quarantine = {
|
|
124
150
|
id: newChangeId(),
|
|
125
151
|
change: staged.change,
|
|
126
152
|
bytes: unpacked.bytes,
|
|
127
153
|
objects: unpacked.count,
|
|
128
|
-
lfsPointers:
|
|
129
|
-
...
|
|
154
|
+
lfsPointers: unpacked.lfsPointers,
|
|
155
|
+
...unpacked.largest
|
|
130
156
|
};
|
|
131
157
|
if (unpacked.cut.length > 0) quarantine.cut = unpacked.cut;
|
|
132
158
|
if (staged.quarantine !== void 0) quarantine.quarantine = staged.quarantine;
|
|
133
159
|
received.add(quarantine);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (whole.outside.every((oid) => held.has(oid))) quarantine.linked = {
|
|
160
|
+
if (unpacked.roots === void 0) return quarantine;
|
|
161
|
+
quarantine.roots = unpacked.roots;
|
|
162
|
+
if (unpacked.outside === void 0 || unpacked.outside.length > 64) return quarantine;
|
|
163
|
+
const held = yield* rowHeaders(store, listed)(unpacked.outside);
|
|
164
|
+
if (unpacked.outside.every((oid) => held.has(oid))) quarantine.linked = {
|
|
140
165
|
packs: [],
|
|
141
|
-
rows:
|
|
166
|
+
rows: unpacked.outside
|
|
142
167
|
};
|
|
143
168
|
return quarantine;
|
|
144
169
|
});
|
|
145
170
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
171
|
+
* Allots `bytes` from `budget` before a chunked object's chunks are read, handing it to `own` in
|
|
172
|
+
* the step the allot ends in: held until its allotment's `release`, which no scope makes for it.
|
|
173
|
+
* The allot's scope is closed by its failure, so an interrupt or a refusal leaves nothing allotted
|
|
174
|
+
* that no one owns.
|
|
150
175
|
*/
|
|
151
|
-
const chunkedCharge = (budget,
|
|
176
|
+
const chunkedCharge = (budget, bytes, own) => Effect.uninterruptibleMask((restore) => Effect.flatMap(Scope$1.make(), (scope) => restore(Scope$1.provide(scope)(budget.allot(bytes))).pipe(Effect.onError(() => Scope$1.close(scope, Exit.void)), Effect.map((allotment) => {
|
|
152
177
|
own(allotment);
|
|
153
178
|
return allotment;
|
|
154
179
|
}))));
|
|
@@ -158,7 +183,7 @@ const chunkedCharge = (budget, size, own) => Effect.uninterruptibleMask((restore
|
|
|
158
183
|
*/
|
|
159
184
|
const readerCharges = (budget) => {
|
|
160
185
|
const held = /* @__PURE__ */ new Set();
|
|
161
|
-
const charge = (size) => chunkedCharge(budget, size, (allotment) => void held.add(allotment));
|
|
186
|
+
const charge = (size) => chunkedCharge(budget, size + chunkPageBytes, (allotment) => void held.add(allotment));
|
|
162
187
|
const give = (allotment) => {
|
|
163
188
|
held.delete(allotment);
|
|
164
189
|
allotment.release();
|
|
@@ -174,47 +199,58 @@ const readerCharges = (budget) => {
|
|
|
174
199
|
};
|
|
175
200
|
};
|
|
176
201
|
/**
|
|
177
|
-
* `oid`'s object, or `undefined`. One kept as chunks
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
202
|
+
* `oid`'s object, or `undefined`. One kept as chunks streams a page of `chunkReadMost` chunks at
|
|
203
|
+
* a time once `budget` allots `chunkPageBytes`, releasing that charge once the stream ends, fails,
|
|
204
|
+
* cancels, or `signal` aborts: not at the reader's release, which comes before a caller streams
|
|
205
|
+
* the body on (#2522).
|
|
181
206
|
*/
|
|
182
|
-
const readObject = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed, oid, budget) {
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
207
|
+
const readObject = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed, oid, budget, signal) {
|
|
208
|
+
const found = yield* rowAt(store, listed, oid);
|
|
209
|
+
if (found === void 0) return void 0;
|
|
210
|
+
if (found.kind === "whole") return gitObjectOf(found.object);
|
|
211
|
+
const count = yield* callScope;
|
|
212
|
+
let charged;
|
|
213
|
+
return yield* chunkedCharge(budget, chunkPageBytes, (allotment) => void (charged = allotment)).pipe(Effect.map((allotment) => {
|
|
214
|
+
const { type, size } = found.reader.chunked;
|
|
215
|
+
return {
|
|
216
|
+
oid,
|
|
217
|
+
type,
|
|
218
|
+
size,
|
|
219
|
+
bytes: chunkStream(found.reader, () => allotment.release(), signal, count)
|
|
220
|
+
};
|
|
221
|
+
}), Effect.onError(() => Effect.sync(() => charged?.release())));
|
|
195
222
|
});
|
|
196
223
|
/**
|
|
197
224
|
* `before`, with each chunked object's bytes charged to `charges` first: given back if `before`
|
|
198
225
|
* leaves it, and held, if it keeps it, until the reader's release.
|
|
199
226
|
*/
|
|
200
227
|
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)))));
|
|
228
|
+
const closeScope = (scope) => scope === void 0 ? Effect.void : Scope$1.close(scope, Exit.void);
|
|
201
229
|
/**
|
|
202
|
-
* A fetch's reads of `listed`'s rows.
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
230
|
+
* A fetch's reads of `listed`'s rows. Objects past one row stream through `ranged` a page of
|
|
231
|
+
* `chunkReadMost` chunks at a time under a constant `chunkPageBytes` allotment, released when each
|
|
232
|
+
* object ends, on error, or via `ended`; `each` (for walk commits/trees/tags) holds one chunked
|
|
233
|
+
* object at a time until its callback ends (#2522).
|
|
206
234
|
*/
|
|
207
235
|
const fetchReads = (calls, listed, budget) => {
|
|
208
236
|
let window;
|
|
209
|
-
|
|
237
|
+
let active;
|
|
238
|
+
const closeWindow = Effect.suspend(() => {
|
|
210
239
|
const open = window;
|
|
211
240
|
window = void 0;
|
|
212
|
-
return
|
|
241
|
+
return closeScope(open);
|
|
213
242
|
});
|
|
214
|
-
const
|
|
243
|
+
const closeActive = Effect.sync(() => {
|
|
244
|
+
const current = active;
|
|
245
|
+
active = void 0;
|
|
246
|
+
current?.reader.dropPage();
|
|
247
|
+
current?.allotment.release();
|
|
248
|
+
});
|
|
249
|
+
const ended = Effect.andThen(closeActive, closeWindow);
|
|
250
|
+
const allotted = (scope) => (_, size) => Effect.as(Scope$1.provide(scope)(budget.allot(size + chunkPageBytes)), true);
|
|
215
251
|
const held = Effect.fnUntraced(function* (oids) {
|
|
216
|
-
yield*
|
|
217
|
-
const scope = yield* Scope.make();
|
|
252
|
+
yield* closeWindow;
|
|
253
|
+
const scope = yield* Scope$1.make();
|
|
218
254
|
window = scope;
|
|
219
255
|
const objects = /* @__PURE__ */ new Map();
|
|
220
256
|
yield* eachHeldRow(calls, listed, allotted(scope))(oids, (object) => Effect.sync(() => void objects.set(object.oid, object)));
|
|
@@ -225,30 +261,59 @@ const fetchReads = (calls, listed, budget) => {
|
|
|
225
261
|
const closed = Effect.suspend(() => {
|
|
226
262
|
const scope = open;
|
|
227
263
|
open = void 0;
|
|
228
|
-
return
|
|
264
|
+
return closeScope(scope);
|
|
229
265
|
});
|
|
230
|
-
const before = (oid, size) => Effect.flatMap(closed, () => Effect.flatMap(Scope.make(), (scope) => {
|
|
266
|
+
const before = (oid, size) => Effect.flatMap(closed, () => Effect.flatMap(Scope$1.make(), (scope) => {
|
|
231
267
|
open = scope;
|
|
232
268
|
return allotted(scope)(oid, size);
|
|
233
269
|
}));
|
|
234
270
|
return Effect.ensuring(eachHeldRow(calls, listed, before)(oids, (object) => Effect.ensuring(take(object), closed)), closed);
|
|
235
271
|
};
|
|
272
|
+
const ranged = {
|
|
273
|
+
handles: ({ kind, size }) => !fitsRow(kind, size),
|
|
274
|
+
read: Effect.fnUntraced(function* (oid, at) {
|
|
275
|
+
let current = active;
|
|
276
|
+
if (current === void 0 || current.oid !== oid) {
|
|
277
|
+
yield* closeActive;
|
|
278
|
+
const found = yield* rowAt(calls, listed, oid);
|
|
279
|
+
if (found === void 0) return void 0;
|
|
280
|
+
if (found.kind === "whole") return found.object.bytes.slice(at, at + chunkRawBytes);
|
|
281
|
+
const allotment = yield* chunkedCharge(budget, chunkPageBytes, (charged) => void (active = {
|
|
282
|
+
oid,
|
|
283
|
+
reader: found.reader,
|
|
284
|
+
allotment: charged
|
|
285
|
+
}));
|
|
286
|
+
current = {
|
|
287
|
+
oid,
|
|
288
|
+
reader: found.reader,
|
|
289
|
+
allotment
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
const index = Math.floor(at / chunkRawBytes);
|
|
293
|
+
const inside = at - index * chunkRawBytes;
|
|
294
|
+
const chunk = yield* current.reader.chunkAt(index).pipe(Effect.onError(() => closeActive));
|
|
295
|
+
const out = inside === 0 ? chunk : chunk.slice(inside);
|
|
296
|
+
if (at + out.byteLength >= current.reader.chunked.size) yield* closeActive;
|
|
297
|
+
return out;
|
|
298
|
+
})
|
|
299
|
+
};
|
|
236
300
|
return {
|
|
237
301
|
reads: {
|
|
238
302
|
held,
|
|
239
303
|
each,
|
|
240
|
-
sizes: rowSizes(calls, listed)
|
|
304
|
+
sizes: rowSizes(calls, listed),
|
|
305
|
+
ranged
|
|
241
306
|
},
|
|
242
307
|
ended
|
|
243
308
|
};
|
|
244
309
|
};
|
|
245
310
|
/**
|
|
246
311
|
* `loose()`: each object a row of the repo's scope, with no bucket. A push of more than
|
|
247
|
-
* `options.objects` objects,
|
|
248
|
-
* `options.bytes`,
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
312
|
+
* `options.objects` objects, 50,000 by default, is refused whole, and so is one whose pack passes
|
|
313
|
+
* `options.bytes`, 64 MiB on the wire by default, before inflation. An object past one row is kept
|
|
314
|
+
* as chunk rows, to `options.fileBytes`, 32 MiB by default, and one past that is refused as
|
|
315
|
+
* `object-too-large`. A whole inline push names its roots and the rows it links to, so it can keep
|
|
316
|
+
* a repo's whole-clone mark. The client's default.
|
|
252
317
|
*/
|
|
253
318
|
const loose = (options = {}) => {
|
|
254
319
|
const limits = checkedLoose(options);
|
|
@@ -274,7 +339,7 @@ const loose = (options = {}) => {
|
|
|
274
339
|
allotment: allotmentWithin,
|
|
275
340
|
release: () => {}
|
|
276
341
|
} : {
|
|
277
|
-
object: (oid) => readObject(calls, listed, oid, budget),
|
|
342
|
+
object: (oid, signal) => readObject(calls, listed, oid, budget, signal),
|
|
278
343
|
sizes: rowSizes(calls, listed),
|
|
279
344
|
headers: rowHeaders(calls, listed),
|
|
280
345
|
has: (oids) => Effect.map(rowHeaders(calls, listed)(oids), (headers) => new Set(headers.keys())),
|
|
@@ -284,7 +349,7 @@ const loose = (options = {}) => {
|
|
|
284
349
|
release: charges.release
|
|
285
350
|
}, scope);
|
|
286
351
|
};
|
|
287
|
-
|
|
352
|
+
const objects = {
|
|
288
353
|
reader: (listed, input) => Effect.map(callScope, (scope) => openReader(listed, scope, input?.listedOnly)),
|
|
289
354
|
pushedCommits: (_, input) => pushedCommitsPage(void 0, input),
|
|
290
355
|
receive: (listed, input) => cancelsBody(input.pack, receiveRows(calls, listed, input, limits, budget)),
|
|
@@ -298,7 +363,8 @@ const loose = (options = {}) => {
|
|
|
298
363
|
readyShallow: false,
|
|
299
364
|
pushObjectsMost: limits.objects
|
|
300
365
|
};
|
|
366
|
+
return withMemoryBudget(objects, budget);
|
|
301
367
|
}
|
|
302
368
|
};
|
|
303
369
|
};
|
|
304
|
-
export { isLoose, loose, looseFileBytesMost, looseLimits, looseObjectsMost };
|
|
370
|
+
export { isLoose, loose, looseBytesMost, looseFileBytesMost, looseLimits, looseObjectsMost };
|