@ref0/git 0.14.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/access-jwt.mjs +2 -2
- package/dist/auth/authorize.mjs +3 -3
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.mjs +4 -4
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/token-cleanup.mjs +67 -0
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/token-text.mjs +9 -1
- package/dist/auth/tokens-base.d.mts +35 -0
- package/dist/auth/tokens-base.mjs +13 -0
- package/dist/auth/tokens-layer.d.mts +2 -27
- package/dist/auth/tokens-layer.mjs +6 -11
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -10
- package/dist/auth/tokens.mjs +9 -80
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +17 -7
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +9 -8
- package/dist/client/remote.mjs +8 -10
- package/dist/client/run-remote-helper.d.mts +1 -0
- package/dist/client/run-remote-helper.mjs +58 -24
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +105 -46
- package/dist/contracts/blobs.d.mts +55 -8
- package/dist/contracts/blobs.mjs +16 -2
- package/dist/contracts/call-allowance.d.mts +13 -0
- package/dist/contracts/call-allowance.mjs +44 -0
- package/dist/contracts/calls-spent.mjs +8 -3
- package/dist/contracts/client.d.mts +15 -16
- package/dist/contracts/commits.d.mts +24 -24
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +10 -10
- package/dist/contracts/forks.d.mts +17 -17
- package/dist/contracts/git-events.d.mts +29 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +21 -0
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -2
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +23 -25
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +26 -23
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +4 -1
- package/dist/contracts/repos.d.mts +29 -138
- package/dist/contracts/repos.mjs +5 -3
- package/dist/contracts/result.d.mts +35 -16
- package/dist/contracts/result.mjs +35 -7
- package/dist/contracts/server.d.mts +25 -50
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +11 -7
- package/dist/contracts/sync.mjs +12 -2
- package/dist/contracts/tags.d.mts +10 -10
- package/dist/contracts/time.d.mts +3 -0
- package/dist/contracts/{promises.mjs → time.mjs} +1 -1
- package/dist/contracts/tokens.d.mts +15 -17
- package/dist/contracts/tokens.mjs +3 -2
- package/dist/contracts/topics.d.mts +1 -1
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +24 -13
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +20 -9
- package/dist/core/ancestry.d.mts +1 -0
- package/dist/core/asked.mjs +1 -1
- package/dist/core/call-names.mjs +6 -1
- package/dist/core/call-services.mjs +11 -3
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +43 -36
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +928 -432
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +29 -23
- package/dist/core/index-job.mjs +122 -34
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/lines.mjs +2 -2
- package/dist/core/objects/merges.mjs +4 -1
- package/dist/core/objects/objects-layer.d.mts +1 -1
- package/dist/core/objects/objects-layer.mjs +3 -3
- package/dist/core/objects/reading.mjs +24 -13
- package/dist/core/objects/tags.mjs +4 -1
- package/dist/core/objects/trees.mjs +2 -2
- package/dist/core/objects/writing.mjs +2 -2
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +4 -5
- package/dist/core/parts.mjs +3 -8
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +287 -83
- package/dist/core/push-decide.mjs +2 -0
- package/dist/core/push-files.d.mts +1 -1
- package/dist/core/push.mjs +58 -47
- package/dist/core/receipts.mjs +8 -3
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +2 -2
- package/dist/core/refs.mjs +5 -5
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +36 -21
- package/dist/core/repo-info.mjs +3 -3
- package/dist/core/repos.mjs +21 -9
- package/dist/core/rules/commit-changes.d.mts +0 -1
- package/dist/core/saved-caller-views.d.mts +7 -2
- package/dist/core/saved-caller-views.mjs +2 -2
- package/dist/core/saved-callers.d.mts +19 -2
- package/dist/core/seam.d.mts +16 -26
- package/dist/core/seam.mjs +7 -28
- package/dist/core/tokens.mjs +1 -1
- package/dist/core/view.mjs +7 -15
- package/dist/core/work.mjs +59 -14
- package/dist/effect.d.mts +3 -12
- package/dist/effect.mjs +1 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +4 -4
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +37 -14
- package/dist/extend.d.mts +2 -3
- package/dist/extend.mjs +2 -1
- package/dist/http/answers.mjs +8 -5
- package/dist/http/core-parts.mjs +95 -79
- package/dist/http/handler.mjs +34 -7
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +56 -27
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +30 -26
- package/dist/http/push-uploads.mjs +36 -21
- package/dist/http/upload-pack.mjs +3 -3
- package/dist/index.d.mts +14 -14
- package/dist/index.mjs +2 -2
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +2 -0
- package/dist/lfs/base.mjs +25 -1
- package/dist/lfs/copy.d.mts +21 -7
- package/dist/lfs/copy.mjs +89 -6
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +24 -11
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -0
- package/dist/lfs/objects.mjs +87 -17
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/streams.mjs +27 -1
- package/dist/protocol/diff/read.d.mts +4 -3
- package/dist/protocol/diff/read.mjs +8 -3
- package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
- package/dist/protocol/objects/lfs-pointer.mjs +1 -3
- package/dist/protocol/objects/links-raw.mjs +24 -10
- package/dist/protocol/objects/tag.d.mts +1 -1
- package/dist/protocol/objects/tree.mjs +23 -6
- package/dist/protocol/packs/delta.d.mts +6 -3
- package/dist/protocol/packs/delta.mjs +96 -32
- package/dist/protocol/packs/idx.d.mts +2 -1
- package/dist/protocol/packs/idx.mjs +22 -3
- package/dist/protocol/packs/parts.d.mts +4 -1
- package/dist/protocol/packs/parts.mjs +10 -7
- package/dist/protocol/packs/reader.d.mts +5 -0
- package/dist/protocol/packs/reader.mjs +3 -2
- package/dist/protocol/packs/writer.mjs +26 -8
- package/dist/queue/advance.mjs +21 -24
- package/dist/queue/base.d.mts +55 -0
- package/dist/queue/base.mjs +44 -0
- package/dist/queue/calls.mjs +51 -54
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -15
- package/dist/queue/host.mjs +2 -7
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +10 -3
- package/dist/queue/limits.mjs +2 -0
- package/dist/queue/push-option.mjs +9 -24
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/state.mjs +2 -10
- package/dist/queue/trim.mjs +5 -3
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4271
- package/dist/rest/caller.mjs +4 -0
- package/dist/rest/client.d.mts +8 -5
- package/dist/rest/client.mjs +19 -2
- package/dist/rest/handlers.mjs +50 -5
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +5 -12
- package/dist/rest/me.d.mts +3 -432
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +11 -8
- package/dist/server/edge-node.mjs +9 -6
- package/dist/server/edge.d.mts +21 -7
- package/dist/server/edge.mjs +32 -11
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +5 -5
- package/dist/server/git-layer.mjs +28 -22
- package/dist/server/git-namespace.d.mts +4 -3
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +6 -18
- package/dist/server/joined.mjs +9 -36
- package/dist/server/lifecycle.mjs +18 -106
- package/dist/server/registry.mjs +24 -7
- package/dist/server/server.mjs +205 -346
- package/dist/signin/context.d.mts +1 -2
- package/dist/signin/layer.d.mts +1 -1
- package/dist/signin/layer.mjs +1 -1
- package/dist/storage/allotted.mjs +18 -3
- package/dist/storage/batch-upkeep.mjs +274 -0
- package/dist/storage/batches.d.mts +8 -0
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/calls.d.mts +1 -2
- package/dist/storage/calls.mjs +144 -158
- package/dist/storage/chunks.d.mts +9 -0
- package/dist/storage/chunks.mjs +297 -0
- package/dist/storage/clean-up.mjs +72 -9
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +287 -210
- package/dist/storage/host-bucket.mjs +1 -2
- package/dist/storage/id-mix.mjs +19 -5
- package/dist/storage/index-bitmaps.mjs +9 -2
- package/dist/storage/index-build.d.mts +0 -1
- package/dist/storage/index-build.mjs +80 -23
- package/dist/storage/index-fetch.mjs +113 -72
- package/dist/storage/index-files.d.mts +3 -0
- package/dist/storage/index-files.mjs +10 -5
- package/dist/storage/index-graph.mjs +72 -22
- package/dist/storage/index-remap.mjs +200 -64
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +1 -1
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +212 -67
- package/dist/storage/memory-budget.mjs +16 -4
- package/dist/storage/merge-plan.mjs +3 -2
- package/dist/storage/merge-row.mjs +7 -1
- package/dist/storage/merge-stream.mjs +164 -25
- package/dist/storage/merge-walk.mjs +8 -4
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +1 -0
- package/dist/storage/object-rows.mjs +385 -65
- package/dist/storage/oid-table.mjs +171 -0
- package/dist/storage/pack-order.mjs +8 -4
- package/dist/storage/pack-ranges.d.mts +1 -2
- package/dist/storage/pack-ranges.mjs +4 -5
- package/dist/storage/pack-reads.d.mts +2 -1
- package/dist/storage/pack-reads.mjs +158 -42
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +2 -2
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +136 -66
- package/dist/storage/placed-reads.mjs +1 -1
- package/dist/storage/plan-columns.d.mts +4 -0
- package/dist/storage/plan-columns.mjs +238 -0
- package/dist/storage/prune-keep.mjs +134 -41
- package/dist/storage/prune-walk.mjs +202 -62
- package/dist/storage/prune.mjs +194 -91
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +4 -4
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +8 -6
- package/dist/storage/receive-bounds.mjs +23 -8
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.mjs +195 -43
- package/dist/storage/send-list.d.mts +1 -0
- package/dist/storage/send-list.mjs +54 -10
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +127 -26
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +2 -2
- package/dist/storage/walk.mjs +192 -38
- package/dist/storage/wants.mjs +5 -5
- package/dist/store/bodies.mjs +38 -0
- package/dist/store/call-count.d.mts +8 -12
- package/dist/store/call-count.mjs +34 -46
- package/dist/store/catalogue.d.mts +2 -2
- package/dist/store/catalogue.mjs +145 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal.d.mts +1 -2
- package/dist/store/cursor-seal.mjs +16 -6
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +15 -33
- package/dist/store/git-store.mjs +25 -7
- package/dist/store/job-try.mjs +9 -32
- package/dist/store/list-job.mjs +44 -8
- package/dist/store/records.d.mts +3 -0
- package/dist/store/records.mjs +3 -0
- package/dist/store/repo-record.d.mts +1 -2
- package/dist/store/repo-record.mjs +32 -20
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +11 -0
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/github.mjs +3 -3
- package/dist/sync/import.mjs +31 -18
- package/dist/sync/lfs-batch.mjs +4 -5
- package/dist/sync/lfs-copy.mjs +17 -6
- package/dist/sync/mirror.mjs +34 -31
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/step.mjs +33 -25
- package/dist/sync/tries.mjs +9 -9
- package/dist/topics/advance.mjs +10 -11
- package/dist/topics/base.d.mts +15 -0
- package/dist/topics/base.mjs +8 -0
- package/dist/topics/host.mjs +1 -1
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +2 -3
- package/dist/topics/members.mjs +4 -4
- package/dist/topics/public.d.mts +2 -1
- package/dist/topics/topic.mjs +2 -2
- package/package.json +5 -4
- package/dist/contracts/promises.d.mts +0 -39
- package/dist/core/call-names.d.mts +0 -3
- package/dist/core/clock.mjs +0 -18
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -833
- package/dist/rest/commits.d.mts +0 -3543
- package/dist/rest/errors.d.mts +0 -2124
- package/dist/rest/events.d.mts +0 -426
- package/dist/rest/files.d.mts +0 -1342
- package/dist/rest/forks.d.mts +0 -2160
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -477
- package/dist/rest/queue.d.mts +0 -5917
- package/dist/rest/refs.d.mts +0 -2988
- package/dist/rest/repos.d.mts +0 -2567
- package/dist/rest/tags.d.mts +0 -1316
- package/dist/rest/tokens.d.mts +0 -2614
- package/dist/rest/topics.d.mts +0 -2224
- package/dist/rest/trees.d.mts +0 -1709
- package/dist/rest/work.d.mts +0 -1695
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
package/dist/storage/prune.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fail } from "../contracts/result.mjs";
|
|
2
2
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
3
|
+
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
3
4
|
import { rootsOf } from "../store/repo-record.mjs";
|
|
4
5
|
import { decodeRow } from "../store/errors.mjs";
|
|
5
6
|
import { WholeRepo, wholeRef } from "../store/ref-rows.mjs";
|
|
@@ -12,10 +13,12 @@ import { upkeepRuns, upkeepTooLarge } from "./memory-budget.mjs";
|
|
|
12
13
|
import { decodeRefused, refusedRead } from "./merge-fence.mjs";
|
|
13
14
|
import { decodeMerges, droppedStep, mergeKey, mergeRead, takenOf, writtenOf } from "./merge-row.mjs";
|
|
14
15
|
import { mergeInputsMost } from "./merge-most.mjs";
|
|
16
|
+
import { remapRow } from "./index-remap.mjs";
|
|
15
17
|
import { opensWithin, resumeMerge, streamMerge } from "./merge-stream.mjs";
|
|
16
18
|
import { noRows, objectKey, rowsMoved } from "./object-rows.mjs";
|
|
17
19
|
import { bitsBytes, eachHolders, hasBit, keepBitsOn, keepMergeCalls, setBit } from "./prune-keep.mjs";
|
|
18
|
-
import { WalkSaved, fits, pruneWalk, pruneWalkStartCalls, walkKeys } from "./prune-walk.mjs";
|
|
20
|
+
import { WalkSaved, fits, pruneStartsOut, pruneStartsPutCalls, pruneWalk, pruneWalkStartCalls, walkKeys } from "./prune-walk.mjs";
|
|
21
|
+
import { compareIds } from "./raw-ids.mjs";
|
|
19
22
|
import { defaultRepack, leavingRows, mergeWith, namedOf, replacing, wholeRows } from "./repack.mjs";
|
|
20
23
|
import { decodeHeld, pruneFloor, pruneWait } from "./rows.mjs";
|
|
21
24
|
import { StoredRuns, dropRuns, mergeHeld, mergeRuns } from "./runs.mjs";
|
|
@@ -75,10 +78,12 @@ const Ranks = /* @__PURE__ */ Schema.Array(Schema.Int.check(Schema.isBetween({
|
|
|
75
78
|
* on from (#2412 B2b-2): `merge` names which, the reach's bits `r`, the first holders merge
|
|
76
79
|
* `first`, the needed walk's bits `n` or the last holders merge `last`. Its object, `n` and
|
|
77
80
|
* `bytes` long, holds what the merge had found: the bits so far, the rows, the IDs a walk starts
|
|
78
|
-
* from and each wanted ID's holders. A bits merge's `places` are each of its
|
|
79
|
-
*
|
|
80
|
-
* next
|
|
81
|
-
* `fits` the last merge's flags so far.
|
|
81
|
+
* from and each wanted ID's holders. A bits merge's `places` are the rows it passed in each of its
|
|
82
|
+
* `runs`' chains, a chain's runs read as one way, `last` the ID it last visited and `ranks` each
|
|
83
|
+
* pack's next; a holders merge's `places` are each pack's next rank. `named` is the needed walk's
|
|
84
|
+
* runs' digest the `n` merge reads, and `missed` and `fits` the last merge's flags so far. A holders merge's `starts` are the runs it had put of the
|
|
85
|
+
* IDs a walk starts from, as `pruneStartsWriter` puts them: under the needed walk's scratch, so
|
|
86
|
+
* the pass's last step drops them once no mark names them (#2229).
|
|
82
87
|
*/
|
|
83
88
|
const KeepAt = /* @__PURE__ */ Schema.Struct({
|
|
84
89
|
...KeptBits.fields,
|
|
@@ -94,7 +99,8 @@ const KeepAt = /* @__PURE__ */ Schema.Struct({
|
|
|
94
99
|
ranks: Schema.optional(Ranks),
|
|
95
100
|
named: Schema.optional(Schema.String),
|
|
96
101
|
missed: Schema.optional(Schema.Boolean),
|
|
97
|
-
fits: Schema.optional(Schema.Boolean)
|
|
102
|
+
fits: Schema.optional(Schema.Boolean),
|
|
103
|
+
starts: Schema.optional(StoredRuns)
|
|
98
104
|
});
|
|
99
105
|
/**
|
|
100
106
|
* What a pass's merges found, kept on its mark when a try's calls end before its next merge
|
|
@@ -217,8 +223,8 @@ const walkPackOf = (repo, at, kind) => `p_${kind}${repo.slice(2)}${at.toString(3
|
|
|
217
223
|
const passScratch = (input, at) => Effect.map(Effect.all([dropRuns(input.bucket, walkPackOf(input.listed.repo, at, "r")), dropRuns(input.bucket, walkPackOf(input.listed.repo, at, "n"))]), (drops) => drops.includes("more") ? "more" : "done");
|
|
218
224
|
/**
|
|
219
225
|
* The bucket keys `started` names under its pass's scratch packs: each walk's runs, saved or
|
|
220
|
-
* done, its classes object
|
|
221
|
-
* takes one call.
|
|
226
|
+
* done, its classes object, its keep's objects and a stopped merge's starts' runs. Bounded by the
|
|
227
|
+
* mark's record, so a drop of them takes one call.
|
|
222
228
|
*/
|
|
223
229
|
const markKeys = (started, repo, at) => {
|
|
224
230
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -231,6 +237,7 @@ const markKeys = (started, repo, at) => {
|
|
|
231
237
|
}
|
|
232
238
|
if (started?.classes !== void 0) keys.add(classesKey(repo, at, started.classes.n));
|
|
233
239
|
for (const key of keptKeys(repo, at, started?.keep)) keys.add(key);
|
|
240
|
+
for (const key of started?.keep?.at?.starts?.keys ?? []) keys.add(key);
|
|
234
241
|
return keys;
|
|
235
242
|
};
|
|
236
243
|
/**
|
|
@@ -250,23 +257,43 @@ const reachOf = (bits, packs) => {
|
|
|
250
257
|
};
|
|
251
258
|
/**
|
|
252
259
|
* One holders merge of a keep's `packs`, as `eachHolders` charges and reads it: `visit` each ID
|
|
253
|
-
* they hold,
|
|
254
|
-
* holding is left out of, and with `going`, where it
|
|
260
|
+
* they hold, with `oidOf` encoding its hex only when needed. Answers the holders of each of
|
|
261
|
+
* `wanted` the packs hold, which no pack holding is left out of, and with `going`, where it
|
|
262
|
+
* stopped, as `mergeHolders` says. Charges `heldWantedBytes(wanted.size)` to the step's allotment
|
|
263
|
+
* before allocating the decoded wanted-ID table, releasing it when the pass ends.
|
|
255
264
|
*/
|
|
256
265
|
const heldPass = /* @__PURE__ */ Effect.fnUntraced(function* (input, packs, wanted, visit = () => void 0, going = {}) {
|
|
266
|
+
const wantBytes = heldWantedBytes(wanted.size);
|
|
267
|
+
if (wantBytes > 0) yield* Effect.acquireRelease(input.allotment.grow(wantBytes, upkeepTooLarge), () => Effect.sync(() => input.allotment.shrink(wantBytes)));
|
|
257
268
|
const found = new Map(going.from?.found);
|
|
269
|
+
const want = [];
|
|
270
|
+
for (const oid of wanted) want.push({
|
|
271
|
+
oid,
|
|
272
|
+
bytes: oidBytes(oid)
|
|
273
|
+
});
|
|
274
|
+
want.sort((a, b) => compareIds(a.bytes, 0, b.bytes, 0));
|
|
275
|
+
let wantAt = 0;
|
|
276
|
+
let currentId = /* @__PURE__ */ new Uint8Array(0);
|
|
277
|
+
let cachedOid;
|
|
278
|
+
const oidOf = () => cachedOid ??= hexOf(currentId);
|
|
258
279
|
return {
|
|
259
280
|
found,
|
|
260
281
|
stopped: (yield* eachHolders(input, packs, (id, holders) => {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
282
|
+
currentId = id;
|
|
283
|
+
cachedOid = void 0;
|
|
284
|
+
for (; wantAt < want.length && compareIds(want[wantAt].bytes, 0, id, 0) < 0;) wantAt += 1;
|
|
285
|
+
const target = want[wantAt];
|
|
286
|
+
if (target !== void 0 && compareIds(target.bytes, 0, id, 0) === 0) {
|
|
287
|
+
cachedOid = target.oid;
|
|
288
|
+
found.set(target.oid, [...holders]);
|
|
289
|
+
}
|
|
290
|
+
return visit(oidOf, holders);
|
|
264
291
|
}, {
|
|
265
292
|
from: going.from?.places,
|
|
266
293
|
goesOn: going.goesOn
|
|
267
294
|
}))?.places
|
|
268
295
|
};
|
|
269
|
-
});
|
|
296
|
+
}, Effect.scoped);
|
|
270
297
|
/**
|
|
271
298
|
* A pass's walk under `scratch`, its runs outliving the step: from where `saved` stopped, or from
|
|
272
299
|
* `start` with `known` reached already, as D2's walk carries it. A new walk, with neither, drops
|
|
@@ -384,7 +411,6 @@ const ClassesHeader = /* @__PURE__ */ Schema.fromJsonString(Schema.Struct({
|
|
|
384
411
|
}))
|
|
385
412
|
})),
|
|
386
413
|
rows: Schema.optional(Schema.Array(Hex)),
|
|
387
|
-
ids: Schema.optional(Schema.Array(Hex)),
|
|
388
414
|
held: Schema.optional(Schema.Array(Schema.Struct({
|
|
389
415
|
oid: Hex,
|
|
390
416
|
holders: Ranks
|
|
@@ -394,7 +420,7 @@ const decodeClassesHeader = /* @__PURE__ */ Schema.decodeUnknownOption(ClassesHe
|
|
|
394
420
|
const encodeClassesHeader = /* @__PURE__ */ Schema.encodeEffect(ClassesHeader);
|
|
395
421
|
/**
|
|
396
422
|
* A pass's classes object: a 4-byte header length, the header, each pack and its object count as
|
|
397
|
-
* JSON, with a keep's `rows
|
|
423
|
+
* JSON, with a keep's `rows` and `held`, then each pack's bits in its order. A try that
|
|
398
424
|
* died after its put leaves the key, and a put never replaces one, so the put deletes it first.
|
|
399
425
|
* The header is charged to the step's allotment while it's put, as the bits are, so a stopped
|
|
400
426
|
* merge's lists past it refuse the step too large, before the put. It returns the object's length.
|
|
@@ -411,7 +437,6 @@ const putClasses = /* @__PURE__ */ Effect.fnUntraced(function* (input, key, pack
|
|
|
411
437
|
const text = yield* Effect.orDie(encodeClassesHeader({
|
|
412
438
|
packs: listed,
|
|
413
439
|
rows: lists.rows,
|
|
414
|
-
ids: lists.ids,
|
|
415
440
|
held
|
|
416
441
|
}));
|
|
417
442
|
const header = new TextEncoder().encode(text);
|
|
@@ -435,7 +460,7 @@ const putClasses = /* @__PURE__ */ Effect.fnUntraced(function* (input, key, pack
|
|
|
435
460
|
* again, and `DATA_LOSS` when it's broken or isn't `bytes` long.
|
|
436
461
|
*/
|
|
437
462
|
const readBits = (input, key, most) => Effect.map(readKept(input, key, most), (kept) => kept?.bits);
|
|
438
|
-
/** The object at `key` as `readBits` reads it, with a stopped merge's `
|
|
463
|
+
/** The object at `key` as `readBits` reads it, with a stopped merge's `held` too. */
|
|
439
464
|
const readKept = /* @__PURE__ */ Effect.fnUntraced(function* (input, key, most) {
|
|
440
465
|
yield* Effect.acquireRelease(input.allotment.grow(most, upkeepTooLarge), () => Effect.sync(() => input.allotment.shrink(most)));
|
|
441
466
|
const bytes = yield* readWhole(input.bucket, key);
|
|
@@ -472,7 +497,6 @@ const readKept = /* @__PURE__ */ Effect.fnUntraced(function* (input, key, most)
|
|
|
472
497
|
packs,
|
|
473
498
|
rows: new Set(header.value.rows)
|
|
474
499
|
},
|
|
475
|
-
ids: header.value.ids ?? [],
|
|
476
500
|
held
|
|
477
501
|
};
|
|
478
502
|
});
|
|
@@ -497,20 +521,35 @@ const keptKeys = (repo, at, keep) => [
|
|
|
497
521
|
const keptPutCalls = (input, counts, rows, listed = 0) => 1 + sizedPutCalls(input.bucket.multipart, 68 + counts.length * 64 + rows * 43 + listed + counts.reduce((sum, count) => sum + bitsBytes(count), 0));
|
|
498
522
|
/** The most header bytes a stopped holders merge's `held` takes: an ID's and each pack's ranks. */
|
|
499
523
|
const heldBytes = (wanted, packs) => wanted * (52 + packs * 24);
|
|
524
|
+
/**
|
|
525
|
+
* What `heldPass`'s decoded wanted-ID table holds per entry while its holders merge runs: 20 bytes
|
|
526
|
+
* for the decoded ID, 148 bytes for the V8 `Uint8Array` and `{ oid, bytes }` entry overhead, and
|
|
527
|
+
* 24 bytes for the array and V8's two TimSort work arrays.
|
|
528
|
+
*/
|
|
529
|
+
const wantedEntryBytes = 192;
|
|
530
|
+
/** What `heldPass`'s decoded wanted-ID table holds for `wanted` IDs, charged to the step's allotment. */
|
|
531
|
+
const heldWantedBytes = (wanted) => wanted * wantedEntryBytes;
|
|
500
532
|
/** How many of `bits`' bits are set. */
|
|
501
533
|
const setCount = (bits) => {
|
|
502
534
|
let count = 0;
|
|
503
535
|
for (const byte of bits) for (let rest = byte; rest !== 0; rest &= rest - 1) count += 1;
|
|
504
536
|
return count;
|
|
505
537
|
};
|
|
506
|
-
/**
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
538
|
+
/**
|
|
539
|
+
* `runs` as the mark stores them: a narrowed merge's runs are put, never held, and their chains
|
|
540
|
+
* kept, since a stopped merge's places are its chains' (#2690).
|
|
541
|
+
*/
|
|
542
|
+
const storedRuns = ({ kind, width, keys, lengths, rows, chains }) => {
|
|
543
|
+
const stored = {
|
|
544
|
+
kind,
|
|
545
|
+
width,
|
|
546
|
+
keys,
|
|
547
|
+
lengths,
|
|
548
|
+
rows
|
|
549
|
+
};
|
|
550
|
+
if (chains !== void 0) stored.chains = chains;
|
|
551
|
+
return stored;
|
|
552
|
+
};
|
|
514
553
|
/**
|
|
515
554
|
* The digest a pass's keep holds over, as `PassKeep.over` says: the listed packs, the young, old
|
|
516
555
|
* and fenced among them, the reads' `digest`, the prune merge under way and the `r` walk's runs.
|
|
@@ -648,9 +687,11 @@ const keptListing = (read, seen, rows, landed) => Effect.fnUntraced(function* (i
|
|
|
648
687
|
* the most that open within a fresh try, as `opensWithin` says, but at least one, which
|
|
649
688
|
* `streamMerge` fences as `open-past-try` when it opens past one alone, so the next read leaves it
|
|
650
689
|
* out of the classes (#1663): choose keeps each object at a set bit, and `listing` lists what
|
|
651
|
-
* it wrote.
|
|
690
|
+
* it wrote. Its row names `classes`, the number of the classes object `bits` came from. With
|
|
691
|
+
* `remap`, a rewrite's, the merge lays the index row again over its pack, what it dropped left out,
|
|
692
|
+
* when it fits one try.
|
|
652
693
|
*/
|
|
653
|
-
const classMerge = (input, read, bits, most, calls, listing) => {
|
|
694
|
+
const classMerge = (input, read, bits, most, calls, listing, classes, remap) => {
|
|
654
695
|
const byPack = new Map(bits.map((each) => [each.pack, each.bits]));
|
|
655
696
|
const named = input.listed.packs.filter((pack) => byPack.has(pack.id));
|
|
656
697
|
const isOld = (pack) => cruftOf(read, pack) !== void 0;
|
|
@@ -668,7 +709,9 @@ const classMerge = (input, read, bits, most, calls, listing) => {
|
|
|
668
709
|
calls,
|
|
669
710
|
owner: "prune",
|
|
670
711
|
keep,
|
|
671
|
-
|
|
712
|
+
classes,
|
|
713
|
+
listing,
|
|
714
|
+
remap
|
|
672
715
|
}, input.at);
|
|
673
716
|
};
|
|
674
717
|
/**
|
|
@@ -719,9 +762,11 @@ const rowsStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, rows, keep,
|
|
|
719
762
|
* The step that unlists each pack of `emptied`, whose every object the pass drops, with no merge:
|
|
720
763
|
* each a `leaving` row, and an old cruft pack's `cruft` row ended, so the step `drops`. It makes
|
|
721
764
|
* the `repack` row due, whose clean-up deletes the packs' bytes once their rows are, so on a repo
|
|
722
|
-
* that takes no push they don't wait for the row's next run.
|
|
765
|
+
* that takes no push they don't wait for the row's next run. With `remap`, the index row is laid
|
|
766
|
+
* again over what's left, the emptied packs' positions gone and nothing merged in, so reads keep
|
|
767
|
+
* their bitmaps across the step rather than walk until the rebuild it would save (#2197).
|
|
723
768
|
*/
|
|
724
|
-
const emptiedStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, emptied) {
|
|
769
|
+
const emptiedStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, emptied, remap) {
|
|
725
770
|
const ids = new Set(emptied.map((each) => each.pack));
|
|
726
771
|
const removed = yield* Effect.forEach(input.listed.packs.filter((pack) => ids.has(pack.id)), namedOf);
|
|
727
772
|
const dropped = removed.filter((pack) => read.cruft.has(pack.id));
|
|
@@ -736,6 +781,16 @@ const emptiedStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, em
|
|
|
736
781
|
repack: input.at
|
|
737
782
|
};
|
|
738
783
|
if (dropped.length > 0) step.drops = true;
|
|
784
|
+
const index = remap === void 0 ? void 0 : yield* remapRow(remap, {
|
|
785
|
+
bucket: input.bucket,
|
|
786
|
+
listed: input.listed,
|
|
787
|
+
merged: { kind: "emptied" },
|
|
788
|
+
taken: ids,
|
|
789
|
+
folded: [],
|
|
790
|
+
keeps: () => false,
|
|
791
|
+
at: input.at
|
|
792
|
+
});
|
|
793
|
+
if (index !== void 0) step.index = index;
|
|
739
794
|
return step;
|
|
740
795
|
});
|
|
741
796
|
/** A mark at `started`'s start, with its `periods`, if any: what each new mark of the pass keeps. */
|
|
@@ -802,7 +857,7 @@ const remarked = (started, patch) => {
|
|
|
802
857
|
* With `calls`, a merge past what the try has left, after one it ran, ends the step with what
|
|
803
858
|
* they found on the mark's `keep`, which `keeping` hands `pruneStep` when the step lets it go.
|
|
804
859
|
*/
|
|
805
|
-
const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, packs, objectRows, most, calls, keeping) {
|
|
860
|
+
const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, packs, objectRows, most, calls, keeping, remap) {
|
|
806
861
|
const rows = yield* wholeRows(objectRows);
|
|
807
862
|
const rowOids = rows.map((row) => row.oid);
|
|
808
863
|
const at = read.started?.at ?? input.at;
|
|
@@ -871,10 +926,26 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
871
926
|
step: droppedStep(merge),
|
|
872
927
|
mark: { classes: void 0 }
|
|
873
928
|
};
|
|
874
|
-
if (classes.kind === "cruft" || merge.value.pass !== "commit" || seenHolds(classes))
|
|
929
|
+
if (classes.kind === "cruft" || merge.value.pass !== "commit" || seenHolds(classes)) {
|
|
930
|
+
const resume = classes.kind === "cruft" ? {
|
|
931
|
+
most,
|
|
932
|
+
calls,
|
|
933
|
+
listing: listingOf(classes)
|
|
934
|
+
} : {
|
|
935
|
+
most,
|
|
936
|
+
calls,
|
|
937
|
+
listing: listingOf(classes),
|
|
938
|
+
remap,
|
|
939
|
+
keep: {
|
|
940
|
+
classes: classes.n,
|
|
941
|
+
read: readClasses(input, classesKey(input.listed.repo, at, classes.n), classes.bytes)
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
return went(yield* resumeMerge(input, merge, resume), classes.kind);
|
|
945
|
+
}
|
|
875
946
|
}
|
|
876
947
|
const chosen = merge === void 0 && classes !== void 0 && (classes.kind === "cruft" ? sameIds(classes.packs, ids) : seenHolds(classes)) ? yield* readClasses(input, classesKey(input.listed.repo, at, classes.n), classes.bytes) : void 0;
|
|
877
|
-
if (chosen !== void 0 && classes !== void 0 && !chosen.some((each) => youngIds.has(each.pack))) return went(yield* classMerge(input, read, chosen, most, calls, listingOf(classes)), classes.kind);
|
|
948
|
+
if (chosen !== void 0 && classes !== void 0 && !chosen.some((each) => youngIds.has(each.pack))) return went(yield* classMerge(input, read, chosen, most, calls, listingOf(classes), classes.n, classes.kind === "kept" ? remap : void 0), classes.kind);
|
|
878
949
|
const reachedRuns = carry.done;
|
|
879
950
|
const oldIds = new Set(packs.old.map((pack) => pack.id));
|
|
880
951
|
const fencedIds = new Set(packs.fenced.map((pack) => pack.id));
|
|
@@ -984,7 +1055,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
984
1055
|
});
|
|
985
1056
|
}
|
|
986
1057
|
const pass = (wanted, visit, going) => heldPass(input, sides, wanted, visit, going);
|
|
987
|
-
const holdersFrom = Effect.fnUntraced(function* (kept, classes
|
|
1058
|
+
const holdersFrom = Effect.fnUntraced(function* (kept, classes) {
|
|
988
1059
|
if (kept === void 0) return void 0;
|
|
989
1060
|
return yield* Effect.scoped(Effect.gen(function* () {
|
|
990
1061
|
const read = yield* readPartial(kept);
|
|
@@ -995,10 +1066,10 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
995
1066
|
into.bits.set(each.bits);
|
|
996
1067
|
into.set = setCount(each.bits);
|
|
997
1068
|
}
|
|
998
|
-
ids.push(...read.ids);
|
|
999
1069
|
return {
|
|
1000
1070
|
places: kept.places,
|
|
1001
|
-
found: read.held
|
|
1071
|
+
found: read.held,
|
|
1072
|
+
starts: kept.starts
|
|
1002
1073
|
};
|
|
1003
1074
|
}));
|
|
1004
1075
|
});
|
|
@@ -1012,49 +1083,63 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
1012
1083
|
const set = reachedBits[pack];
|
|
1013
1084
|
return set !== void 0 && hasBit(set, rank);
|
|
1014
1085
|
};
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1017
|
-
|
|
1086
|
+
const reachedByBit = (byPack, holders) => {
|
|
1087
|
+
const first = holders[0];
|
|
1088
|
+
if (first === void 0) return false;
|
|
1089
|
+
const set = byPack[first.pack];
|
|
1090
|
+
return set === void 0 || hasBit(set, first.rank);
|
|
1091
|
+
};
|
|
1092
|
+
const reachedLazy = (oidOf, holders) => reachedByBit(reachedBits, holders) || bits.rows.size > 0 && bits.rows.has(oidOf());
|
|
1093
|
+
const reachedAt = (oidOf, holder) => reachedBits[holder.pack] === void 0 || ownBit(holder) || bits.rows.size > 0 && bits.rows.has(oidOf());
|
|
1094
|
+
const starts = (oidOf, holders) => packs.old.length > 0 && !reachedLazy(oidOf, holders) && holders.some(({ pack }) => isOld[pack] !== true || isFenced[pack] === true);
|
|
1095
|
+
const startsRow = (oid, holders) => packs.old.length > 0 && !reached(oid, holders) && !starts(() => oid, holders);
|
|
1018
1096
|
const keptFirst = packs.old.length > 0 && neededCarry === void 0 ? void 0 : prior.keep?.first;
|
|
1019
1097
|
const sideCounts = sides.map((pack) => pack.objects);
|
|
1020
1098
|
const walkStart = pruneWalkStartCalls(input.listed.packs.reduce((sum, pack) => sum + pack.objects, 0) + rows.length, sideCounts.reduce((sum, count) => sum + count, 0) + rows.length + refs.length);
|
|
1021
1099
|
const holdersCalls = keepMergeCalls(input, sides) + keptPutCalls(input, sideCounts, 0);
|
|
1022
1100
|
if (keptFirst === void 0 && !goesOn(holdersCalls + walkStart)) return yield* stopped;
|
|
1023
|
-
const
|
|
1101
|
+
const named = walkPackOf(input.listed.repo, at, "n");
|
|
1102
|
+
const startsOut = (before, writes = true) => pruneStartsOut(input.allotment, input.bucket, named, before, writes);
|
|
1103
|
+
const startsPuts = 2 * pruneStartsPutCalls(input.bucket.multipart);
|
|
1104
|
+
const none = { start: void 0 };
|
|
1024
1105
|
ran ||= keptFirst === void 0;
|
|
1025
1106
|
const first = keptFirst !== void 0 ? none : yield* Effect.scoped(Effect.gen(function* () {
|
|
1026
1107
|
const fresh = sides.flatMap((_, at) => isFresh[at] === true ? [at] : []);
|
|
1027
1108
|
const cruft = merge === void 0 ? yield* classBitsOf(input, sides, fresh) : void 0;
|
|
1028
|
-
const start = [];
|
|
1029
1109
|
const wanted = /* @__PURE__ */ new Set([...rowSet, ...refs]);
|
|
1030
1110
|
const cruftCounts = classPacks(cruft).map((each) => each.count);
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1111
|
+
const from = yield* holdersFrom(partialOf("first"), cruft);
|
|
1112
|
+
const out = yield* startsOut(from?.starts);
|
|
1113
|
+
const passed = yield* pass(wanted, (oidOf, holders) => {
|
|
1114
|
+
const wrote = starts(oidOf, holders) ? out.add(oidOf()) : void 0;
|
|
1115
|
+
if (cruft !== void 0 && !apart(holders)) {
|
|
1116
|
+
for (const holder of holders) if (!reachedAt(oidOf, holder)) setClass(cruft, holder);
|
|
1117
|
+
}
|
|
1118
|
+
return wrote;
|
|
1035
1119
|
}, {
|
|
1036
|
-
from
|
|
1037
|
-
goesOn: goesOnIn(() => keptPutCalls(input, cruftCounts,
|
|
1120
|
+
from,
|
|
1121
|
+
goesOn: goesOnIn(() => keptPutCalls(input, cruftCounts, 0, heldBytes(wanted.size, sides.length)) + startsPuts + walkStart)
|
|
1038
1122
|
});
|
|
1039
|
-
if (passed.stopped !== void 0)
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1123
|
+
if (passed.stopped !== void 0) {
|
|
1124
|
+
const written = yield* out.finish;
|
|
1125
|
+
return { stopped: yield* stoppedAt({
|
|
1126
|
+
merge: "first",
|
|
1127
|
+
places: passed.stopped,
|
|
1128
|
+
starts: written
|
|
1129
|
+
}, classPacks(cruft), { held: passed.found }) };
|
|
1130
|
+
}
|
|
1046
1131
|
const rowsBy = passed.found;
|
|
1047
1132
|
const caught = refs.filter((oid) => !reached(oid, rowsBy.get(oid) ?? []));
|
|
1048
1133
|
if (caught.length > 0) return { caught };
|
|
1049
|
-
|
|
1050
|
-
if (cruft === void 0) return { start };
|
|
1134
|
+
for (const oid of rowOids) if (startsRow(oid, rowsBy.get(oid) ?? [])) yield* out.add(oid);
|
|
1135
|
+
if (cruft === void 0) return { start: yield* out.finish };
|
|
1051
1136
|
const cruftRows = rows.filter((row) => {
|
|
1052
1137
|
const holders = rowsBy.get(row.oid) ?? [];
|
|
1053
1138
|
return !reached(row.oid, holders) && !apart(holders);
|
|
1054
1139
|
});
|
|
1055
1140
|
if (cruftRows.length > 0) return { cruft: yield* rowsCruft(input, cruftRows, most) };
|
|
1056
1141
|
const copies = [...cruft.values()].filter((each) => each.set > 0);
|
|
1057
|
-
if (copies.length === 0) return { start };
|
|
1142
|
+
if (copies.length === 0) return { start: yield* out.finish };
|
|
1058
1143
|
const n = (classes?.n ?? -1) + 1;
|
|
1059
1144
|
const bytes = yield* putClasses(input, classesKey(input.listed.repo, at, n), copies);
|
|
1060
1145
|
return { classes: {
|
|
@@ -1090,12 +1175,11 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
1090
1175
|
},
|
|
1091
1176
|
mark: { classes: first.classes }
|
|
1092
1177
|
};
|
|
1093
|
-
const startsAny = keptFirst?.starts ?? first.start
|
|
1178
|
+
const startsAny = keptFirst?.starts ?? (first.start?.rows ?? 0) > 0;
|
|
1094
1179
|
keepNow.first = { starts: startsAny };
|
|
1095
|
-
const named = walkPackOf(input.listed.repo, at, "n");
|
|
1096
1180
|
if (packs.old.length > 0 && (neededCarry === void 0 || "saved" in neededCarry)) {
|
|
1097
1181
|
const keep = calls === void 0 ? void 0 : yield* saved(["r"]);
|
|
1098
|
-
const start = neededCarry === void 0 ? first.start : [];
|
|
1182
|
+
const start = (neededCarry === void 0 ? first.start : void 0) ?? [];
|
|
1099
1183
|
const walked = yield* walkOn(input, named, start, rows, () => void 0, calls, roots, {
|
|
1100
1184
|
saved: neededCarry?.saved,
|
|
1101
1185
|
known: neededCarry === void 0 ? reachedRuns : void 0,
|
|
@@ -1126,7 +1210,10 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
1126
1210
|
});
|
|
1127
1211
|
}
|
|
1128
1212
|
const needed = neededRuns === void 0 ? () => false : reachOf(neededRuns, sides);
|
|
1213
|
+
const neededBits = neededRuns === void 0 ? void 0 : sides.map((pack) => neededRuns.packs.find((each) => each.pack === pack.id)?.bits);
|
|
1214
|
+
const neededLazy = (oidOf, holders) => neededBits !== void 0 && (reachedByBit(neededBits, holders) || neededRuns !== void 0 && neededRuns.rows.size > 0 && neededRuns.rows.has(oidOf()));
|
|
1129
1215
|
const keep = (oid, holders) => reached(oid, holders) || !apart(holders) && (inFresh(holders) || rowSet.has(oid) || needed(oid, holders));
|
|
1216
|
+
const keepLazy = (oidOf, holders) => reachedLazy(oidOf, holders) || !apart(holders) && (inFresh(holders) || rowSet.size > 0 && rowSet.has(oidOf()) || neededLazy(oidOf, holders));
|
|
1130
1217
|
const moved = merge !== void 0 && classes !== void 0 ? merge : void 0;
|
|
1131
1218
|
const before = moved === void 0 || classes === void 0 ? void 0 : yield* readClasses(input, classesKey(input.listed.repo, at, classes.n), classes.bytes);
|
|
1132
1219
|
const byPack = new Map((before ?? []).map((each) => [each.pack, each.bits]));
|
|
@@ -1143,46 +1230,47 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
1143
1230
|
const isOutside = (holders) => holders.some(({ pack }) => outside[pack] === true);
|
|
1144
1231
|
const whole = (oid, holders) => keep(oid, holders) || holders.some(({ pack }) => isFenced[pack] === true);
|
|
1145
1232
|
if (!goesOn(holdersCalls + walkStart)) return yield* stopped;
|
|
1146
|
-
const behind = [];
|
|
1147
1233
|
const behindOf = neededRuns !== void 0 && startsAny;
|
|
1148
1234
|
const lastAt = partialOf("last");
|
|
1235
|
+
const from = yield* holdersFrom(lastAt, kept);
|
|
1236
|
+
const behind = yield* startsOut(from?.starts, behindOf);
|
|
1149
1237
|
let missed = lastAt?.missed ?? false;
|
|
1150
1238
|
let markFits = lastAt?.fits ?? true;
|
|
1151
1239
|
const wanted = /* @__PURE__ */ new Set([...rowSet, ...bits.rows]);
|
|
1152
1240
|
const keptCounts = classPacks(kept).map((each) => each.count);
|
|
1153
|
-
const passed = yield* pass(wanted, (
|
|
1154
|
-
|
|
1155
|
-
const keeps =
|
|
1241
|
+
const passed = yield* pass(wanted, (oidOf, holders) => {
|
|
1242
|
+
const wrote = behindOf && starts(oidOf, holders) && !neededLazy(oidOf, holders) ? behind.add(oidOf()) : void 0;
|
|
1243
|
+
const keeps = keepLazy(oidOf, holders);
|
|
1156
1244
|
if (moved !== void 0) {
|
|
1157
1245
|
missed ||= keeps && holders.some(unclassed);
|
|
1158
|
-
return;
|
|
1246
|
+
return wrote;
|
|
1159
1247
|
}
|
|
1160
1248
|
for (const holder of holders) if (keeps || ownBit(holder)) setClass(kept, holder);
|
|
1161
|
-
if (!markFits) return;
|
|
1249
|
+
if (!markFits) return wrote;
|
|
1162
1250
|
const wholly = keeps || holders.some(({ pack }) => isFenced[pack] === true);
|
|
1163
|
-
if (isOutside(holders) && wholly && !
|
|
1164
|
-
if (holders.some(ownBit) && !(wholly && (
|
|
1251
|
+
if (isOutside(holders) && wholly && !reachedLazy(oidOf, holders)) markFits = false;
|
|
1252
|
+
if (holders.some(ownBit) && !(wholly && (isOutside(holders) || rowSet.size > 0 && rowSet.has(oidOf())))) markFits = false;
|
|
1253
|
+
return wrote;
|
|
1165
1254
|
}, {
|
|
1166
|
-
from
|
|
1167
|
-
goesOn: goesOnIn(() => keptPutCalls(input, keptCounts,
|
|
1255
|
+
from,
|
|
1256
|
+
goesOn: goesOnIn(() => keptPutCalls(input, keptCounts, 0, heldBytes(wanted.size, sides.length)) + startsPuts + walkStart)
|
|
1168
1257
|
});
|
|
1169
1258
|
if (passed.stopped !== void 0) return yield* stoppedAt({
|
|
1170
1259
|
merge: "last",
|
|
1171
1260
|
places: passed.stopped,
|
|
1172
1261
|
missed,
|
|
1173
|
-
fits: markFits
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
held: passed.found
|
|
1177
|
-
});
|
|
1262
|
+
fits: markFits,
|
|
1263
|
+
starts: yield* behind.finish
|
|
1264
|
+
}, classPacks(kept), { held: passed.found });
|
|
1178
1265
|
const rowsBy = passed.found;
|
|
1179
|
-
if (behindOf)
|
|
1266
|
+
if (behindOf) for (const oid of rowOids) {
|
|
1180
1267
|
const holders = rowsBy.get(oid) ?? [];
|
|
1181
|
-
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1268
|
+
if (startsRow(oid, holders) && !needed(oid, holders)) yield* behind.add(oid);
|
|
1269
|
+
}
|
|
1270
|
+
const behindRuns = yield* behind.finish;
|
|
1271
|
+
if (neededDone !== void 0 && behindRuns.rows > 0) {
|
|
1184
1272
|
const keep = calls === void 0 ? void 0 : yield* saved(["r"]);
|
|
1185
|
-
const walked = yield* walkOn(input, named,
|
|
1273
|
+
const walked = yield* walkOn(input, named, behindRuns, rows, () => void 0, calls, roots, {
|
|
1186
1274
|
known: neededDone,
|
|
1187
1275
|
spent: ran
|
|
1188
1276
|
});
|
|
@@ -1197,7 +1285,17 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
1197
1285
|
reads: digest,
|
|
1198
1286
|
packs: ids
|
|
1199
1287
|
}, rowOids, landed);
|
|
1200
|
-
|
|
1288
|
+
const keep = classes?.kind === "kept" ? {
|
|
1289
|
+
classes: classes.n,
|
|
1290
|
+
read: Effect.succeed(before)
|
|
1291
|
+
} : void 0;
|
|
1292
|
+
return went(yield* resumeMerge(input, moved, {
|
|
1293
|
+
most,
|
|
1294
|
+
calls,
|
|
1295
|
+
listing,
|
|
1296
|
+
remap,
|
|
1297
|
+
keep
|
|
1298
|
+
}), "kept");
|
|
1201
1299
|
}
|
|
1202
1300
|
if (redos + 1 >= 3) return {
|
|
1203
1301
|
waits: `pushes moved its refs onto what its rewrite was about to drop, 3 times in a row`,
|
|
@@ -1215,7 +1313,7 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
1215
1313
|
if (rows.some((row) => !rowKeep(row.oid))) return yield* rowsStep(input, rows, rowKeep, most);
|
|
1216
1314
|
const rewrites = [...kept.values()].filter((each) => oldIds.has(each.pack) || each.set < each.count);
|
|
1217
1315
|
const emptied = rewrites.filter((each) => each.set === 0);
|
|
1218
|
-
if (emptied.length > 0) return { step: yield* emptiedStep(input, read, emptied) };
|
|
1316
|
+
if (emptied.length > 0) return { step: yield* emptiedStep(input, read, emptied, remap) };
|
|
1219
1317
|
if (rewrites.length > 0) {
|
|
1220
1318
|
const n = (classes?.n ?? -1) + 1;
|
|
1221
1319
|
const value = {
|
|
@@ -1296,6 +1394,11 @@ const passDue = (input, prune, read, objectRows) => {
|
|
|
1296
1394
|
};
|
|
1297
1395
|
};
|
|
1298
1396
|
/**
|
|
1397
|
+
* Whether a pass due now would put its row alone, with no walk: the repo's mark holds, so every
|
|
1398
|
+
* object outside cruft is one a ref reaches, and no cruft is listed or merge under way.
|
|
1399
|
+
*/
|
|
1400
|
+
const passAlone = (read) => markHolds(read.mark) && read.cruft.size === 0 && read.merges.prune === void 0;
|
|
1401
|
+
/**
|
|
1299
1402
|
* Upkeep's prune, as Q270 says: a pass at most once each `prune`, or each hour while the repo's
|
|
1300
1403
|
* `ReachedMark` doesn't hold, and at once after a newer clear; while it holds with no cruft listed,
|
|
1301
1404
|
* just the pass's row with no walk. A pass walks to sorted runs whatever the repo's count, and is
|
|
@@ -1314,7 +1417,7 @@ const passDue = (input, prune, read, objectRows) => {
|
|
|
1314
1417
|
* held it, as every wait for anything but pushes does. `step` is `undefined` when no pass is
|
|
1315
1418
|
* due; `next` is when the next one is, and `undefined` for a repo that holds no object.
|
|
1316
1419
|
*/
|
|
1317
|
-
const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, repack, read, objectRows, drops, holds, retried = false, calls) {
|
|
1420
|
+
const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, repack, read, objectRows, drops, holds, retried = false, calls, remap) {
|
|
1318
1421
|
const due = passDue(input, prune, read, objectRows);
|
|
1319
1422
|
if (due === void 0) return {
|
|
1320
1423
|
step: void 0,
|
|
@@ -1326,7 +1429,6 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
1326
1429
|
next
|
|
1327
1430
|
};
|
|
1328
1431
|
const last = read.pass?.at;
|
|
1329
|
-
const markHeld = markHolds(read.mark);
|
|
1330
1432
|
const merge = read.merges.prune;
|
|
1331
1433
|
const uncounted = countEnded(read);
|
|
1332
1434
|
const waitsElse = (step) => uncounted === void 0 ? step : alsoPuts(step, uncounted);
|
|
@@ -1346,7 +1448,7 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
1346
1448
|
},
|
|
1347
1449
|
next
|
|
1348
1450
|
};
|
|
1349
|
-
if (
|
|
1451
|
+
if (passAlone(read)) return {
|
|
1350
1452
|
step: {
|
|
1351
1453
|
change: {
|
|
1352
1454
|
put: [{
|
|
@@ -1355,9 +1457,10 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
1355
1457
|
}],
|
|
1356
1458
|
rows: noRows
|
|
1357
1459
|
},
|
|
1358
|
-
more:
|
|
1460
|
+
more: false
|
|
1359
1461
|
},
|
|
1360
|
-
next: input.at + pruneWait(prune)
|
|
1462
|
+
next: input.at + pruneWait(prune),
|
|
1463
|
+
alone: true
|
|
1361
1464
|
};
|
|
1362
1465
|
const most = (repack === false ? void 0 : repack.maxPackSize) ?? defaultRepack.maxPackSize;
|
|
1363
1466
|
const until = input.at + pruneWait(prune);
|
|
@@ -1434,7 +1537,7 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
1434
1537
|
changed: false,
|
|
1435
1538
|
keep: void 0
|
|
1436
1539
|
};
|
|
1437
|
-
const stepped = yield* passSteps(input, read, packs, rows, most, calls, keeping).pipe(Effect.catchTag("PruneWalkTooLarge", (refused) => fail("RESOURCE_EXHAUSTED", `The prune pass is past what one walk holds: ${refused.message}`, { context: { reason: "prune-walk-too-large" } })));
|
|
1540
|
+
const stepped = yield* passSteps(input, read, packs, rows, most, calls, keeping, remap).pipe(Effect.catchTag("PruneWalkTooLarge", (refused) => fail("RESOURCE_EXHAUSTED", `The prune pass is past what one walk holds: ${refused.message}`, { context: { reason: "prune-walk-too-large" } })));
|
|
1438
1541
|
if ("waits" in stepped) return yield* waits(stepped.waits, "busy" in stepped);
|
|
1439
1542
|
const { change } = stepped.step;
|
|
1440
1543
|
const marked = "mark" in stepped ? stepped.mark : void 0;
|
|
@@ -1476,4 +1579,4 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
1476
1579
|
next
|
|
1477
1580
|
};
|
|
1478
1581
|
});
|
|
1479
|
-
export { CruftRow, PassClasses, PassKeep, PruneCleared, PrunePass, PruneStarted, cruftOf, mergesAlone, passDue, passScratch, pruneClearedKey, prunePassKey, pruneStartedKey, pruneStep, reachOf, reachesOnly, readPrune, walkPackOf };
|
|
1582
|
+
export { CruftRow, PassClasses, PassKeep, PruneCleared, PrunePass, PruneStarted, cruftOf, heldWantedBytes, mergesAlone, passAlone, passDue, passScratch, pruneClearedKey, prunePassKey, pruneStartedKey, pruneStep, reachOf, reachesOnly, readPrune, walkPackOf };
|