@ref0/git 0.20.0 → 0.25.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 +20 -17
- 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 +2 -2
- 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 +125 -94
- 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 +3 -15
- 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/host-bucket.mjs +9 -4
- package/dist/storage/index-bitmaps.mjs +77 -49
- package/dist/storage/index-build.d.mts +2 -3
- package/dist/storage/index-build.mjs +248 -48
- 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 +21 -17
- 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/packs.mjs
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { fail
|
|
1
|
+
import { fail } from "../contracts/result.mjs";
|
|
2
2
|
import { PackTransportError } from "../protocol/packs/reader.mjs";
|
|
3
|
+
import { stepEffect } from "../protocol/packs/step.mjs";
|
|
3
4
|
import { decodeRecord } from "../store/catalogue.mjs";
|
|
4
5
|
import { decodePacks } from "../store/git-store.mjs";
|
|
5
6
|
import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
|
|
6
|
-
import { resultCall } from "../store/errors.mjs";
|
|
7
7
|
import { decodeStats, repoStats } from "../store/repo-record.mjs";
|
|
8
8
|
import { collections, newChangeId, repoScope, selfKey } from "../store/scopes.mjs";
|
|
9
9
|
import { CallBudget, RequestCalls, callScope, checkedLimits, countInto, countedAs, heldCall, inCallScope, noScope, readScope, requestCount, stepBudget, withBound } from "../store/call-count.mjs";
|
|
10
10
|
import { forkIn, noCall } from "../store/crossing.mjs";
|
|
11
|
-
import {
|
|
11
|
+
import { jobCallLimitsOf } from "../store/job-try.mjs";
|
|
12
|
+
import { RequestSnapshot } from "../store/request-snapshot.mjs";
|
|
13
|
+
import { bestEffort } from "../store/errors.mjs";
|
|
14
|
+
import { bucketDo, cancelsBody, madeOwned, objectReader } from "./calls.mjs";
|
|
12
15
|
import { budgetCalls, countedBucket } from "./counted-bucket.mjs";
|
|
13
16
|
import { hostFailures } from "./host-bucket.mjs";
|
|
14
17
|
import { cleanUp } from "./clean-up.mjs";
|
|
@@ -17,88 +20,123 @@ import { graphMostOf, indexRowOf, indexSaves, indexStatus, indexTry } from "./in
|
|
|
17
20
|
import { indexEligible, indexPath } from "./index-fetch.mjs";
|
|
18
21
|
import { listedIds } from "./listed-ids.mjs";
|
|
19
22
|
import { defaultRemapCpuMost, indexHolds } from "./index-remap.mjs";
|
|
20
|
-
import { indexRowKey, isPackId } from "./layout.mjs";
|
|
21
|
-
import { ReachCache, indexReach, reachedRoots } from "./index-reach.mjs";
|
|
23
|
+
import { indexRowKey, isPackId, packFiles, prunePassKey } from "./layout.mjs";
|
|
24
|
+
import { ReachCache, indexReach, reachCacheBytes, reachedRoots } from "./index-reach.mjs";
|
|
22
25
|
import { indexedVisible, setReachOf } from "./index-visible.mjs";
|
|
23
|
-
import { pointersOfObjects } from "./lfs-pointers.mjs";
|
|
24
|
-
import { largestOf } from "./largest-files.mjs";
|
|
25
26
|
import { PackIndexes, packReader, seedBytes } from "./pack-reads.mjs";
|
|
26
27
|
import { maintainBatches, withBatchesDue } from "./batch-upkeep.mjs";
|
|
27
|
-
import {
|
|
28
|
-
import { copyRowsPage, noRows } from "./object-rows.mjs";
|
|
28
|
+
import { abandonBatch, batchStager, deltaPartBytes, openBatch, stageBytes, streamedChange } from "./batches.mjs";
|
|
29
|
+
import { copyRowsPage, gitObjectOf, noRows, readStagedRows } from "./object-rows.mjs";
|
|
30
|
+
import { createReceiveCache, wholeOfCached } from "./receive-cache.mjs";
|
|
29
31
|
import { pushedCommitsPage } from "./pushed-commits.mjs";
|
|
30
32
|
import { segmentTooLarge } from "./links.mjs";
|
|
31
33
|
import { walkWithin } from "./swap-walk.mjs";
|
|
32
34
|
import { receivePack, tooMany } from "./pack-receive.mjs";
|
|
33
|
-
import { mergesAlone, passAlone, passDue, passScratch,
|
|
35
|
+
import { mergesAlone, passAlone, passDue, passScratch, pruneStartedKey, pruneStep, readPrune } from "./prune.mjs";
|
|
34
36
|
import { rebuildStep } from "./graph-rebuild.mjs";
|
|
35
37
|
import { liftedFences, unfenced } from "./merge-fence.mjs";
|
|
36
38
|
import { freshCalls, geometricStep, groupedPacks, membersOf, opensWithin, resumeMerge, streamHeld } from "./merge-stream.mjs";
|
|
37
39
|
import { droppedStep, mergeKey } from "./merge-row.mjs";
|
|
38
|
-
import { parksPass } from "./repack-job.mjs";
|
|
39
|
-
import { sharePacks } from "./quarantine.mjs";
|
|
40
|
-
import { burstOptions, defaultRepack, optionFor, readObjectRows } from "./repack.mjs";
|
|
40
|
+
import { parksPass, repackJobRow } from "./repack-job.mjs";
|
|
41
|
+
import { dropRefused, sharePacks } from "./quarantine.mjs";
|
|
42
|
+
import { burstOptions, defaultRepack, foldStep, optionFor, readObjectRows, rowsPastInflated } from "./repack.mjs";
|
|
41
43
|
import { containedPlan, containedWalk, countedMerge } from "./repack-contained.mjs";
|
|
42
44
|
import { refuseBacklog } from "./repack-backlog.mjs";
|
|
43
|
-
import { defaultShallow,
|
|
45
|
+
import { defaultShallow, readyAskMs, readyAskRoomMs, readyBytesOf, readyKey, readyLookup, readyStep, untilEnded, wantedRow } from "./ready.mjs";
|
|
44
46
|
import { defaultPrune, deletedLeaveAt, pruneWait, quarantineKey } from "./rows.mjs";
|
|
45
|
-
import { readAnswer, receiveStep, stageReceive } from "./receive-steps.mjs";
|
|
47
|
+
import { openStageReceive, readAnswer, receiveStep, stageReceive, stageReceiveStep, stageStepKey } from "./receive-steps.mjs";
|
|
46
48
|
import { memoryOf, openBudget } from "./packs-memory.mjs";
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
+
import { receiveRoomAdmitted } from "./receive-admission.mjs";
|
|
50
|
+
import { fetchFloorBytes, fetchRowCacheBytes, headroomBytes, idleHeapBytes, pushAdmissionOf, pushFloorsOf, pushPartBytes, pushRulesOf, readReserveBytes, readerFloorBytes, readerMost, unpackInflatedMost } from "./budget.mjs";
|
|
51
|
+
import { chargedCache } from "./charged-cache.mjs";
|
|
52
|
+
import { serverRequestBudget } from "./request-cache.mjs";
|
|
53
|
+
import { AllottedPointers, allotmentCacheCharge, allottedWithin, cacheRoomCharge, fetchBusy, growWaitMs, instanceRoomOf, pushMemoryOf, pushObjectsMostOf, pushTooLarge, readBusy, readerMemoryOf, requestBudgetOf, rowCacheRoomOf, upkeepMemoryOf, upkeepTooLarge, withMemoryBudget } from "./memory-budget.mjs";
|
|
49
54
|
import { PacksAllotment, catchPack, treesBusy } from "./push-allotment.mjs";
|
|
50
|
-
import {
|
|
55
|
+
import { adoptFetchRowCache, fetchIndexRowOf, fetchRowCacheOf } from "./fetch-row-cache.mjs";
|
|
51
56
|
import { wholeAnswer, wholePlan, wholeStream } from "./stream-whole.mjs";
|
|
52
|
-
import {
|
|
57
|
+
import { pastDeclared, readFailure, unpackObjects } from "./unpack.mjs";
|
|
53
58
|
import { seenFetch, visibleOf, walkedVisible } from "./visible.mjs";
|
|
54
|
-
import
|
|
59
|
+
import { limits } from "@ref0/infra";
|
|
55
60
|
import * as Effect from "effect/Effect";
|
|
56
|
-
import * as Exit from "effect/Exit";
|
|
57
61
|
import * as Predicate from "effect/Predicate";
|
|
58
62
|
import * as Context from "effect/Context";
|
|
59
|
-
import * as
|
|
63
|
+
import * as Exit from "effect/Exit";
|
|
64
|
+
import * as Scope$1 from "effect/Scope";
|
|
65
|
+
import * as Clock from "effect/Clock";
|
|
60
66
|
// src/storage/packs.ts
|
|
61
|
-
/** A push at or under
|
|
67
|
+
/** A push at or under 500 objects and 4 MiB is kept as rows (#2518). */
|
|
62
68
|
const defaultUnpack = {
|
|
63
|
-
maxObjects:
|
|
64
|
-
maxBytes:
|
|
69
|
+
maxObjects: 500,
|
|
70
|
+
maxBytes: 4194304
|
|
65
71
|
};
|
|
66
72
|
/**
|
|
67
|
-
* The pack's first chunks, read until they pass `most` bytes
|
|
68
|
-
*
|
|
69
|
-
*
|
|
73
|
+
* The pack's first chunks, read until they pass `most` bytes, the allotment has no room to hold
|
|
74
|
+
* more, or the pack ends. Every chunk buffered here is charged to `allotment` via `tryGrow` and
|
|
75
|
+
* returned via `release()` on completion, fallback, failure, or interrupt. A chunked push says no
|
|
76
|
+
* size, so its bytes are counted as they come. A pack that ends is let go of at once, each chunk a
|
|
77
|
+
* view of a larger buffer copied, so the small pack holds no more than its own bytes. One that
|
|
70
78
|
* doesn't hands on its reader, which `rejoined` lets go of. A read that fails or is interrupted
|
|
71
79
|
* cancels the pack, not waiting on the cancel, and lets go.
|
|
72
80
|
*/
|
|
73
|
-
const readPast = (pack, most) => Effect.suspend(() => {
|
|
81
|
+
const readPast = (pack, most, allotment, covered = 0) => Effect.suspend(() => {
|
|
74
82
|
const reader = pack.getReader();
|
|
83
|
+
let seen = 0;
|
|
84
|
+
let charged = 0;
|
|
85
|
+
const shrink = (bytes) => {
|
|
86
|
+
const give = Math.min(bytes, charged);
|
|
87
|
+
if (give <= 0) return;
|
|
88
|
+
charged -= give;
|
|
89
|
+
allotment.shrink(give);
|
|
90
|
+
};
|
|
91
|
+
const release = () => shrink(charged);
|
|
92
|
+
const charge = (bytes) => {
|
|
93
|
+
if (bytes <= 0) return true;
|
|
94
|
+
const next = seen + bytes;
|
|
95
|
+
const extra = Math.max(0, next - Math.max(seen, covered));
|
|
96
|
+
if (extra > 0 && !allotment.tryGrow(extra)) return false;
|
|
97
|
+
seen = next;
|
|
98
|
+
charged += extra;
|
|
99
|
+
return true;
|
|
100
|
+
};
|
|
75
101
|
const stop = Effect.sync(() => {
|
|
76
102
|
reader.cancel().catch(() => void 0);
|
|
77
103
|
reader.releaseLock();
|
|
104
|
+
release();
|
|
78
105
|
});
|
|
79
|
-
return readChunks(reader, most).pipe(Effect.onError(() => stop));
|
|
106
|
+
return readChunks(reader, most, charge, shrink, release).pipe(Effect.onError(() => stop));
|
|
80
107
|
});
|
|
81
|
-
const readChunks = (reader, most
|
|
108
|
+
const readChunks = /* @__PURE__ */ Effect.fnUntraced(function* (reader, most, charge, shrink, release) {
|
|
82
109
|
const chunks = [];
|
|
83
110
|
let bytes = 0;
|
|
84
111
|
while (bytes <= most) {
|
|
85
|
-
const read =
|
|
112
|
+
const read = yield* tryUnlessSpent(() => reader.read(), (cause) => readFailure(new PackTransportError({ cause })));
|
|
86
113
|
if (read.done) {
|
|
87
114
|
reader.releaseLock();
|
|
88
115
|
return {
|
|
89
116
|
ended: true,
|
|
90
|
-
chunks: chunks.map(owned)
|
|
117
|
+
chunks: chunks.map(owned),
|
|
118
|
+
shrink,
|
|
119
|
+
release
|
|
91
120
|
};
|
|
92
121
|
}
|
|
93
122
|
chunks.push(read.value);
|
|
94
123
|
bytes += read.value.byteLength;
|
|
124
|
+
if (!charge(read.value.byteLength)) return {
|
|
125
|
+
ended: false,
|
|
126
|
+
chunks,
|
|
127
|
+
reader,
|
|
128
|
+
shrink,
|
|
129
|
+
release
|
|
130
|
+
};
|
|
95
131
|
}
|
|
96
132
|
return {
|
|
97
133
|
ended: false,
|
|
98
134
|
chunks,
|
|
99
|
-
reader
|
|
135
|
+
reader,
|
|
136
|
+
shrink,
|
|
137
|
+
release
|
|
100
138
|
};
|
|
101
|
-
}
|
|
139
|
+
});
|
|
102
140
|
/** `chunk`, copied when it's a view of a larger buffer, which it would otherwise keep. */
|
|
103
141
|
const owned = (chunk) => chunk.byteOffset === 0 && chunk.byteLength === chunk.buffer.byteLength ? chunk : chunk.slice();
|
|
104
142
|
/** What a replayed chunk's place holds, so the chunk itself can go. */
|
|
@@ -108,7 +146,7 @@ const empty = /* @__PURE__ */ new Uint8Array(0);
|
|
|
108
146
|
* `reader`, and lets go of it once the pack ends, its read fails, or it's cancelled, after the
|
|
109
147
|
* cancel starts.
|
|
110
148
|
*/
|
|
111
|
-
const rejoined = (chunks, reader) => {
|
|
149
|
+
const rejoined = (chunks, reader, onChunk) => {
|
|
112
150
|
let next = 0;
|
|
113
151
|
return new ReadableStream({
|
|
114
152
|
pull: async (controller) => {
|
|
@@ -116,6 +154,7 @@ const rejoined = (chunks, reader) => {
|
|
|
116
154
|
if (chunk !== void 0) {
|
|
117
155
|
chunks[next] = empty;
|
|
118
156
|
next += 1;
|
|
157
|
+
onChunk?.(chunk.byteLength);
|
|
119
158
|
return controller.enqueue(chunk);
|
|
120
159
|
}
|
|
121
160
|
if (reader === void 0) return controller.close();
|
|
@@ -139,7 +178,6 @@ const rejoined = (chunks, reader) => {
|
|
|
139
178
|
};
|
|
140
179
|
/** A step whose record another try of it committed first: the next try goes on from there. */
|
|
141
180
|
const stepLost = fail("UNAVAILABLE", "Another try of this receive's step committed first", { hint: "Try the step again" });
|
|
142
|
-
const tooManyToUnpack = (count) => gitError("INVALID_ARGUMENT", `The pack's header counts ${count} objects, past what its push said`, { hint: "Push again" });
|
|
143
181
|
/**
|
|
144
182
|
* A repo's stats, read for an option given as a function: its record, refs, `stats` times, listed
|
|
145
183
|
* packs and ready shallow pack, all at one version, so the bytes are a total some version held.
|
|
@@ -218,39 +256,238 @@ const linkedPacks = /* @__PURE__ */ Effect.fnUntraced(function* (reader, oids) {
|
|
|
218
256
|
};
|
|
219
257
|
});
|
|
220
258
|
/**
|
|
259
|
+
* Push-allotment hooks for `batchStager`: reserves each prepared entry's size (flushing buffered
|
|
260
|
+
* entries on memory pressure) and releases the stager's charge whenever `batchStager` flushes.
|
|
261
|
+
*/
|
|
262
|
+
const stagerHooks = (charge) => {
|
|
263
|
+
let charged = 0;
|
|
264
|
+
const releaseCharge = () => {
|
|
265
|
+
if (charged <= 0) return;
|
|
266
|
+
const held = charged;
|
|
267
|
+
charged = 0;
|
|
268
|
+
charge.shrink(held);
|
|
269
|
+
};
|
|
270
|
+
return {
|
|
271
|
+
reserve: Effect.fnUntraced(function* (bytes, hasBuffered, flush) {
|
|
272
|
+
if (bytes <= 0) return;
|
|
273
|
+
if (hasBuffered) {
|
|
274
|
+
if (charge.tryGrow(bytes)) {
|
|
275
|
+
charged += bytes;
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
yield* flush();
|
|
279
|
+
}
|
|
280
|
+
yield* charge.grow(bytes, () => {
|
|
281
|
+
charged += bytes;
|
|
282
|
+
});
|
|
283
|
+
}),
|
|
284
|
+
flush: (send) => Effect.ensuring(send, Effect.sync(releaseCharge)),
|
|
285
|
+
clear: releaseCharge
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Fallback split for speculative `receiveRows`: decides in one place when a rows refusal may retry
|
|
290
|
+
* through `asPack` and when the rows path's memory refusal must be preserved.
|
|
291
|
+
*
|
|
292
|
+
* Whole-push admission (`budget.admit(pushAdmissionOf(input))`, before `receiveWithin`) and shared
|
|
293
|
+
* LFS pointer charging (`pointers.carrying`, after `receiveRows` succeeds) apply to both paths and
|
|
294
|
+
* never enter this split. Every `pushTooLarge` inside `receiveRows` comes from rows-only working
|
|
295
|
+
* buffers, so a self-contained pack can still succeed in `asPack`.
|
|
296
|
+
*/
|
|
297
|
+
const canFallbackFromRows = (error) => error.code === "RESOURCE_EXHAUSTED" && (error.context?.["reason"] === "object-too-large" || error.context?.["reason"] === "too-large" || error.context?.["reason"] === "delta-chain-too-deep");
|
|
298
|
+
const isNoThinPackRefusal = (error) => error.code === "INVALID_ARGUMENT" && error.context?.["reason"] === "base-not-before";
|
|
299
|
+
const rowsFallbackError = (rowsError, packError) => {
|
|
300
|
+
const rowsTooLarge = rowsError === pushTooLarge || rowsError.code === "RESOURCE_EXHAUSTED" && rowsError.context?.["reason"] === "too-large";
|
|
301
|
+
const packTooLarge = packError.code === "RESOURCE_EXHAUSTED" && packError.context?.["reason"] === "too-large";
|
|
302
|
+
if (rowsError === pushTooLarge && (isNoThinPackRefusal(packError) || packTooLarge)) return rowsError;
|
|
303
|
+
if (rowsTooLarge && isNoThinPackRefusal(packError)) return rowsError;
|
|
304
|
+
return packError;
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
221
307
|
* A small push as rows: it refuses an `OFS_DELTA` as a stored pack does, so one push answers alike
|
|
222
|
-
* at any size.
|
|
308
|
+
* at any size. Streams external thin bases via `eachHeld` on the shared `memory.outside` high-water
|
|
309
|
+
* (reusing `PackIndexer`'s reservation for packed bases and `ReceiveCache` for cached hits, while
|
|
310
|
+
* charging uncached row bases once), reclaims pending instructions before growing for an external
|
|
311
|
+
* base, and charges working-set buffers to `memory.allotment` (#2518).
|
|
223
312
|
*/
|
|
224
|
-
const receiveRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo,
|
|
313
|
+
const receiveRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, repo, makeReader, unpack, receive, memory, cache) {
|
|
314
|
+
const { allotment } = memory;
|
|
225
315
|
const objects = unpack === false ? 0 : unpack.maxObjects;
|
|
316
|
+
const bytes = unpack === false ? 0 : unpack.maxBytes;
|
|
317
|
+
const lru = chargedCache(cacheRoomCharge(memory.cache), {
|
|
318
|
+
maxBytes: pushFloorsOf(receive).cache,
|
|
319
|
+
entryOverhead: 96,
|
|
320
|
+
weight: (object) => object.bytes.byteLength,
|
|
321
|
+
evict: "lru"
|
|
322
|
+
});
|
|
323
|
+
let opened;
|
|
324
|
+
let stager;
|
|
325
|
+
let clearStager;
|
|
326
|
+
const covered = receiveRoomAdmitted(receive.objects, receive.needs?.length ?? 0);
|
|
327
|
+
let used = 0;
|
|
328
|
+
let grown = 0;
|
|
329
|
+
let outsideHigh = 0;
|
|
330
|
+
let reclaimState;
|
|
331
|
+
let reclaiming = false;
|
|
332
|
+
const extraFor = (amount) => Math.max(0, used + amount - Math.max(used, covered));
|
|
333
|
+
const runReclaim = Effect.fnUntraced(function* (need) {
|
|
334
|
+
if (reclaiming || reclaimState === void 0 || need <= allotment.growable) return;
|
|
335
|
+
const { ensureStager, waiting, dropPending, hasInline } = reclaimState;
|
|
336
|
+
reclaiming = true;
|
|
337
|
+
yield* Effect.gen(function* () {
|
|
338
|
+
if (hasInline()) yield* ensureStager();
|
|
339
|
+
if (stager !== void 0) yield* stager.flush();
|
|
340
|
+
for (const map of waiting) for (const list of map.values()) for (const delta of list) {
|
|
341
|
+
if (need <= allotment.growable) return;
|
|
342
|
+
const data = delta.data;
|
|
343
|
+
if (data === void 0) continue;
|
|
344
|
+
const active = yield* ensureStager();
|
|
345
|
+
const parts = [];
|
|
346
|
+
for (let at = 0; at < data.byteLength; at += deltaPartBytes) {
|
|
347
|
+
const take = Math.min(deltaPartBytes, data.byteLength - at);
|
|
348
|
+
stagerCharge.shrink(take);
|
|
349
|
+
yield* active.pushDelta(delta.seq, parts.length, data.subarray(at, at + take));
|
|
350
|
+
parts.push(take);
|
|
351
|
+
}
|
|
352
|
+
delta.data = void 0;
|
|
353
|
+
delta.parts = parts;
|
|
354
|
+
dropPending(data.byteLength);
|
|
355
|
+
yield* active.flush();
|
|
356
|
+
}
|
|
357
|
+
}).pipe(Effect.ensuring(Effect.sync(() => {
|
|
358
|
+
reclaiming = false;
|
|
359
|
+
})));
|
|
360
|
+
});
|
|
361
|
+
const reserveOutside = (need) => {
|
|
362
|
+
if (need <= outsideHigh) return void 0;
|
|
363
|
+
const delta = need - outsideHigh;
|
|
364
|
+
const grow = () => Effect.tap(stepEffect(memory.outside(need)), () => Effect.sync(() => {
|
|
365
|
+
outsideHigh = Math.max(outsideHigh, need);
|
|
366
|
+
}));
|
|
367
|
+
return delta <= allotment.growable || reclaimState === void 0 ? grow() : Effect.flatMap(runReclaim(delta), grow);
|
|
368
|
+
};
|
|
369
|
+
const reader = makeReader({
|
|
370
|
+
...memory.reader,
|
|
371
|
+
outside: reserveOutside
|
|
372
|
+
});
|
|
373
|
+
const cachedReader = cache === void 0 ? reader : cache.wrap(reader);
|
|
374
|
+
const stagerCharge = {
|
|
375
|
+
tryGrow: (amount) => {
|
|
376
|
+
if (amount <= 0) return true;
|
|
377
|
+
const extra = extraFor(amount);
|
|
378
|
+
if (extra > 0 && !allotment.tryGrow(extra)) return false;
|
|
379
|
+
used += amount;
|
|
380
|
+
grown += extra;
|
|
381
|
+
return true;
|
|
382
|
+
},
|
|
383
|
+
grow: (amount, adopted) => Effect.suspend(() => {
|
|
384
|
+
if (amount <= 0) {
|
|
385
|
+
adopted?.();
|
|
386
|
+
return Effect.void;
|
|
387
|
+
}
|
|
388
|
+
const take = () => {
|
|
389
|
+
const extra = extraFor(amount);
|
|
390
|
+
if (extra === 0) {
|
|
391
|
+
used += amount;
|
|
392
|
+
adopted?.();
|
|
393
|
+
return Effect.void;
|
|
394
|
+
}
|
|
395
|
+
return allotment.grow(extra, pushTooLarge, () => {
|
|
396
|
+
used += amount;
|
|
397
|
+
grown += extra;
|
|
398
|
+
adopted?.();
|
|
399
|
+
});
|
|
400
|
+
};
|
|
401
|
+
const extra = extraFor(amount);
|
|
402
|
+
return !reclaiming && extra > allotment.growable && reclaimState !== void 0 ? Effect.flatMap(runReclaim(extra), take) : take();
|
|
403
|
+
}),
|
|
404
|
+
shrink: (amount) => {
|
|
405
|
+
if (amount <= 0) return;
|
|
406
|
+
const nextUsed = Math.max(0, used - amount);
|
|
407
|
+
const neededGrown = Math.max(0, nextUsed - covered);
|
|
408
|
+
const give = Math.max(0, grown - neededGrown);
|
|
409
|
+
used = nextUsed;
|
|
410
|
+
grown -= give;
|
|
411
|
+
if (give > 0) allotment.shrink(give);
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
const unpackMemory = {
|
|
415
|
+
...stagerCharge,
|
|
416
|
+
page: (roundCap) => Math.min(roundCap, Math.max(limits.valueBytes, allotment.growable + Math.max(0, covered - used))),
|
|
417
|
+
delta: Effect.fnUntraced(function* (size, canHold, spillChunk) {
|
|
418
|
+
if (size > allotment.growable + Math.max(covered, used)) yield* stagerCharge.grow(size);
|
|
419
|
+
if (canHold && stagerCharge.tryGrow(size)) return true;
|
|
420
|
+
yield* stagerCharge.grow(spillChunk);
|
|
421
|
+
return false;
|
|
422
|
+
}),
|
|
423
|
+
free: (ensureStager, waiting, dropPending, hasInline) => {
|
|
424
|
+
reclaimState = {
|
|
425
|
+
ensureStager,
|
|
426
|
+
waiting,
|
|
427
|
+
dropPending,
|
|
428
|
+
hasInline
|
|
429
|
+
};
|
|
430
|
+
},
|
|
431
|
+
lru
|
|
432
|
+
};
|
|
433
|
+
const staging = {
|
|
434
|
+
stager: Effect.fnUntraced(function* () {
|
|
435
|
+
opened ??= yield* openBatch({
|
|
436
|
+
store,
|
|
437
|
+
repo,
|
|
438
|
+
at: yield* Clock.currentTimeMillis
|
|
439
|
+
});
|
|
440
|
+
if (stager === void 0) {
|
|
441
|
+
const hooks = stagerHooks(stagerCharge);
|
|
442
|
+
clearStager = hooks.clear;
|
|
443
|
+
stager = batchStager(store, repo, opened, stageBytes, hooks);
|
|
444
|
+
}
|
|
445
|
+
return stager;
|
|
446
|
+
}),
|
|
447
|
+
readStaged: readStagedRows(store, repo)
|
|
448
|
+
};
|
|
449
|
+
const eachHeld = (oids, take) => cachedReader.each(oids, (object) => Effect.flatMap(cache?.bodies.has(object.oid) === true ? Effect.void : stepEffect(reserveOutside(object.bytes.byteLength)), () => take(object)));
|
|
226
450
|
const unpacked = yield* unpackObjects({
|
|
227
451
|
receive,
|
|
228
452
|
limits: {
|
|
229
453
|
objects,
|
|
230
|
-
bytes
|
|
454
|
+
bytes
|
|
231
455
|
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
456
|
+
inflatedBytes: unpackInflatedMost,
|
|
457
|
+
tooMany: pastDeclared,
|
|
458
|
+
held: cachedReader.held,
|
|
459
|
+
eachHeld,
|
|
460
|
+
headers: cachedReader.headers,
|
|
461
|
+
offsetDeltas: "refuse",
|
|
462
|
+
staging,
|
|
463
|
+
memory: unpackMemory
|
|
464
|
+
}).pipe(Effect.onError(() => opened === void 0 ? Effect.void : abandonBatch(store, repo, opened.batch)), Effect.ensuring(Effect.sync(() => {
|
|
465
|
+
lru.clear();
|
|
466
|
+
clearStager?.();
|
|
467
|
+
stagerCharge.shrink(used);
|
|
468
|
+
})));
|
|
469
|
+
const staged = streamedChange(opened, unpacked.inlineRows, unpacked.own, unpacked.moved, yield* Clock.currentTimeMillis);
|
|
238
470
|
const quarantine = {
|
|
239
471
|
id: newChangeId(),
|
|
240
472
|
change: staged.change,
|
|
241
473
|
bytes: unpacked.bytes,
|
|
242
|
-
objects: unpacked.
|
|
243
|
-
lfsPointers:
|
|
244
|
-
...
|
|
474
|
+
objects: unpacked.count,
|
|
475
|
+
lfsPointers: unpacked.lfsPointers,
|
|
476
|
+
...unpacked.largest
|
|
245
477
|
};
|
|
246
478
|
if (unpacked.cut.length > 0) quarantine.cut = unpacked.cut;
|
|
247
479
|
if (staged.quarantine !== void 0) quarantine.quarantine = staged.quarantine;
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
480
|
+
if (unpacked.roots === void 0) return {
|
|
481
|
+
quarantine,
|
|
482
|
+
batch: opened?.batch
|
|
483
|
+
};
|
|
484
|
+
quarantine.roots = unpacked.roots;
|
|
485
|
+
const linked = unpacked.outside === void 0 ? void 0 : yield* linkedPacks(cachedReader, unpacked.outside);
|
|
252
486
|
if (linked !== void 0) quarantine.linked = linked;
|
|
253
|
-
return
|
|
487
|
+
return {
|
|
488
|
+
quarantine,
|
|
489
|
+
batch: opened?.batch
|
|
490
|
+
};
|
|
254
491
|
});
|
|
255
492
|
/**
|
|
256
493
|
* `packs()`: each push's objects one pack in the bucket, indexed as it streams in, under a
|
|
@@ -286,6 +523,7 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
286
523
|
open: ({ store: calls, bucket: hosts, clock, fetchLimits, callLimits }) => {
|
|
287
524
|
const bucket = countedBucket(hostFailures(hosts));
|
|
288
525
|
const callsMost = fetchCallsMost(callLimits, options.callLimits);
|
|
526
|
+
const stepMost = callLimits === void 0 ? callsMost : fetchCallsMost(jobCallLimitsOf(callLimits), options.callLimits);
|
|
289
527
|
const base = {
|
|
290
528
|
store: calls,
|
|
291
529
|
bucket
|
|
@@ -296,12 +534,12 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
296
534
|
const indexLimits = {
|
|
297
535
|
graphMost,
|
|
298
536
|
memory: budget.total,
|
|
299
|
-
calls:
|
|
537
|
+
calls: stepMost
|
|
300
538
|
};
|
|
301
539
|
const readerOf = (listed, memory, listedOnly, visible, handles = {
|
|
302
540
|
store: calls,
|
|
303
541
|
bucket
|
|
304
|
-
}, blocks) => {
|
|
542
|
+
}, blocks, observe, rowCache) => {
|
|
305
543
|
const input = {
|
|
306
544
|
...handles,
|
|
307
545
|
indexes,
|
|
@@ -311,6 +549,8 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
311
549
|
if (listedOnly !== void 0) input.listedOnly = listedOnly;
|
|
312
550
|
if (blocks !== void 0) input.blocks = blocks;
|
|
313
551
|
if (visible !== void 0) input.visible = visible;
|
|
552
|
+
if (observe !== void 0) input.observe = observe;
|
|
553
|
+
if (rowCache !== void 0) input.rowCache = rowCache;
|
|
314
554
|
return packReader(input);
|
|
315
555
|
};
|
|
316
556
|
/**
|
|
@@ -325,6 +565,7 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
325
565
|
const listedOnly = input?.listedOnly;
|
|
326
566
|
const context = yield* Effect.context();
|
|
327
567
|
const count = yield* callScope;
|
|
568
|
+
const rowCache = listedOnly === true ? void 0 : yield* fetchRowCacheOf(listed, () => rowCacheRoomOf(budget, fetchRowCacheBytes));
|
|
328
569
|
const allotted = "push" in on ? on.push.take(listedOnly === true, handles?.bucket ?? bucket) : void 0;
|
|
329
570
|
if (allotted !== void 0) {
|
|
330
571
|
const reader = readerOf(listed, readerMemoryOf(allotted.allotment, {
|
|
@@ -337,8 +578,13 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
337
578
|
blocks: 0
|
|
338
579
|
}
|
|
339
580
|
}), listedOnly, visible, handles, allotted.blocks);
|
|
581
|
+
const bases = listedOnly === true || !("push" in on) ? void 0 : on.push.bases;
|
|
340
582
|
return made(objectReader({
|
|
341
583
|
...reader,
|
|
584
|
+
object: bases === void 0 ? reader.object : (oid, signal) => {
|
|
585
|
+
const kept = bases.get(oid);
|
|
586
|
+
return kept === void 0 ? reader.object(oid, signal) : Effect.map(wholeOfCached(kept), gitObjectOf);
|
|
587
|
+
},
|
|
342
588
|
has: reader.seenHeld,
|
|
343
589
|
allotment: (most, refusal) => allottedWithin(allotted.allotment, most, refusal, context),
|
|
344
590
|
release: () => {
|
|
@@ -347,7 +593,7 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
347
593
|
}
|
|
348
594
|
}, count));
|
|
349
595
|
}
|
|
350
|
-
const scope = yield* Scope.make();
|
|
596
|
+
const scope = yield* Scope$1.make();
|
|
351
597
|
const held = "upkeep" in on ? Effect.map(upkeepMemoryOf(on.upkeep), (memory) => ({
|
|
352
598
|
memory,
|
|
353
599
|
allotment: on.upkeep
|
|
@@ -355,15 +601,15 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
355
601
|
memory: readerMemoryOf(allotment),
|
|
356
602
|
allotment
|
|
357
603
|
}));
|
|
358
|
-
return yield* Effect.uninterruptibleMask((restore) => Effect.map(restore(Scope.provide(held, scope)).pipe(Effect.onError(() => Scope.close(scope, Exit.void))), ({ memory, allotment }) => {
|
|
359
|
-
const reader = readerOf(listed, memory, listedOnly, visible, handles);
|
|
604
|
+
return yield* Effect.uninterruptibleMask((restore) => Effect.map(restore(Scope$1.provide(held, scope)).pipe(Effect.onError(() => Scope$1.close(scope, Exit.void))), ({ memory, allotment }) => {
|
|
605
|
+
const reader = readerOf(listed, memory, listedOnly, visible, handles, void 0, void 0, rowCache);
|
|
360
606
|
return made(objectReader({
|
|
361
607
|
...reader,
|
|
362
608
|
has: reader.seenHeld,
|
|
363
609
|
allotment: (most, refusal) => allottedWithin(allotment, most, refusal, context),
|
|
364
610
|
release: () => {
|
|
365
611
|
reader.release();
|
|
366
|
-
forkIn(Scope.close(scope, Exit.void), noCall);
|
|
612
|
+
forkIn(Scope$1.close(scope, Exit.void), noCall);
|
|
367
613
|
}
|
|
368
614
|
}, count));
|
|
369
615
|
}));
|
|
@@ -374,12 +620,12 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
374
620
|
* `listed`'s objects, read whole through one reader over `handles` in `on`'s memory, closed
|
|
375
621
|
* with the scope.
|
|
376
622
|
*/
|
|
377
|
-
const objectsAt = (listed, on, handles) => Effect.map(Effect.acquireRelease(openReader(listed, on, void 0, void 0, handles), (reader) => Effect.sync(() => reader.close())), (reader) => (oid) =>
|
|
623
|
+
const objectsAt = (listed, on, handles) => Effect.map(Effect.acquireRelease(openReader(listed, on, void 0, void 0, handles), (reader) => Effect.sync(() => reader.close())), (reader) => (oid) => reader.read({ oid }));
|
|
378
624
|
/** What a reach on the index reads through: a want check's, and a visible set's. */
|
|
379
625
|
const reachParts = {
|
|
380
626
|
bucket,
|
|
381
627
|
budget,
|
|
382
|
-
cache: new ReachCache(),
|
|
628
|
+
cache: new ReachCache(instanceRoomOf(budget, reachCacheBytes)),
|
|
383
629
|
objects: (listed) => objectsAt(listed, { read: true }),
|
|
384
630
|
indexes
|
|
385
631
|
};
|
|
@@ -416,6 +662,7 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
416
662
|
let written;
|
|
417
663
|
const memory = {
|
|
418
664
|
...pushMemoryOf(allotment, input),
|
|
665
|
+
allotment,
|
|
419
666
|
written: (pack, files) => {
|
|
420
667
|
written = {
|
|
421
668
|
listed: pack,
|
|
@@ -423,16 +670,17 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
423
670
|
};
|
|
424
671
|
}
|
|
425
672
|
};
|
|
426
|
-
const { caught, received } = yield* Effect.uninterruptibleMask((restore) => Effect.suspend(() => {
|
|
673
|
+
const { caught, received, bases } = yield* Effect.uninterruptibleMask((restore) => Effect.suspend(() => {
|
|
427
674
|
const caught = input.objects === 0 ? void 0 : catchPack(input.pack, input);
|
|
428
675
|
const body = caught === void 0 ? input : {
|
|
429
676
|
...input,
|
|
430
677
|
pack: caught.pack
|
|
431
678
|
};
|
|
432
679
|
const receiving = restore(receiveWithin(listed, body, memory, visible));
|
|
433
|
-
return Effect.map(cancelsBody(body.pack, receiving), (
|
|
680
|
+
return Effect.map(cancelsBody(body.pack, receiving), ({ quarantine, bases }) => ({
|
|
434
681
|
caught,
|
|
435
|
-
received
|
|
682
|
+
received: quarantine,
|
|
683
|
+
bases
|
|
436
684
|
}));
|
|
437
685
|
}));
|
|
438
686
|
if (input.objects === 0) return {
|
|
@@ -440,7 +688,7 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
440
688
|
seed: void 0
|
|
441
689
|
};
|
|
442
690
|
const block = written === void 0 ? void 0 : caught?.block(written);
|
|
443
|
-
const kept = yield* keepReceived(input, allotment, received, written, answered, block);
|
|
691
|
+
const kept = yield* keepReceived(input, allotment, received, written, answered, block, bases);
|
|
444
692
|
return {
|
|
445
693
|
answer: made(kept.received),
|
|
446
694
|
seed: kept.seed
|
|
@@ -450,18 +698,22 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
450
698
|
* What a received pack keeps past its receive's scope, owned by `answered`: the rules' share
|
|
451
699
|
* of its allotment and its LFS pointers, then the seed's charge for the files it wrote.
|
|
452
700
|
*/
|
|
453
|
-
const keepReceived = Effect.fnUntraced(function* (input, allotment, received, written, answered, caught) {
|
|
454
|
-
const keep = (bytes) => Scope.provide(Effect.acquireRelease(Effect.sync(() => allotment.keep(bytes, treesBusy)), (each, exit) => Exit.isSuccess(exit) || each.released ? Effect.void : Effect.sync(() =>
|
|
455
|
-
|
|
456
|
-
|
|
701
|
+
const keepReceived = Effect.fnUntraced(function* (input, allotment, received, written, answered, caught, bases) {
|
|
702
|
+
const keep = (bytes, onAbort) => Scope$1.provide(Effect.acquireRelease(Effect.sync(() => allotment.keep(bytes, treesBusy)), (each, exit) => Exit.isSuccess(exit) || each.released ? Effect.void : Effect.sync(() => {
|
|
703
|
+
onAbort?.();
|
|
704
|
+
each.release();
|
|
705
|
+
})), answered);
|
|
706
|
+
const kept = yield* keep(pushRulesOf(input) + received.lfsPointers.bytes + (bases?.chargedBytes ?? 0), () => bases?.clear());
|
|
707
|
+
const context = Context.omit(Scope$1.Scope)(yield* Effect.context());
|
|
457
708
|
const seed = written === void 0 ? void 0 : {
|
|
458
709
|
...written,
|
|
459
710
|
charge: yield* keep(seedBytes(written.files))
|
|
460
711
|
};
|
|
712
|
+
const pushAllotment = new PacksAllotment(kept, input, context, caught, bases);
|
|
461
713
|
return {
|
|
462
714
|
received: {
|
|
463
715
|
...received,
|
|
464
|
-
allotment:
|
|
716
|
+
allotment: pushAllotment
|
|
465
717
|
},
|
|
466
718
|
seed
|
|
467
719
|
};
|
|
@@ -493,6 +745,48 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
493
745
|
}
|
|
494
746
|
});
|
|
495
747
|
});
|
|
748
|
+
/** Stepped multipart staging for push uploads (#1931), internal to `packs()`. */
|
|
749
|
+
const stageStep = {
|
|
750
|
+
open: Effect.fnUntraced(function* (listed) {
|
|
751
|
+
const { quarantine: prune } = optionsFor(chosen ? yield* statsOf(calls, listed.repo) : void 0);
|
|
752
|
+
return yield* openStageReceive({
|
|
753
|
+
store: calls,
|
|
754
|
+
bucket,
|
|
755
|
+
indexes,
|
|
756
|
+
repo: listed.repo,
|
|
757
|
+
at: clock.currentTimeMillisUnsafe(),
|
|
758
|
+
prune
|
|
759
|
+
});
|
|
760
|
+
}),
|
|
761
|
+
slice: Effect.fnUntraced(function* (listed, input) {
|
|
762
|
+
const { shallow = [] } = input;
|
|
763
|
+
return yield* stageReceiveStep({
|
|
764
|
+
store: calls,
|
|
765
|
+
bucket,
|
|
766
|
+
sourceBucket: input.sourceBucket,
|
|
767
|
+
indexes,
|
|
768
|
+
repo: listed.repo,
|
|
769
|
+
sourceKey: input.sourceKey,
|
|
770
|
+
bytes: input.bytes,
|
|
771
|
+
staging: input.staging,
|
|
772
|
+
sliceBytes: input.sliceBytes,
|
|
773
|
+
partBytes: input.partBytes,
|
|
774
|
+
answer: {
|
|
775
|
+
boundary: [],
|
|
776
|
+
needs: [],
|
|
777
|
+
...shallow.length > 0 && { shallow: [...shallow] }
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
}),
|
|
781
|
+
abort: (pack, token) => bucketDo(bucket.abortPut(packFiles(pack).pack, token)).pipe(Effect.catchIf((error) => error.code === "NOT_FOUND", () => Effect.void)),
|
|
782
|
+
drop: (repo, pack) => dropRefused({
|
|
783
|
+
store: calls,
|
|
784
|
+
bucket,
|
|
785
|
+
indexes,
|
|
786
|
+
repo,
|
|
787
|
+
pack
|
|
788
|
+
})
|
|
789
|
+
};
|
|
496
790
|
/**
|
|
497
791
|
* One step of a staged receive, admitted as `receive` admits a push of its objects and needs:
|
|
498
792
|
* paused, with the step its next try runs, or its pack received, kept and seeded as
|
|
@@ -571,16 +865,34 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
571
865
|
const seeded = (run) => Effect.scoped(Effect.flatMap(Effect.scope, (answered) => Effect.flatMap(Effect.scoped(run(answered)), (done) => done.seed === void 0 ? Effect.succeed(done.answer) : Effect.as(indexes.seed(done.seed), done.answer))));
|
|
572
866
|
const receiveWithin = Effect.fnUntraced(function* (listed, input, memory, visible) {
|
|
573
867
|
const { unpack, quarantine } = optionsFor(chosen ? yield* statsOf(calls, listed.repo) : void 0);
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
868
|
+
const cache = createReceiveCache(allotmentCacheCharge(memory.allotment));
|
|
869
|
+
const makeReader = (readerMemory) => readerOf(listed, readerMemory, void 0, visible, void 0, void 0, cache.observe);
|
|
870
|
+
const dropPushPreload = Effect.flatMap(RequestSnapshot, (snapshot) => Effect.sync(() => snapshot?.dropPush?.(repoScope(listed.repo))));
|
|
871
|
+
if (input.objects === 0) {
|
|
872
|
+
yield* dropPushPreload;
|
|
873
|
+
return {
|
|
874
|
+
quarantine: (yield* receiveRows(calls, listed.repo, makeReader, unpack, input, memory, cache).pipe(Effect.ensuring(Effect.sync(() => cache.release())))).quarantine,
|
|
875
|
+
bases: void 0
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
if (unpack === false || input.objects > unpack.maxObjects) {
|
|
879
|
+
yield* dropPushPreload;
|
|
880
|
+
return {
|
|
881
|
+
quarantine: yield* asPack(listed, input, quarantine, memory, visible),
|
|
882
|
+
bases: void 0
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
const read = yield* readPast(input.pack, unpack.maxBytes, memory.allotment, pushPartBytes(input));
|
|
578
886
|
if (!read.ended) {
|
|
887
|
+
yield* dropPushPreload;
|
|
579
888
|
const whole = {
|
|
580
889
|
...input,
|
|
581
|
-
pack: rejoined(read.chunks, read.reader)
|
|
890
|
+
pack: rejoined(read.chunks, read.reader, read.shrink)
|
|
891
|
+
};
|
|
892
|
+
return {
|
|
893
|
+
quarantine: yield* cancelsBody(whole.pack, asPack(listed, whole, quarantine, memory, visible)).pipe(Effect.ensuring(Effect.sync(read.release))),
|
|
894
|
+
bases: void 0
|
|
582
895
|
};
|
|
583
|
-
return yield* cancelsBody(whole.pack, asPack(listed, whole, quarantine, memory, visible));
|
|
584
896
|
}
|
|
585
897
|
const whole = {
|
|
586
898
|
...input,
|
|
@@ -590,8 +902,37 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
590
902
|
...input,
|
|
591
903
|
pack: rejoined(read.chunks)
|
|
592
904
|
};
|
|
593
|
-
const rows = receiveRows(calls, listed.repo,
|
|
594
|
-
|
|
905
|
+
const rows = Effect.flatMap(receiveRows(calls, listed.repo, makeReader, unpack, whole, memory, cache).pipe(Effect.ensuring(dropPushPreload), Effect.map((done) => ({
|
|
906
|
+
kind: "rows",
|
|
907
|
+
done
|
|
908
|
+
})), Effect.catchIf(canFallbackFromRows, (rowsError) => Effect.gen(function* () {
|
|
909
|
+
cache.release();
|
|
910
|
+
yield* dropPushPreload;
|
|
911
|
+
return {
|
|
912
|
+
kind: "pack",
|
|
913
|
+
quarantine: yield* asPack(listed, again, quarantine, memory, visible).pipe(Effect.mapError((packError) => rowsFallbackError(rowsError, packError)))
|
|
914
|
+
};
|
|
915
|
+
}))), Effect.fnUntraced(function* (outcome) {
|
|
916
|
+
if (outcome.kind === "pack") return {
|
|
917
|
+
quarantine: outcome.quarantine,
|
|
918
|
+
bases: void 0
|
|
919
|
+
};
|
|
920
|
+
const { quarantine: received, batch } = outcome.done;
|
|
921
|
+
if (received.lfsPointers.count > 0) yield* memory.pointers.carrying(received.lfsPointers.count).pipe(Effect.onError(() => batch === void 0 ? Effect.void : abandonBatch(calls, listed.repo, batch)));
|
|
922
|
+
cache.dropLocations();
|
|
923
|
+
if (cache.bodies.size === 0) {
|
|
924
|
+
cache.release();
|
|
925
|
+
return {
|
|
926
|
+
quarantine: received,
|
|
927
|
+
bases: void 0
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
return {
|
|
931
|
+
quarantine: received,
|
|
932
|
+
bases: cache
|
|
933
|
+
};
|
|
934
|
+
})).pipe(Effect.onExit((exit) => Exit.isFailure(exit) ? Effect.sync(() => cache.release()) : Effect.void));
|
|
935
|
+
return yield* cancelsBody(whole.pack, rows).pipe(Effect.ensuring(Effect.sync(read.release)));
|
|
595
936
|
});
|
|
596
937
|
/**
|
|
597
938
|
* The stored packs streamed whole, for a fetch the core proved may have them, over the whole
|
|
@@ -605,12 +946,13 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
605
946
|
const streamed = Effect.fnUntraced(function* (listed, input, started, counted) {
|
|
606
947
|
const { limits } = input;
|
|
607
948
|
const { store, bucket } = counted.handles;
|
|
608
|
-
const scope = yield* Scope.make();
|
|
609
|
-
const ended = Scope.close(scope, Exit.void);
|
|
949
|
+
const scope = yield* Scope$1.make();
|
|
950
|
+
const ended = Scope$1.close(scope, Exit.void);
|
|
610
951
|
return yield* Effect.gen(function* () {
|
|
611
|
-
const allotment = yield* Scope.provide(budget.allot(fetchFloorBytes, fetchBusy), scope);
|
|
612
|
-
const charge = (bytes) => allotment.grow(bytes, fetchTooLarge);
|
|
613
|
-
const
|
|
952
|
+
const allotment = yield* Scope$1.provide(budget.allot(fetchFloorBytes, fetchBusy), scope);
|
|
953
|
+
const charge = (bytes, adopted) => allotment.grow(bytes, fetchTooLarge, adopted);
|
|
954
|
+
const release = (bytes) => Effect.sync(() => allotment.shrink(bytes));
|
|
955
|
+
const plan = yield* wholePlan(store, bucket, indexes, listed, input, counted.calls, charge, release).pipe(Effect.timeoutOrElse({
|
|
614
956
|
duration: Math.max(0, yield* timeLeft(limits, started)),
|
|
615
957
|
orElse: () => Effect.fail(planTooSlow(limits))
|
|
616
958
|
}));
|
|
@@ -638,7 +980,24 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
638
980
|
const sent = whole && input.whole === true ? yield* streamed(listed, input, started, counted) : void 0;
|
|
639
981
|
if (sent !== void 0) return sent;
|
|
640
982
|
const { store, bucket: read } = counted.handles;
|
|
641
|
-
|
|
983
|
+
const depth = shallow === false ? void 0 : shallow.depth;
|
|
984
|
+
const { answer, want } = yield* readyLookup(store, read, listed, input, started, depth, counted.calls);
|
|
985
|
+
if (answer !== void 0) return answer;
|
|
986
|
+
if (want === void 0) return yield* planned(listed, input, started, counted);
|
|
987
|
+
const allowance = Math.min(readyAskMs, (yield* timeLeft(input.limits, started)) - readyAskRoomMs);
|
|
988
|
+
if (allowance <= 0) return yield* planned(listed, input, started, counted);
|
|
989
|
+
const asked = store.add({
|
|
990
|
+
scope: repoScope(listed.repo),
|
|
991
|
+
addition: {
|
|
992
|
+
put: [wantedRow(want)],
|
|
993
|
+
jobs: [repackJobRow(started)]
|
|
994
|
+
}
|
|
995
|
+
}).pipe(Effect.timeoutOrElse({
|
|
996
|
+
duration: allowance,
|
|
997
|
+
orElse: () => Effect.logWarning(`A shallow clone's ask for repo ${listed.repo}'s ready pack took past ${allowance} ms, so a later clone asks again`)
|
|
998
|
+
}));
|
|
999
|
+
yield* bestEffort(asked, (error) => error.code === "ALREADY_EXISTS" ? Effect.void : Effect.logWarning(`A shallow clone's ask for repo ${listed.repo}'s ready pack wasn't saved, so a later clone asks again: ${error.message}`));
|
|
1000
|
+
return yield* planned(listed, input, started, counted);
|
|
642
1001
|
});
|
|
643
1002
|
/**
|
|
644
1003
|
* A walk past what one fetch may be allotted: `awaitingIndex` while the repo's `git.index`
|
|
@@ -651,9 +1010,9 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
651
1010
|
* to 30 before the next, are final too: no push saves `git.index` before `retryAt`, so "a few
|
|
652
1011
|
* minutes" would be false. Once the wait has passed, `retry`, the next push saves a try.
|
|
653
1012
|
*/
|
|
654
|
-
const pastWalk = Effect.fnUntraced(function* (store, listed, request, extras, index) {
|
|
1013
|
+
const pastWalk = Effect.fnUntraced(function* (store, listed, request, extras, index, knownIndexRow) {
|
|
655
1014
|
if (!indexEligible(request)) return yield* Effect.fail(fetchTooLarge);
|
|
656
|
-
const pending = yield* indexPending(store, listed);
|
|
1015
|
+
const pending = yield* indexPending(store, listed, knownIndexRow);
|
|
657
1016
|
const covered = index.opened && !extras.met;
|
|
658
1017
|
return yield* Effect.fail(!pending || covered ? fetchTooLarge : awaitingIndex);
|
|
659
1018
|
});
|
|
@@ -661,19 +1020,20 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
661
1020
|
* A walk refused at its call bound before the repo's first index: `awaitingIndex` while
|
|
662
1021
|
* `git.index` will build an index that answers `request`, since the index path's calls grow
|
|
663
1022
|
* by its packs where the walk's grow by its bytes; `refused` as it was once the fetch opened
|
|
664
|
-
* an index, or when none will build (#647).
|
|
1023
|
+
* an index, or when none will build (#647). When `knownIndexRow` was already read by `opened`
|
|
1024
|
+
* at `listed.version` (#2899), no extra store call is needed or held back.
|
|
665
1025
|
*/
|
|
666
|
-
const pastCalls = Effect.fnUntraced(function* (store, listed, request, index, refused) {
|
|
1026
|
+
const pastCalls = Effect.fnUntraced(function* (store, listed, request, index, refused, knownIndexRow) {
|
|
667
1027
|
if (index.opened || !indexEligible(request)) return yield* Effect.fail(refused);
|
|
668
|
-
return yield* Effect.fail((yield* indexPending(store, listed)) ? awaitingIndex : refused);
|
|
1028
|
+
return yield* Effect.fail((yield* indexPending(store, listed, knownIndexRow)) ? awaitingIndex : refused);
|
|
669
1029
|
});
|
|
670
1030
|
/** Whether the repo's `git.index` will build or update an index for `listed`, by its row. */
|
|
671
|
-
const indexPending = Effect.fnUntraced(function* (store, listed) {
|
|
672
|
-
const
|
|
1031
|
+
const indexPending = Effect.fnUntraced(function* (store, listed, known) {
|
|
1032
|
+
const raw = known !== void 0 ? known.row : (yield* store.read({
|
|
673
1033
|
scope: repoScope(listed.repo),
|
|
674
1034
|
reads: [indexRowKey]
|
|
675
|
-
});
|
|
676
|
-
const row = indexRowOf(
|
|
1035
|
+
})).results[0]?.[0];
|
|
1036
|
+
const row = indexRowOf(raw);
|
|
677
1037
|
const at = yield* Clock.currentTimeMillis;
|
|
678
1038
|
return indexSaves(indexStatus(row, indexLimits, at, listedIds(listed)));
|
|
679
1039
|
});
|
|
@@ -682,29 +1042,27 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
682
1042
|
* pack's stream outlives the call.
|
|
683
1043
|
*/
|
|
684
1044
|
const planned = Effect.fnUntraced(function* (listed, input, started, counted) {
|
|
685
|
-
const scope = yield* Scope.make();
|
|
686
|
-
const ended = Scope.close(scope, Exit.void);
|
|
1045
|
+
const scope = yield* Scope$1.make();
|
|
1046
|
+
const ended = Scope$1.close(scope, Exit.void);
|
|
687
1047
|
return yield* Effect.gen(function* () {
|
|
688
|
-
const allotment = yield* Scope.provide(budget.allot(fetchFloorBytes, fetchBusy), scope);
|
|
1048
|
+
const allotment = yield* Scope$1.provide(budget.allot(fetchFloorBytes, fetchBusy), scope);
|
|
689
1049
|
const memory = readerMemoryOf(allotment, { tooLarge: () => fetchTooLarge });
|
|
690
|
-
const
|
|
1050
|
+
const rowCache = yield* adoptFetchRowCache(listed, rowCacheRoomOf(allotment, fetchRowCacheBytes));
|
|
1051
|
+
const reader = readerOf(listed, memory, void 0, void 0, counted.handles, void 0, void 0, rowCache);
|
|
691
1052
|
const charge = (bytes) => allotment.grow(bytes, fetchTooLarge);
|
|
692
1053
|
const { store, bucket: read } = counted.handles;
|
|
693
1054
|
const extras = counted.calls?.extras ?? { met: false };
|
|
694
1055
|
const opened = { opened: false };
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
bucket: read,
|
|
698
|
-
listed,
|
|
699
|
-
extras,
|
|
700
|
-
opened
|
|
701
|
-
} : {
|
|
1056
|
+
const indexRow = yield* fetchIndexRowOf(listed);
|
|
1057
|
+
const index = {
|
|
702
1058
|
store,
|
|
703
1059
|
bucket: read,
|
|
704
1060
|
listed,
|
|
705
1061
|
extras,
|
|
706
1062
|
opened,
|
|
707
|
-
|
|
1063
|
+
indexes,
|
|
1064
|
+
...inner.wholeIndexMost !== void 0 && { wholeMost: inner.wholeIndexMost },
|
|
1065
|
+
...indexRow !== void 0 && { indexRow }
|
|
708
1066
|
};
|
|
709
1067
|
const release = (bytes) => Effect.sync(() => allotment.shrink(bytes));
|
|
710
1068
|
const held = {
|
|
@@ -715,22 +1073,22 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
715
1073
|
release
|
|
716
1074
|
};
|
|
717
1075
|
if (counted.calls !== void 0) held.calls = counted.calls;
|
|
718
|
-
const givenBack = indexEligible(input.request) ? yield* heldCall("store") : Effect.void;
|
|
1076
|
+
const givenBack = indexEligible(input.request) && indexRow === void 0 ? yield* heldCall("store") : Effect.void;
|
|
719
1077
|
const walk = { over: false };
|
|
720
1078
|
held.walked = givenBack;
|
|
721
1079
|
held.planned = Effect.sync(() => {
|
|
722
1080
|
walk.over = true;
|
|
723
1081
|
});
|
|
724
1082
|
const clone = input.request.haves.length === 0;
|
|
725
|
-
const fetched = Scope.provide(fetchPack(reader, input, fetchLimits, held), scope);
|
|
726
|
-
return yield* refusedWhenSpent(fetched, counted.calls, clone).pipe(Effect.ensuring(givenBack), Effect.catchIf((error) => error === fetchTooLarge, () => pastWalk(store, listed, input.request, extras, opened)), Effect.catchIf((error) => !walk.over && error.context?.["reason"] === "too-many-store-calls", (refused) => pastCalls(store, listed, input.request, opened, refused)));
|
|
1083
|
+
const fetched = Scope$1.provide(fetchPack(reader, input, fetchLimits, held), scope).pipe(Effect.ensuring(Effect.sync(() => rowCache.clear())));
|
|
1084
|
+
return yield* refusedWhenSpent(fetched, counted.calls, clone).pipe(Effect.ensuring(givenBack), Effect.catchIf((error) => error === fetchTooLarge, () => pastWalk(store, listed, input.request, extras, opened, indexRow)), Effect.catchIf((error) => !walk.over && error.context?.["reason"] === "too-many-store-calls", (refused) => pastCalls(store, listed, input.request, opened, refused, indexRow)));
|
|
727
1085
|
}).pipe(Effect.onError(() => ended));
|
|
728
1086
|
});
|
|
729
1087
|
/**
|
|
730
1088
|
* Clean-up's step first; once it has nothing to do, a geometric merge's, which answers
|
|
731
1089
|
* `more`; once there's none, the ready shallow pack's.
|
|
732
1090
|
*/
|
|
733
|
-
const maintain = (listed, input) =>
|
|
1091
|
+
const maintain = (listed, input) => stepMost === void 0 ? upkeepOf(listed, input, void 0) : Effect.flatMap(stepBudget(stepMost, "upkeep"), (own) => Effect.provideService(upkeepOf(listed, input, own), CallBudget, own));
|
|
734
1092
|
/** `maintain`'s step, its calls counted into `own`, the step's budget, when bounded. */
|
|
735
1093
|
const upkeepOf = Effect.fnUntraced(function* (listed, input, own) {
|
|
736
1094
|
const { at, deleted } = input;
|
|
@@ -877,7 +1235,7 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
877
1235
|
const alone = (pack) => cruft(pack) || held.has(pack.id);
|
|
878
1236
|
const kept = (pack) => alone(pack) || read.refused.has(pack.id);
|
|
879
1237
|
const members = membersOf(upkeep, objectRows.rows, kept, holds);
|
|
880
|
-
const opens = opensWithin(upkeep.bucket.multipart,
|
|
1238
|
+
const opens = opensWithin(upkeep.bucket.multipart, stepMost);
|
|
881
1239
|
const grouped = repack === false ? void 0 : groupedPacks(members, repack, opens);
|
|
882
1240
|
const heldUntil = burst?.quietAt === void 0 || chosen === false || grouped === void 0 || groupedPacks(members, chosen, opens).size <= grouped.size ? void 0 : burst.quietAt;
|
|
883
1241
|
const plan = grouped === void 0 ? void 0 : yield* containedPlan(upkeep, alone, grouped);
|
|
@@ -886,6 +1244,8 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
886
1244
|
if (owed !== void 0) return owed;
|
|
887
1245
|
const merged = repack === false ? void 0 : yield* geometricStep(upkeep, repack, objectRows.rows, kept, geometricRemap(repack));
|
|
888
1246
|
if (merged !== void 0) return plan === void 0 ? merged : countedMerge(plan, merged);
|
|
1247
|
+
const folded = repack === false || objectRows.rows.length === 0 || !(yield* rowsPastInflated(upkeep, objectRows, 16777216, input.stats)) ? void 0 : yield* foldStep(upkeep, objectRows.rows, repack.maxPackSize ?? defaultRepack.maxPackSize);
|
|
1248
|
+
if (folded !== void 0) return folded;
|
|
889
1249
|
const dropped = plan === void 0 || walksFirst ? void 0 : yield* containedWalk(upkeep, plan);
|
|
890
1250
|
if (dropped !== void 0) return dropped;
|
|
891
1251
|
const step = {
|
|
@@ -1008,7 +1368,7 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
1008
1368
|
}, listed, input).pipe(Effect.tap((answer) => answer.kind === "moved" && own !== void 0 ? countInto(own, "store", 1) : Effect.void));
|
|
1009
1369
|
return own === void 0 ? step : Effect.provideService(step, CallBudget, own);
|
|
1010
1370
|
};
|
|
1011
|
-
return
|
|
1371
|
+
return stepMost === void 0 ? counted(void 0) : Effect.flatMap(indexBudget(input, stepMost), counted);
|
|
1012
1372
|
},
|
|
1013
1373
|
reach: (listed, input) => {
|
|
1014
1374
|
const built = indexReach(reachParts, listed, input);
|
|
@@ -1036,18 +1396,19 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
1036
1396
|
reach: face.index.reach
|
|
1037
1397
|
},
|
|
1038
1398
|
readyShallow: shallow !== false,
|
|
1039
|
-
pushObjectsMost: pushObjectsMostOf(memoryTotal)
|
|
1399
|
+
pushObjectsMost: pushObjectsMostOf(memoryTotal),
|
|
1400
|
+
...visible === void 0 && { [stageStepKey]: stageStep }
|
|
1040
1401
|
};
|
|
1041
1402
|
};
|
|
1042
|
-
const visible = (listed, input, fallback = () => walkedVisible(over(), listed, input)) => indexedVisible(reachParts, listed, input, fallback);
|
|
1403
|
+
const visible = (listed, input, fallback = () => walkedVisible(over(), listed, input, { budget: serverRequestBudget(requestBudgetOf(budget)) })) => indexedVisible(reachParts, listed, input, fallback);
|
|
1043
1404
|
const seen = (set) => over(visibleOf(set), setReachOf(set));
|
|
1044
1405
|
const rootsReached = (listed, input) => reachedRoots(reachParts, listed, input);
|
|
1045
|
-
return withBound({
|
|
1406
|
+
return withBound(withMemoryBudget({
|
|
1046
1407
|
...over(),
|
|
1047
1408
|
visible,
|
|
1048
1409
|
seen,
|
|
1049
1410
|
rootsReached
|
|
1050
|
-
}, callsMost);
|
|
1411
|
+
}, budget), callsMost);
|
|
1051
1412
|
}
|
|
1052
1413
|
};
|
|
1053
1414
|
};
|