@ref0/git 0.12.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/access/private-refs.mjs +3 -3
- package/dist/auth/access-jwt.mjs +2 -2
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +4 -20
- 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/helpers.mjs +3 -11
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- 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 -28
- package/dist/auth/tokens-layer.mjs +6 -12
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -17
- package/dist/auth/tokens.mjs +9 -87
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +35 -11
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +39 -12
- package/dist/client/remote.mjs +95 -31
- 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/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +57 -10
- 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 +23 -19
- package/dist/contracts/commits.d.mts +34 -26
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +12 -12
- package/dist/contracts/forks.d.mts +27 -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 +39 -7
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -9
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +103 -35
- package/dist/contracts/operations.d.mts +3 -0
- package/dist/contracts/operations.mjs +12 -2
- package/dist/contracts/push-uploads.d.mts +44 -5
- package/dist/contracts/push-uploads.mjs +7 -3
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +50 -25
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +5 -4
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +106 -127
- package/dist/contracts/repos.mjs +33 -4
- package/dist/contracts/result.d.mts +49 -25
- package/dist/contracts/result.mjs +52 -11
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +37 -111
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +90 -26
- package/dist/contracts/sync.mjs +45 -11
- 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 -22
- package/dist/contracts/tokens.mjs +3 -3
- package/dist/contracts/topics.d.mts +1 -6
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +87 -12
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +46 -13
- package/dist/core/ancestry.d.mts +10 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +43 -5
- package/dist/core/call-names.mjs +7 -1
- package/dist/core/call-services.mjs +13 -4
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +48 -33
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +931 -435
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +159 -15
- package/dist/core/index-job.mjs +128 -37
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/commits.mjs +16 -6
- 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 +10 -6
- package/dist/core/parts.mjs +3 -11
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +316 -42
- package/dist/core/push-decide.mjs +3 -1
- package/dist/core/push-files.d.mts +12 -0
- package/dist/core/push-files.mjs +225 -0
- package/dist/core/push-repo.d.mts +8 -0
- package/dist/core/push-repo.mjs +56 -0
- package/dist/core/push.d.mts +17 -0
- package/dist/core/push.mjs +153 -70
- package/dist/core/receipts.mjs +34 -13
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +61 -7
- package/dist/core/refs.mjs +18 -13
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +46 -28
- package/dist/core/repo-info.mjs +19 -12
- package/dist/core/repos.mjs +50 -22
- 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.d.mts +6 -0
- package/dist/core/view.mjs +51 -26
- package/dist/core/work.mjs +105 -35
- package/dist/effect.d.mts +5 -12
- package/dist/effect.mjs +3 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +17 -10
- package/dist/engine/walk.mjs +4 -4
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +3 -3
- package/dist/event-streams/stream.mjs +38 -15
- package/dist/extend.d.mts +4 -5
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +12 -7
- package/dist/http/core-parts.mjs +129 -64
- package/dist/http/handler.mjs +36 -9
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +61 -31
- package/dist/http/parts.d.mts +2 -0
- package/dist/http/push-upload-job.mjs +507 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +142 -69
- package/dist/http/upload-pack.mjs +10 -9
- package/dist/index.d.mts +27 -28
- package/dist/index.mjs +5 -8
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +9 -3
- package/dist/lfs/base.mjs +27 -2
- package/dist/lfs/copy.d.mts +60 -0
- package/dist/lfs/copy.mjs +109 -0
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +28 -13
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +7 -0
- package/dist/lfs/objects.mjs +152 -55
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +3 -3
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
- package/dist/protocol/bytes/sha256.d.mts +32 -0
- package/dist/protocol/bytes/sha256.mjs +105 -49
- package/dist/protocol/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/protocol/wire/advertisement.mjs +9 -4
- package/dist/protocol/wire/lines.d.mts +4 -2
- package/dist/protocol/wire/lines.mjs +11 -5
- package/dist/protocol/wire/push-uploads.mjs +13 -1
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/protocol.d.mts +3 -1
- package/dist/protocol.mjs +3 -1
- package/dist/queue/advance.mjs +22 -25
- 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 +2 -22
- package/dist/queue/host.mjs +2 -13
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +11 -4
- 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 +6 -4
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4231
- package/dist/rest/caller.mjs +5 -1
- package/dist/rest/client.d.mts +15 -5
- package/dist/rest/client.mjs +23 -2
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.mjs +68 -9
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +7 -13
- package/dist/rest/me.d.mts +3 -428
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/work.mjs +8 -0
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +14 -15
- package/dist/server/edge-node.mjs +12 -12
- 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 +6 -11
- package/dist/server/git-layer.mjs +29 -23
- package/dist/server/git-namespace.d.mts +5 -4
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +21 -40
- package/dist/server/joined.mjs +11 -62
- package/dist/server/lifecycle.mjs +65 -69
- package/dist/server/registry.mjs +28 -3
- package/dist/server/server.mjs +245 -465
- 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/{core/purge.d.mts → storage/batches.d.mts} +4 -4
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/budget.mjs +2 -2
- 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 +85 -19
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +298 -216
- package/dist/storage/file-limits.mjs +24 -0
- 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 +1 -1
- package/dist/storage/index-build.mjs +185 -84
- package/dist/storage/index-fetch.mjs +128 -74
- 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-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +208 -65
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +214 -67
- package/dist/storage/memory-budget.mjs +44 -8
- 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 +165 -49
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +85 -27
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +172 -86
- 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 +299 -37
- package/dist/storage/prune-walk.mjs +240 -62
- package/dist/storage/prune.mjs +749 -213
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +40 -16
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/quarantine.mjs +9 -9
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +55 -25
- package/dist/storage/receive-bounds.mjs +51 -15
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +2 -2
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +13 -2
- 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/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +132 -28
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +31 -3
- package/dist/storage/walk.mjs +194 -39
- 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 +146 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal-namespace.d.mts +2 -0
- package/dist/store/cursor-seal-public.d.mts +5 -0
- package/dist/store/cursor-seal-public.mjs +5 -0
- package/dist/store/cursor-seal.d.mts +16 -3
- package/dist/store/cursor-seal.mjs +40 -18
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +24 -34
- 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 +5 -0
- package/dist/store/records.mjs +12 -6
- package/dist/store/repo-record.d.mts +10 -9
- package/dist/store/repo-record.mjs +123 -28
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +21 -2
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/bound.d.mts +2 -0
- package/dist/sync/bound.mjs +11 -2
- package/dist/sync/github.d.mts +6 -1
- package/dist/sync/github.mjs +56 -44
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +32 -18
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +118 -0
- package/dist/sync/lfs-copy.mjs +262 -0
- package/dist/sync/mirror.mjs +227 -151
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +58 -30
- package/dist/sync/tries.mjs +52 -21
- package/dist/sync.d.mts +2 -2
- 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 +2 -20
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +3 -4
- 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 -9
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- 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/core/registered-rows.d.mts +0 -5
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -825
- package/dist/rest/commits.d.mts +0 -3510
- package/dist/rest/errors.d.mts +0 -2104
- package/dist/rest/events.d.mts +0 -423
- package/dist/rest/files.d.mts +0 -1330
- package/dist/rest/forks.d.mts +0 -2136
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -473
- package/dist/rest/queue.d.mts +0 -5861
- package/dist/rest/refs.d.mts +0 -2959
- package/dist/rest/repos.d.mts +0 -2539
- package/dist/rest/tags.d.mts +0 -1304
- package/dist/rest/tokens.d.mts +0 -2590
- package/dist/rest/topics.d.mts +0 -2204
- package/dist/rest/trees.d.mts +0 -1693
- package/dist/rest/work.d.mts +0 -1248
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/server/registry.d.mts +0 -16
- package/dist/server/server.d.mts +0 -36
- package/dist/storage/repack-job.d.mts +0 -3
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
- package/dist/topics/host.d.mts +0 -7
package/dist/storage/prune.mjs
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
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";
|
|
6
7
|
import { ReachedMark, markHolds } from "../store/records.mjs";
|
|
7
8
|
import { collections, reachedKey, repoRootsKey, repoScope } from "../store/scopes.mjs";
|
|
8
|
-
import { bucketDeleteMany, readWhole } from "./calls.mjs";
|
|
9
|
-
import { putOnce } from "./index-build.mjs";
|
|
9
|
+
import { bucketDeleteMany, readWhole, sizedPutCalls } from "./calls.mjs";
|
|
10
|
+
import { putOnce, rootsKeyOf } from "./index-build.mjs";
|
|
10
11
|
import { isPackId, objectCollections, runKey } from "./layout.mjs";
|
|
11
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
|
-
import { bitsBytes, hasBit,
|
|
18
|
-
import { WalkSaved, pruneWalk, walkKeys } from "./prune-walk.mjs";
|
|
19
|
-
import {
|
|
19
|
+
import { bitsBytes, eachHolders, hasBit, keepBitsOn, keepMergeCalls, setBit } from "./prune-keep.mjs";
|
|
20
|
+
import { WalkSaved, fits, pruneStartsOut, pruneStartsPutCalls, pruneWalk, pruneWalkStartCalls, walkKeys } from "./prune-walk.mjs";
|
|
21
|
+
import { compareIds } from "./raw-ids.mjs";
|
|
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";
|
|
22
25
|
import { lost } from "./walk.mjs";
|
|
@@ -49,7 +52,7 @@ const WalkCarry = /* @__PURE__ */ Schema.Union([Schema.Struct({
|
|
|
49
52
|
* go on without reading them again: `'cruft'`, each fresh pack's objects no ref reaches, which its
|
|
50
53
|
* cruft merge copies, or `'kept'`, each pack's objects its rewrite keeps. `n` names the object;
|
|
51
54
|
* `packs` are the listed packs out of `refused` its bits were read over, and they hold while the
|
|
52
|
-
* listing does; `reads` is the digest of the refs
|
|
55
|
+
* listing does; `reads` is the digest of the refs, object rows and roots they were read at, as
|
|
53
56
|
* `readsDigest` takes them, since a push can land rows and let its ref go, the refs as they were.
|
|
54
57
|
* `bytes` is the object's length, which its read charges: a fork's swap can unlist packs it holds
|
|
55
58
|
* bits of, so the listing a later step reads doesn't bound it.
|
|
@@ -61,6 +64,63 @@ const PassClasses = /* @__PURE__ */ Schema.Struct({
|
|
|
61
64
|
reads: Schema.String,
|
|
62
65
|
bytes: Schema.Int
|
|
63
66
|
});
|
|
67
|
+
/** A keep's object of bits, by its number and length, which its read charges. */
|
|
68
|
+
const KeptBits = /* @__PURE__ */ Schema.Struct({
|
|
69
|
+
n: Schema.Int,
|
|
70
|
+
bytes: Schema.Int
|
|
71
|
+
});
|
|
72
|
+
const Ranks = /* @__PURE__ */ Schema.Array(Schema.Int.check(Schema.isBetween({
|
|
73
|
+
minimum: 0,
|
|
74
|
+
maximum: 2 ** 32
|
|
75
|
+
})));
|
|
76
|
+
/**
|
|
77
|
+
* Where a keep's merge that alone passed a try stopped, between two IDs, for the next try to go
|
|
78
|
+
* on from (#2412 B2b-2): `merge` names which, the reach's bits `r`, the first holders merge
|
|
79
|
+
* `first`, the needed walk's bits `n` or the last holders merge `last`. Its object, `n` and
|
|
80
|
+
* `bytes` long, holds what the merge had found: the bits so far, the rows, the IDs a walk starts
|
|
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).
|
|
87
|
+
*/
|
|
88
|
+
const KeepAt = /* @__PURE__ */ Schema.Struct({
|
|
89
|
+
...KeptBits.fields,
|
|
90
|
+
merge: Schema.Literals([
|
|
91
|
+
"r",
|
|
92
|
+
"first",
|
|
93
|
+
"n",
|
|
94
|
+
"last"
|
|
95
|
+
]),
|
|
96
|
+
places: Ranks,
|
|
97
|
+
runs: Schema.optional(StoredRuns),
|
|
98
|
+
last: Schema.optional(Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}$/))),
|
|
99
|
+
ranks: Schema.optional(Ranks),
|
|
100
|
+
named: Schema.optional(Schema.String),
|
|
101
|
+
missed: Schema.optional(Schema.Boolean),
|
|
102
|
+
fits: Schema.optional(Schema.Boolean),
|
|
103
|
+
starts: Schema.optional(StoredRuns)
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* What a pass's merges found, kept on its mark when a try's calls end before its next merge
|
|
107
|
+
* (#2412), for the next try to read back in place of each merge. `over` is the digest of what
|
|
108
|
+
* they read, as `keepOver` takes it: the listed packs and their places in the pass, the refs,
|
|
109
|
+
* object rows and roots, a prune merge under way and the `r` walk's runs. `r` names the object of
|
|
110
|
+
* the reach's bits and rows, and `n` the needed walk's, `runs` the digest of the `n` walk's runs
|
|
111
|
+
* they were merged from. `first` says whether the first holders merge found where the needed walk
|
|
112
|
+
* starts, which it found nothing to catch up, copy or class.
|
|
113
|
+
*/
|
|
114
|
+
const PassKeep = /* @__PURE__ */ Schema.Struct({
|
|
115
|
+
over: Schema.String,
|
|
116
|
+
r: Schema.optional(KeptBits),
|
|
117
|
+
first: Schema.optional(Schema.Struct({ starts: Schema.Boolean })),
|
|
118
|
+
n: Schema.optional(Schema.Struct({
|
|
119
|
+
...KeptBits.fields,
|
|
120
|
+
runs: Schema.String
|
|
121
|
+
})),
|
|
122
|
+
at: Schema.optional(KeepAt)
|
|
123
|
+
});
|
|
64
124
|
/**
|
|
65
125
|
* A pass's mark, put in a step of its own before the pass first walks: when it began, and when
|
|
66
126
|
* it waits until, if its walk has waited. A pass is under way while its mark is newer than the
|
|
@@ -68,10 +128,12 @@ const PassClasses = /* @__PURE__ */ Schema.Struct({
|
|
|
68
128
|
* writes `waits`, the next period: till then no try walks, whatever its attempt. `walks` carries
|
|
69
129
|
* the pass's two walks across its steps, `r` of what the refs reach and `n` of what the reach
|
|
70
130
|
* leaves out names: each `saved` where a try stopped, or `done`, its reached runs under the pass's
|
|
71
|
-
* scratch pack, till the pass's last step drops them
|
|
131
|
+
* scratch pack, till the pass's last step drops them, and `roots`, `rootsKeyOf`'s digest of the
|
|
132
|
+
* roots they walk under, none in a repo with none. `classes` names the classes object its
|
|
72
133
|
* merges read, and `redos` counts the rewrites it dropped as pushes moved its refs onto what they
|
|
73
134
|
* were about to drop: the third waits for the next period, as `pruneStep` says, and that period's
|
|
74
|
-
* walks start again with none (#1660). `
|
|
135
|
+
* walks start again with none (#1660). `keep` holds what its merges found, as `PassKeep` says, its
|
|
136
|
+
* objects under the `r` walk's scratch too. `periods` counts the periods in a row the pass has waited
|
|
75
137
|
* so, which a wait for any other reason ends, as `ObjectsStep.busy` says (#2233).
|
|
76
138
|
*/
|
|
77
139
|
const PruneStarted = /* @__PURE__ */ Schema.Struct({
|
|
@@ -79,10 +141,12 @@ const PruneStarted = /* @__PURE__ */ Schema.Struct({
|
|
|
79
141
|
waits: Schema.optional(Schema.Int),
|
|
80
142
|
walks: Schema.optional(Schema.Struct({
|
|
81
143
|
r: Schema.optional(WalkCarry),
|
|
82
|
-
n: Schema.optional(WalkCarry)
|
|
144
|
+
n: Schema.optional(WalkCarry),
|
|
145
|
+
roots: Schema.optional(Schema.String)
|
|
83
146
|
})),
|
|
84
147
|
classes: Schema.optional(PassClasses),
|
|
85
148
|
redos: Schema.optional(Schema.Int),
|
|
149
|
+
keep: Schema.optional(PassKeep),
|
|
86
150
|
periods: Schema.optional(Schema.Int)
|
|
87
151
|
});
|
|
88
152
|
const pruneStartedKey = {
|
|
@@ -159,7 +223,8 @@ const walkPackOf = (repo, at, kind) => `p_${kind}${repo.slice(2)}${at.toString(3
|
|
|
159
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");
|
|
160
224
|
/**
|
|
161
225
|
* The bucket keys `started` names under its pass's scratch packs: each walk's runs, saved or
|
|
162
|
-
* done,
|
|
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.
|
|
163
228
|
*/
|
|
164
229
|
const markKeys = (started, repo, at) => {
|
|
165
230
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -171,48 +236,79 @@ const markKeys = (started, repo, at) => {
|
|
|
171
236
|
else for (const key of walkKeys(carry.saved)) keys.add(key);
|
|
172
237
|
}
|
|
173
238
|
if (started?.classes !== void 0) keys.add(classesKey(repo, at, started.classes.n));
|
|
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);
|
|
174
241
|
return keys;
|
|
175
242
|
};
|
|
176
243
|
/**
|
|
177
|
-
* A pass's reach,
|
|
178
|
-
*
|
|
179
|
-
*
|
|
244
|
+
* A pass's reach, by an ID and the packs among `packs` that hold it, as a holders merge of `packs`
|
|
245
|
+
* finds them: an ID is in it when the bits' rows hold it, or its first holder keeps it at its
|
|
246
|
+
* rank, as D3's `keptAt` says, a pack the bits have none for keeping it whole.
|
|
180
247
|
*/
|
|
181
|
-
const
|
|
182
|
-
const byPack =
|
|
248
|
+
const reachOf = (bits, packs) => {
|
|
249
|
+
const byPack = packs.map((pack) => bits.packs.find((each) => each.pack === pack.id)?.bits);
|
|
250
|
+
return (oid, holders) => {
|
|
251
|
+
if (bits.rows.has(oid)) return true;
|
|
252
|
+
const first = holders[0];
|
|
253
|
+
if (first === void 0) return false;
|
|
254
|
+
const set = byPack[first.pack];
|
|
255
|
+
return set === void 0 || hasBit(set, first.rank);
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* One holders merge of a keep's `packs`, as `eachHolders` charges and reads it: `visit` each ID
|
|
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.
|
|
264
|
+
*/
|
|
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)));
|
|
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);
|
|
183
279
|
return {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
280
|
+
found,
|
|
281
|
+
stopped: (yield* eachHolders(input, packs, (id, holders) => {
|
|
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]);
|
|
190
289
|
}
|
|
191
|
-
return
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (set === void 0) continue;
|
|
197
|
-
for (let rank = 0; rank < at.index.count; rank += 1) if (hasBit(set, rank)) yield at.index.oidAt(rank);
|
|
198
|
-
}
|
|
199
|
-
yield* bits.rows;
|
|
200
|
-
}
|
|
290
|
+
return visit(oidOf, holders);
|
|
291
|
+
}, {
|
|
292
|
+
from: going.from?.places,
|
|
293
|
+
goesOn: going.goesOn
|
|
294
|
+
}))?.places
|
|
201
295
|
};
|
|
202
|
-
};
|
|
296
|
+
}, Effect.scoped);
|
|
203
297
|
/**
|
|
204
298
|
* A pass's walk under `scratch`, its runs outliving the step: from where `saved` stopped, or from
|
|
205
299
|
* `start` with `known` reached already, as D2's walk carries it. A new walk, with neither, drops
|
|
206
300
|
* what a pass that died left under `scratch` first. With `more`, where it stopped, for the mark.
|
|
301
|
+
* A walk `spent`, after a merge the try ran, stops with `more` where a fresh try's wouldn't.
|
|
207
302
|
*/
|
|
208
|
-
const walkOn = /* @__PURE__ */ Effect.fnUntraced(function* (input, scratch, start, rows, missing, calls, roots, saved, known) {
|
|
303
|
+
const walkOn = /* @__PURE__ */ Effect.fnUntraced(function* (input, scratch, start, rows, missing, calls, roots, { saved, known, spent } = {}) {
|
|
209
304
|
if (saved === void 0 && known === void 0) yield* dropRuns(input.bucket, scratch);
|
|
210
305
|
const walked = yield* pruneWalk(input, scratch, start, missing, {
|
|
211
306
|
rows: rows.length,
|
|
212
307
|
calls,
|
|
213
308
|
saved,
|
|
214
309
|
known,
|
|
215
|
-
roots
|
|
310
|
+
roots,
|
|
311
|
+
spent
|
|
216
312
|
});
|
|
217
313
|
return "more" in walked ? { more: walked.more } : {
|
|
218
314
|
runs: walked.reached,
|
|
@@ -253,19 +349,6 @@ const refsOf = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
253
349
|
roots: yield* rootsOf(snapshot.results[1])
|
|
254
350
|
};
|
|
255
351
|
});
|
|
256
|
-
/** Every ref's object, once each, with no roots: what a listing checks its bits were read at. */
|
|
257
|
-
const refIdsOf = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
258
|
-
const snapshot = yield* input.store.read({
|
|
259
|
-
scope: repoScope(input.listed.repo),
|
|
260
|
-
reads: [{ collection: collections.refs }]
|
|
261
|
-
});
|
|
262
|
-
return yield* refIdsIn(snapshot.results[0]);
|
|
263
|
-
});
|
|
264
|
-
/** The objects of `packs` and `rows` that `reached` leaves out: where the needed walk starts. */
|
|
265
|
-
const unreachedOf = (packs, rows, reached) => [...new Set([...oidsOf(packs), ...rows.map((row) => row.oid)].filter((oid) => !reached.has(oid)))];
|
|
266
|
-
/** Every object `packs` hold. */
|
|
267
|
-
const oidsOf = (packs) => packs.flatMap(({ index }) => Array.from({ length: index.count }, (_, rank) => index.oidAt(rank)));
|
|
268
|
-
const holds = (packs) => (oid) => packs.some((indexed) => indexed.index.find(oid) !== void 0);
|
|
269
352
|
/** The packs a geometric step leaves alone: each cruft pack, which only the prune pass merges. */
|
|
270
353
|
const mergesAlone = (read) => (pack) => cruftOf(read, pack) !== void 0;
|
|
271
354
|
/**
|
|
@@ -287,26 +370,28 @@ const passPacks = (input, prune, read, drops) => {
|
|
|
287
370
|
};
|
|
288
371
|
};
|
|
289
372
|
/**
|
|
290
|
-
* Whether a pass whose steps keep what `keep` says
|
|
291
|
-
* `rows`,
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
* Exported for its test alone.
|
|
373
|
+
* Whether a pass whose steps keep what `keep` says leaves both halves of the repo's mark over its
|
|
374
|
+
* `rows`, as `ReachedMark` says: each row it keeps is one a ref reaches, and each the reach holds
|
|
375
|
+
* as a row, `reachedRows`, it keeps, in a row or a pack out of cruft, `inPacks`. A holders pass
|
|
376
|
+
* checks the same of the packs (#647). Exported for its test alone.
|
|
295
377
|
*/
|
|
296
|
-
const reachesOnly = (
|
|
297
|
-
|
|
298
|
-
for (const { index } of packs) for (let rank = 0; rank < index.count; rank += 1) if (!fits(index.oidAt(rank))) return false;
|
|
299
|
-
if (!rows.every(({ oid }) => fits(oid))) return false;
|
|
300
|
-
const inPacks = holds(packs);
|
|
378
|
+
const reachesOnly = (rows, reached, reachedRows, keep, inPacks) => {
|
|
379
|
+
if (!rows.every(({ oid }) => reached(oid) || !keep(oid))) return false;
|
|
301
380
|
const rowOids = new Set(rows.map(({ oid }) => oid));
|
|
302
|
-
for (const oid of
|
|
381
|
+
for (const oid of reachedRows) if (!keep(oid) || !rowOids.has(oid) && !inPacks(oid)) return false;
|
|
303
382
|
return true;
|
|
304
383
|
};
|
|
384
|
+
/** SHA-256 over `lists`, each sorted, a line each of its own, with a blank line between. */
|
|
385
|
+
const listsDigest = (lists) => Effect.map(Effect.promise(() => crypto.subtle.digest("SHA-256", new TextEncoder().encode(lists.map((ids) => ids.toSorted().join("\n")).join("\n\n")))), (digest) => hexOf(new Uint8Array(digest)));
|
|
305
386
|
/**
|
|
306
|
-
* The digest of the repo's refs
|
|
307
|
-
* sorted IDs, the refs', a blank line, then the
|
|
387
|
+
* The digest of the repo's refs, object rows and roots, as `PassClasses` keeps it: SHA-256 over
|
|
388
|
+
* their sorted IDs, the refs', a blank line, the rows', a blank line, then the roots'.
|
|
308
389
|
*/
|
|
309
|
-
const readsDigest = (refs, rows
|
|
390
|
+
const readsDigest = (refs, rows, roots) => listsDigest([
|
|
391
|
+
refs,
|
|
392
|
+
rows,
|
|
393
|
+
[...roots]
|
|
394
|
+
]);
|
|
310
395
|
/** The listed packs a pass's bits are read over, by ID: those out of `refused`. */
|
|
311
396
|
const classedIds = (input, read) => input.listed.packs.filter((pack) => !read.refused.has(pack.id)).map((pack) => pack.id);
|
|
312
397
|
/** Whether `a` and `b` name the same packs. */
|
|
@@ -316,25 +401,44 @@ const sameIds = (a, b) => {
|
|
|
316
401
|
};
|
|
317
402
|
/** The key of a pass's classes object `n`, under its `r` walk's scratch, which its last step drops. */
|
|
318
403
|
const classesKey = (repo, at, n) => runKey(walkPackOf(repo, at, "r"), "classes", n);
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
404
|
+
const Hex = /* @__PURE__ */ Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}$/));
|
|
405
|
+
const ClassesHeader = /* @__PURE__ */ Schema.fromJsonString(Schema.Struct({
|
|
406
|
+
packs: Schema.Array(Schema.Struct({
|
|
407
|
+
pack: Schema.String.pipe(Schema.refine(isPackId)),
|
|
408
|
+
count: Schema.Int.check(Schema.isBetween({
|
|
409
|
+
minimum: 0,
|
|
410
|
+
maximum: 2 ** 32
|
|
411
|
+
}))
|
|
412
|
+
})),
|
|
413
|
+
rows: Schema.optional(Schema.Array(Hex)),
|
|
414
|
+
held: Schema.optional(Schema.Array(Schema.Struct({
|
|
415
|
+
oid: Hex,
|
|
416
|
+
holders: Ranks
|
|
417
|
+
})))
|
|
418
|
+
}));
|
|
326
419
|
const decodeClassesHeader = /* @__PURE__ */ Schema.decodeUnknownOption(ClassesHeader);
|
|
327
420
|
const encodeClassesHeader = /* @__PURE__ */ Schema.encodeEffect(ClassesHeader);
|
|
328
421
|
/**
|
|
329
422
|
* A pass's classes object: a 4-byte header length, the header, each pack and its object count as
|
|
330
|
-
* JSON, then each pack's bits in its order. A try that
|
|
331
|
-
* put never replaces one, so the put deletes it first.
|
|
423
|
+
* JSON, with a keep's `rows` and `held`, then each pack's bits in its order. A try that
|
|
424
|
+
* died after its put leaves the key, and a put never replaces one, so the put deletes it first.
|
|
425
|
+
* The header is charged to the step's allotment while it's put, as the bits are, so a stopped
|
|
426
|
+
* merge's lists past it refuse the step too large, before the put. It returns the object's length.
|
|
332
427
|
*/
|
|
333
|
-
const putClasses = /* @__PURE__ */ Effect.fnUntraced(function* (input, key, packs) {
|
|
334
|
-
const
|
|
428
|
+
const putClasses = /* @__PURE__ */ Effect.fnUntraced(function* (input, key, packs, lists = {}) {
|
|
429
|
+
const listed = packs.map(({ pack, count }) => ({
|
|
335
430
|
pack,
|
|
336
431
|
count
|
|
337
|
-
}))
|
|
432
|
+
}));
|
|
433
|
+
const held = lists.held === void 0 ? void 0 : [...lists.held].map(([oid, holders]) => ({
|
|
434
|
+
oid,
|
|
435
|
+
holders: holders.flatMap(({ pack, rank }) => [pack, rank])
|
|
436
|
+
}));
|
|
437
|
+
const text = yield* Effect.orDie(encodeClassesHeader({
|
|
438
|
+
packs: listed,
|
|
439
|
+
rows: lists.rows,
|
|
440
|
+
held
|
|
441
|
+
}));
|
|
338
442
|
const header = new TextEncoder().encode(text);
|
|
339
443
|
const length = /* @__PURE__ */ new Uint8Array(4);
|
|
340
444
|
new DataView(length.buffer).setUint32(0, header.length);
|
|
@@ -343,16 +447,21 @@ const putClasses = /* @__PURE__ */ Effect.fnUntraced(function* (input, key, pack
|
|
|
343
447
|
header,
|
|
344
448
|
...packs.map((each) => each.bits)
|
|
345
449
|
];
|
|
346
|
-
yield*
|
|
347
|
-
|
|
348
|
-
|
|
450
|
+
return yield* Effect.scoped(Effect.gen(function* () {
|
|
451
|
+
yield* Effect.acquireRelease(input.allotment.grow(header.length, upkeepTooLarge), () => Effect.sync(() => input.allotment.shrink(header.length)));
|
|
452
|
+
yield* bucketDeleteMany(input.bucket, [key]);
|
|
453
|
+
yield* putOnce(input.bucket, key, parts);
|
|
454
|
+
return parts.reduce((sum, part) => sum + part.length, 0);
|
|
455
|
+
}));
|
|
349
456
|
});
|
|
350
457
|
/**
|
|
351
|
-
* The bits of the pass's classes object at `key`, its `bytes` charged to the
|
|
352
|
-
* while its scope is open: `undefined` when it's gone, so the pass reads its bits
|
|
353
|
-
* `DATA_LOSS` when it's broken or isn't `bytes` long.
|
|
458
|
+
* The bits and rows of the pass's classes or keep object at `key`, its `bytes` charged to the
|
|
459
|
+
* step's allotment while its scope is open: `undefined` when it's gone, so the pass reads its bits
|
|
460
|
+
* again, and `DATA_LOSS` when it's broken or isn't `bytes` long.
|
|
354
461
|
*/
|
|
355
|
-
const
|
|
462
|
+
const readBits = (input, key, most) => Effect.map(readKept(input, key, most), (kept) => kept?.bits);
|
|
463
|
+
/** The object at `key` as `readBits` reads it, with a stopped merge's `held` too. */
|
|
464
|
+
const readKept = /* @__PURE__ */ Effect.fnUntraced(function* (input, key, most) {
|
|
356
465
|
yield* Effect.acquireRelease(input.allotment.grow(most, upkeepTooLarge), () => Effect.sync(() => input.allotment.shrink(most)));
|
|
357
466
|
const bytes = yield* readWhole(input.bucket, key);
|
|
358
467
|
if (bytes === void 0) return void 0;
|
|
@@ -373,31 +482,151 @@ const readClasses = /* @__PURE__ */ Effect.fnUntraced(function* (input, key, mos
|
|
|
373
482
|
at = end;
|
|
374
483
|
}
|
|
375
484
|
if (at !== bytes.length) return yield* broken;
|
|
376
|
-
|
|
485
|
+
const held = /* @__PURE__ */ new Map();
|
|
486
|
+
for (const { oid, holders } of header.value.held ?? []) {
|
|
487
|
+
if (holders.length % 2 !== 0) return yield* broken;
|
|
488
|
+
const each = [];
|
|
489
|
+
for (let place = 0; place < holders.length; place += 2) each.push({
|
|
490
|
+
pack: holders[place] ?? 0,
|
|
491
|
+
rank: holders[place + 1] ?? 0
|
|
492
|
+
});
|
|
493
|
+
held.set(oid, each);
|
|
494
|
+
}
|
|
495
|
+
return {
|
|
496
|
+
bits: {
|
|
497
|
+
packs,
|
|
498
|
+
rows: new Set(header.value.rows)
|
|
499
|
+
},
|
|
500
|
+
held
|
|
501
|
+
};
|
|
377
502
|
});
|
|
503
|
+
/** The bits of the pass's classes object at `key`, as `readBits` reads them. */
|
|
504
|
+
const readClasses = (input, key, most) => Effect.map(readBits(input, key, most), (read) => read?.packs);
|
|
378
505
|
/**
|
|
379
|
-
*
|
|
380
|
-
*
|
|
506
|
+
* The key of a pass's keep object `n`, under its `r` walk's scratch: of the `kind` walk's bits, or
|
|
507
|
+
* `at`, what a stopped merge had found.
|
|
381
508
|
*/
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
509
|
+
const keepKey = (repo, at, kind, n) => runKey(walkPackOf(repo, at, "r"), `keep-${kind}`, n);
|
|
510
|
+
/** The keys of `keep`'s objects. */
|
|
511
|
+
const keptKeys = (repo, at, keep) => [
|
|
512
|
+
...keep?.r === void 0 ? [] : [keepKey(repo, at, "r", keep.r.n)],
|
|
513
|
+
...keep?.n === void 0 ? [] : [keepKey(repo, at, "n", keep.n.n)],
|
|
514
|
+
...keep?.at === void 0 ? [] : [keepKey(repo, at, "at", keep.at.n)]
|
|
515
|
+
];
|
|
516
|
+
/**
|
|
517
|
+
* The calls a keep object's put makes, its delete first, a forecast: of bits for packs of
|
|
518
|
+
* `counts` objects and `rows` row IDs, its header at 64 bytes a pack and 43 a row at the most,
|
|
519
|
+
* and `listed` more bytes of a stopped merge's lists.
|
|
520
|
+
*/
|
|
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));
|
|
522
|
+
/** The most header bytes a stopped holders merge's `held` takes: an ID's and each pack's ranks. */
|
|
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;
|
|
532
|
+
/** How many of `bits`' bits are set. */
|
|
533
|
+
const setCount = (bits) => {
|
|
534
|
+
let count = 0;
|
|
535
|
+
for (const byte of bits) for (let rest = byte; rest !== 0; rest &= rest - 1) count += 1;
|
|
536
|
+
return count;
|
|
537
|
+
};
|
|
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
|
+
};
|
|
553
|
+
/**
|
|
554
|
+
* The digest a pass's keep holds over, as `PassKeep.over` says: the listed packs, the young, old
|
|
555
|
+
* and fenced among them, the reads' `digest`, the prune merge under way and the `r` walk's runs.
|
|
556
|
+
*/
|
|
557
|
+
const keepOver = (input, packs, digest, merge, reached) => {
|
|
558
|
+
const placed = (place, list) => list.map((pack) => place + pack.id);
|
|
559
|
+
return listsDigest([
|
|
560
|
+
input.listed.packs.map((pack) => pack.id),
|
|
561
|
+
[...placed("young ", packs.young), ...placed("old ", packs.old)],
|
|
562
|
+
placed("fenced ", packs.fenced),
|
|
563
|
+
[digest],
|
|
564
|
+
[merge ?? ""],
|
|
565
|
+
reached.keys
|
|
566
|
+
]);
|
|
567
|
+
};
|
|
568
|
+
/**
|
|
569
|
+
* The parts of the mark's `keep` that hold `over` and, for `n`, the needed walk's runs `named`,
|
|
570
|
+
* the objects of those that don't deleted first: `changed` when any part is let go.
|
|
571
|
+
*/
|
|
572
|
+
const keptOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, at, keep, over, named) {
|
|
573
|
+
if (keep === void 0) return {
|
|
574
|
+
keep: void 0,
|
|
575
|
+
changed: false
|
|
576
|
+
};
|
|
577
|
+
if (keep.over !== over) {
|
|
578
|
+
yield* bucketDeleteMany(input.bucket, keptKeys(input.listed.repo, at, keep));
|
|
393
579
|
return {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
bits,
|
|
397
|
-
set
|
|
580
|
+
keep: void 0,
|
|
581
|
+
changed: true
|
|
398
582
|
};
|
|
399
|
-
}
|
|
583
|
+
}
|
|
584
|
+
const staleN = keep.n !== void 0 && keep.n.runs !== named;
|
|
585
|
+
const staleAt = keep.at?.merge === "n" && keep.at.named !== named;
|
|
586
|
+
if (!staleN && !staleAt) return {
|
|
587
|
+
keep,
|
|
588
|
+
changed: false
|
|
589
|
+
};
|
|
590
|
+
const holding = { ...keep };
|
|
591
|
+
const keys = [];
|
|
592
|
+
if (staleN && keep.n !== void 0) {
|
|
593
|
+
keys.push(keepKey(input.listed.repo, at, "n", keep.n.n));
|
|
594
|
+
delete holding.n;
|
|
595
|
+
}
|
|
596
|
+
if (staleAt && keep.at !== void 0) {
|
|
597
|
+
keys.push(keepKey(input.listed.repo, at, "at", keep.at.n));
|
|
598
|
+
delete holding.at;
|
|
599
|
+
}
|
|
600
|
+
yield* bucketDeleteMany(input.bucket, keys);
|
|
601
|
+
return {
|
|
602
|
+
keep: holding,
|
|
603
|
+
changed: true
|
|
604
|
+
};
|
|
605
|
+
});
|
|
606
|
+
/**
|
|
607
|
+
* Bits for each of `packs` at `chosen`, by its place, none set, charged to the step's allotment
|
|
608
|
+
* while its scope is open: a holders pass sets them with `setClass`.
|
|
609
|
+
*/
|
|
610
|
+
const classBitsOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, packs, chosen) {
|
|
611
|
+
const bytes = chosen.reduce((sum, at) => sum + bitsBytes(packs[at]?.objects ?? 0), 0);
|
|
612
|
+
yield* Effect.acquireRelease(input.allotment.grow(bytes, upkeepTooLarge), () => Effect.sync(() => input.allotment.shrink(bytes)));
|
|
613
|
+
return new Map(chosen.map((at) => {
|
|
614
|
+
const count = packs[at]?.objects ?? 0;
|
|
615
|
+
return [at, {
|
|
616
|
+
pack: packs[at]?.id,
|
|
617
|
+
count,
|
|
618
|
+
bits: new Uint8Array(bitsBytes(count)),
|
|
619
|
+
set: 0
|
|
620
|
+
}];
|
|
621
|
+
}));
|
|
400
622
|
});
|
|
623
|
+
/** Sets `classes`' bit at `holder`'s rank in its pack, when it has bits for that pack. */
|
|
624
|
+
const setClass = (classes, { pack, rank }) => {
|
|
625
|
+
const each = classes.get(pack);
|
|
626
|
+
if (each === void 0 || hasBit(each.bits, rank)) return;
|
|
627
|
+
setBit(each.bits, rank);
|
|
628
|
+
each.set += 1;
|
|
629
|
+
};
|
|
401
630
|
/**
|
|
402
631
|
* The cruft merge's listing: its packs listed, each a cruft pack with a `cruft` row of now. It
|
|
403
632
|
* only adds, so a push beside it loses nothing, and the next step finds what it copied in young
|
|
@@ -424,11 +653,12 @@ const cruftListing = (landed) => Effect.fnUntraced(function* (input, merge) {
|
|
|
424
653
|
/**
|
|
425
654
|
* The rewrite's listing: its packs listed in place of its inputs, each an input a `leaving` row,
|
|
426
655
|
* and each old cruft input's `cruft` row ended, so the step `drops`. None while the repo's refs,
|
|
427
|
-
* its object rows, `rows`, or its listed packs aren't the ones its bits were read at, `seen`: the
|
|
656
|
+
* its object rows, `rows`, its roots or its listed packs aren't the ones its bits were read at, `seen`: the
|
|
428
657
|
* merge waits at its commit pass, and the pass catches up first.
|
|
429
658
|
*/
|
|
430
659
|
const keptListing = (read, seen, rows, landed) => Effect.fnUntraced(function* (input, merge) {
|
|
431
|
-
|
|
660
|
+
const { refs, roots } = yield* refsOf(input);
|
|
661
|
+
if ((yield* readsDigest(refs, rows, roots)) !== seen.reads || !sameIds(seen.packs, classedIds(input, read))) return void 0;
|
|
432
662
|
const removed = yield* takenOf(input, merge);
|
|
433
663
|
const { packs, quarantines, first } = yield* writtenOf(merge);
|
|
434
664
|
const dropped = removed.filter((pack) => read.cruft.has(pack.id));
|
|
@@ -457,9 +687,11 @@ const keptListing = (read, seen, rows, landed) => Effect.fnUntraced(function* (i
|
|
|
457
687
|
* the most that open within a fresh try, as `opensWithin` says, but at least one, which
|
|
458
688
|
* `streamMerge` fences as `open-past-try` when it opens past one alone, so the next read leaves it
|
|
459
689
|
* out of the classes (#1663): choose keeps each object at a set bit, and `listing` lists what
|
|
460
|
-
* 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.
|
|
461
693
|
*/
|
|
462
|
-
const classMerge = (input, read, bits, most, calls, listing) => {
|
|
694
|
+
const classMerge = (input, read, bits, most, calls, listing, classes, remap) => {
|
|
463
695
|
const byPack = new Map(bits.map((each) => [each.pack, each.bits]));
|
|
464
696
|
const named = input.listed.packs.filter((pack) => byPack.has(pack.id));
|
|
465
697
|
const isOld = (pack) => cruftOf(read, pack) !== void 0;
|
|
@@ -477,7 +709,9 @@ const classMerge = (input, read, bits, most, calls, listing) => {
|
|
|
477
709
|
calls,
|
|
478
710
|
owner: "prune",
|
|
479
711
|
keep,
|
|
480
|
-
|
|
712
|
+
classes,
|
|
713
|
+
listing,
|
|
714
|
+
remap
|
|
481
715
|
}, input.at);
|
|
482
716
|
};
|
|
483
717
|
/**
|
|
@@ -528,9 +762,11 @@ const rowsStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, rows, keep,
|
|
|
528
762
|
* The step that unlists each pack of `emptied`, whose every object the pass drops, with no merge:
|
|
529
763
|
* each a `leaving` row, and an old cruft pack's `cruft` row ended, so the step `drops`. It makes
|
|
530
764
|
* the `repack` row due, whose clean-up deletes the packs' bytes once their rows are, so on a repo
|
|
531
|
-
* 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).
|
|
532
768
|
*/
|
|
533
|
-
const emptiedStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, emptied) {
|
|
769
|
+
const emptiedStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, emptied, remap) {
|
|
534
770
|
const ids = new Set(emptied.map((each) => each.pack));
|
|
535
771
|
const removed = yield* Effect.forEach(input.listed.packs.filter((pack) => ids.has(pack.id)), namedOf);
|
|
536
772
|
const dropped = removed.filter((pack) => read.cruft.has(pack.id));
|
|
@@ -545,6 +781,16 @@ const emptiedStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, em
|
|
|
545
781
|
repack: input.at
|
|
546
782
|
};
|
|
547
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;
|
|
548
794
|
return step;
|
|
549
795
|
});
|
|
550
796
|
/** A mark at `started`'s start, with its `periods`, if any: what each new mark of the pass keeps. */
|
|
@@ -587,9 +833,11 @@ const remarked = (started, patch) => {
|
|
|
587
833
|
const walks = "walks" in patch ? patch.walks : started.walks;
|
|
588
834
|
const classes = "classes" in patch ? patch.classes : started.classes;
|
|
589
835
|
const redos = "redos" in patch ? patch.redos : started.redos;
|
|
836
|
+
const keep = "keep" in patch ? patch.keep : started.keep;
|
|
590
837
|
if (walks !== void 0) value.walks = walks;
|
|
591
838
|
if (classes !== void 0) value.classes = classes;
|
|
592
839
|
if (redos !== void 0) value.redos = redos;
|
|
840
|
+
if (keep !== void 0) value.keep = keep;
|
|
593
841
|
return value;
|
|
594
842
|
};
|
|
595
843
|
/**
|
|
@@ -606,35 +854,54 @@ const remarked = (started, patch) => {
|
|
|
606
854
|
* holds it, and what it names stays, so the pass proves no mark while it holds what no ref
|
|
607
855
|
* reaches. A rewrite whose refs, object rows or listed packs moved before its listing catches up,
|
|
608
856
|
* and is dropped for its bits to be read again when it was about to drop what they reach now.
|
|
857
|
+
* With `calls`, a merge past what the try has left, after one it ran, ends the step with what
|
|
858
|
+
* they found on the mark's `keep`, which `keeping` hands `pruneStep` when the step lets it go.
|
|
609
859
|
*/
|
|
610
|
-
const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, packs, objectRows, most, calls) {
|
|
860
|
+
const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, packs, objectRows, most, calls, keeping, remap) {
|
|
611
861
|
const rows = yield* wholeRows(objectRows);
|
|
612
862
|
const rowOids = rows.map((row) => row.oid);
|
|
613
863
|
const at = read.started?.at ?? input.at;
|
|
614
|
-
const
|
|
864
|
+
const { refs, roots } = yield* refsOf(input);
|
|
865
|
+
const rootsKey = rootsKeyOf(roots);
|
|
866
|
+
const carried = read.started?.walks?.roots === rootsKey ? read.started?.walks ?? {} : {};
|
|
615
867
|
const classes = read.started?.classes;
|
|
616
868
|
const redos = read.started?.redos ?? 0;
|
|
617
869
|
const scratch = walkPackOf(input.listed.repo, at, "r");
|
|
618
|
-
const saving = (walks) =>
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
870
|
+
const saving = (walks, keep) => {
|
|
871
|
+
const value = rootsKey === void 0 ? walks : {
|
|
872
|
+
...walks,
|
|
873
|
+
roots: rootsKey
|
|
874
|
+
};
|
|
875
|
+
return {
|
|
876
|
+
step: {
|
|
877
|
+
change: { rows: noRows },
|
|
878
|
+
more: true
|
|
879
|
+
},
|
|
880
|
+
mark: keep === void 0 ? { walks: value } : {
|
|
881
|
+
walks: value,
|
|
882
|
+
keep
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
};
|
|
886
|
+
const digest = yield* readsDigest(refs, rowOids, roots);
|
|
627
887
|
const ids = classedIds(input, read);
|
|
628
888
|
const carry = carried.r;
|
|
629
889
|
if (carry === void 0 || "saved" in carry) {
|
|
630
|
-
const walked = yield* walkOn(input, scratch, refs, rows, lost, calls, roots, carry?.saved);
|
|
631
|
-
|
|
890
|
+
const walked = yield* walkOn(input, scratch, refs, rows, lost, calls, roots, { saved: carry?.saved });
|
|
891
|
+
const walkedOn = saving({ r: "more" in walked ? {
|
|
632
892
|
saved: walked.more,
|
|
633
893
|
refs: carry?.refs
|
|
634
894
|
} : {
|
|
635
895
|
done: walked.runs,
|
|
636
896
|
refs: refsJoined(carry?.refs, walked.refs)
|
|
637
897
|
} });
|
|
898
|
+
return carry === void 0 && read.started?.keep !== void 0 ? {
|
|
899
|
+
...walkedOn,
|
|
900
|
+
mark: {
|
|
901
|
+
...walkedOn.mark,
|
|
902
|
+
keep: void 0
|
|
903
|
+
}
|
|
904
|
+
} : walkedOn;
|
|
638
905
|
}
|
|
639
906
|
const merge = read.merges.prune;
|
|
640
907
|
const landed = { done: false };
|
|
@@ -659,59 +926,220 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
659
926
|
step: droppedStep(merge),
|
|
660
927
|
mark: { classes: void 0 }
|
|
661
928
|
};
|
|
662
|
-
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
|
+
}
|
|
663
946
|
}
|
|
664
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;
|
|
665
|
-
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);
|
|
666
949
|
const reachedRuns = carry.done;
|
|
667
|
-
const bits = yield* keepBits(input, scratch, reachedRuns, rowOids, lost);
|
|
668
950
|
const oldIds = new Set(packs.old.map((pack) => pack.id));
|
|
669
951
|
const fencedIds = new Set(packs.fenced.map((pack) => pack.id));
|
|
670
|
-
const sides =
|
|
671
|
-
|
|
672
|
-
|
|
952
|
+
const sides = [...packs.merging, ...packs.young];
|
|
953
|
+
const isYoung = sides.map((pack) => youngIds.has(pack.id));
|
|
954
|
+
const isFenced = sides.map((pack) => fencedIds.has(pack.id));
|
|
955
|
+
const isOld = sides.map((pack) => oldIds.has(pack.id));
|
|
956
|
+
const isFresh = sides.map((_, at) => !isYoung[at] && !isOld[at] && !isFenced[at]);
|
|
957
|
+
const neededCarry = carried.n;
|
|
958
|
+
const neededDone = neededCarry !== void 0 && "done" in neededCarry ? neededCarry.done : void 0;
|
|
959
|
+
const neededKeys = neededDone === void 0 ? void 0 : yield* listsDigest([neededDone.keys]);
|
|
960
|
+
const keptOver = yield* keepOver(input, packs, digest, merge?.pack, reachedRuns);
|
|
961
|
+
const prior = yield* keptOf(input, at, read.started?.keep, keptOver, neededKeys);
|
|
962
|
+
const keepNow = { over: keptOver };
|
|
963
|
+
keeping.changed = prior.changed;
|
|
964
|
+
keeping.keep = keepNow;
|
|
965
|
+
const unsaved = [];
|
|
966
|
+
const started = read.started?.keep;
|
|
967
|
+
let numbered = Math.max(started?.r?.n ?? -1, started?.n?.n ?? -1, started?.at?.n ?? -1) + 1;
|
|
968
|
+
let ran = false;
|
|
969
|
+
const saveCalls = () => unsaved.reduce((sum, { bits }) => sum + keptPutCalls(input, bits.packs.map((each) => each.count), bits.rows.size), 0);
|
|
970
|
+
const goesOn = (needs) => !ran || fits(calls, needs + saveCalls());
|
|
971
|
+
const saved = Effect.fnUntraced(function* (kinds) {
|
|
972
|
+
for (const { kind, bits: each } of unsaved) {
|
|
973
|
+
if (!kinds.includes(kind)) continue;
|
|
974
|
+
const n = numbered;
|
|
975
|
+
numbered += 1;
|
|
976
|
+
const key = keepKey(input.listed.repo, at, kind, n);
|
|
977
|
+
const bytes = yield* putClasses(input, key, each.packs, { rows: [...each.rows] });
|
|
978
|
+
if (kind === "r") keepNow.r = {
|
|
979
|
+
n,
|
|
980
|
+
bytes
|
|
981
|
+
};
|
|
982
|
+
else keepNow.n = {
|
|
983
|
+
n,
|
|
984
|
+
bytes,
|
|
985
|
+
runs: neededKeys ?? ""
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
unsaved.length = 0;
|
|
989
|
+
return { ...keepNow };
|
|
990
|
+
});
|
|
991
|
+
const stopped = Effect.map(saved(["r", "n"]), (keep) => ({
|
|
992
|
+
step: {
|
|
993
|
+
change: { rows: noRows },
|
|
994
|
+
more: true
|
|
995
|
+
},
|
|
996
|
+
mark: { keep }
|
|
997
|
+
}));
|
|
998
|
+
const partial = prior.keep?.at;
|
|
999
|
+
keeping.changed ||= partial !== void 0;
|
|
1000
|
+
const partialOf = (kind) => partial?.merge === kind ? partial : void 0;
|
|
1001
|
+
const readPartial = (kept) => readKept(input, keepKey(input.listed.repo, at, "at", kept.n), kept.bytes);
|
|
1002
|
+
const goesOnIn = (reserve) => calls === void 0 ? void 0 : (reads) => fits(calls, reads + saveCalls() + reserve() + 1);
|
|
1003
|
+
const stoppedAt = Effect.fnUntraced(function* (place, found, lists) {
|
|
1004
|
+
const n = numbered;
|
|
1005
|
+
numbered += 1;
|
|
1006
|
+
const bytes = yield* putClasses(input, keepKey(input.listed.repo, at, "at", n), found, lists);
|
|
1007
|
+
keepNow.at = {
|
|
1008
|
+
...place,
|
|
1009
|
+
n,
|
|
1010
|
+
bytes
|
|
1011
|
+
};
|
|
1012
|
+
const step = yield* stopped;
|
|
1013
|
+
if (partial !== void 0) yield* bucketDeleteMany(input.bucket, [keepKey(input.listed.repo, at, "at", partial.n)]);
|
|
1014
|
+
return step;
|
|
1015
|
+
});
|
|
1016
|
+
const listedCounts = input.listed.packs.map((pack) => pack.objects);
|
|
1017
|
+
const bitsCalls = () => keptPutCalls(input, listedCounts, rowOids.length);
|
|
1018
|
+
const bitsFrom = Effect.fnUntraced(function* (kept) {
|
|
1019
|
+
if (kept?.runs === void 0 || kept.last === void 0 || kept.ranks === void 0) return void 0;
|
|
1020
|
+
const read = yield* readPartial(kept);
|
|
1021
|
+
if (read === void 0) return void 0;
|
|
673
1022
|
return {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
1023
|
+
place: {
|
|
1024
|
+
runs: kept.runs,
|
|
1025
|
+
places: kept.places,
|
|
1026
|
+
last: kept.last,
|
|
1027
|
+
ranks: kept.ranks
|
|
1028
|
+
},
|
|
1029
|
+
bits: read.bits
|
|
679
1030
|
};
|
|
680
1031
|
});
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
1032
|
+
const stoppedBits = (kind, place, found) => stoppedAt({
|
|
1033
|
+
merge: kind,
|
|
1034
|
+
places: place.places,
|
|
1035
|
+
runs: storedRuns(place.runs),
|
|
1036
|
+
last: place.last,
|
|
1037
|
+
ranks: place.ranks,
|
|
1038
|
+
named: kind === "n" ? neededKeys ?? "" : void 0
|
|
1039
|
+
}, found.packs, { rows: [...found.rows] });
|
|
1040
|
+
const keptR = prior.keep?.r;
|
|
1041
|
+
const savedR = keptR === void 0 ? void 0 : yield* readBits(input, keepKey(input.listed.repo, at, "r", keptR.n), keptR.bytes);
|
|
1042
|
+
if (savedR !== void 0 && keptR !== void 0) keepNow.r = keptR;
|
|
1043
|
+
keeping.changed ||= keptR !== void 0 && savedR === void 0;
|
|
1044
|
+
const mergedR = savedR !== void 0 ? { bits: savedR } : yield* keepBitsOn(input, scratch, reachedRuns, rowOids, lost, {
|
|
1045
|
+
from: yield* bitsFrom(partialOf("r")),
|
|
1046
|
+
goesOn: goesOnIn(bitsCalls)
|
|
1047
|
+
});
|
|
1048
|
+
if ("stopped" in mergedR) return yield* stoppedBits("r", mergedR.stopped, mergedR.bits);
|
|
1049
|
+
const { bits } = mergedR;
|
|
1050
|
+
if (savedR === void 0) {
|
|
1051
|
+
ran = true;
|
|
1052
|
+
unsaved.push({
|
|
1053
|
+
kind: "r",
|
|
1054
|
+
bits
|
|
693
1055
|
});
|
|
694
1056
|
}
|
|
695
|
-
const
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
return
|
|
1057
|
+
const pass = (wanted, visit, going) => heldPass(input, sides, wanted, visit, going);
|
|
1058
|
+
const holdersFrom = Effect.fnUntraced(function* (kept, classes) {
|
|
1059
|
+
if (kept === void 0) return void 0;
|
|
1060
|
+
return yield* Effect.scoped(Effect.gen(function* () {
|
|
1061
|
+
const read = yield* readPartial(kept);
|
|
1062
|
+
if (read === void 0) return void 0;
|
|
1063
|
+
for (const each of read.bits.packs) {
|
|
1064
|
+
const into = classes?.get(sides.findIndex((pack) => pack.id === each.pack));
|
|
1065
|
+
if (into?.bits.length !== each.bits.length) return yield* fail("DATA_LOSS", `The prune pass's keep ${kept.n} names other classes`);
|
|
1066
|
+
into.bits.set(each.bits);
|
|
1067
|
+
into.set = setCount(each.bits);
|
|
1068
|
+
}
|
|
1069
|
+
return {
|
|
1070
|
+
places: kept.places,
|
|
1071
|
+
found: read.held,
|
|
1072
|
+
starts: kept.starts
|
|
1073
|
+
};
|
|
1074
|
+
}));
|
|
1075
|
+
});
|
|
1076
|
+
const classPacks = (classes) => [...classes?.values() ?? []];
|
|
1077
|
+
const reached = reachOf(bits, sides);
|
|
1078
|
+
const apart = (holders) => holders.some(({ pack }) => isYoung[pack] === true || isFenced[pack] === true);
|
|
1079
|
+
const inFresh = (holders) => holders.some(({ pack }) => isFresh[pack] === true);
|
|
1080
|
+
const rowSet = new Set(rowOids);
|
|
1081
|
+
const reachedBits = sides.map((pack) => bits.packs.find((each) => each.pack === pack.id)?.bits);
|
|
1082
|
+
const ownBit = ({ pack, rank }) => {
|
|
1083
|
+
const set = reachedBits[pack];
|
|
1084
|
+
return set !== void 0 && hasBit(set, rank);
|
|
699
1085
|
};
|
|
700
|
-
const
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
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);
|
|
1096
|
+
const keptFirst = packs.old.length > 0 && neededCarry === void 0 ? void 0 : prior.keep?.first;
|
|
1097
|
+
const sideCounts = sides.map((pack) => pack.objects);
|
|
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);
|
|
1099
|
+
const holdersCalls = keepMergeCalls(input, sides) + keptPutCalls(input, sideCounts, 0);
|
|
1100
|
+
if (keptFirst === void 0 && !goesOn(holdersCalls + walkStart)) return yield* stopped;
|
|
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 };
|
|
1105
|
+
ran ||= keptFirst === void 0;
|
|
1106
|
+
const first = keptFirst !== void 0 ? none : yield* Effect.scoped(Effect.gen(function* () {
|
|
1107
|
+
const fresh = sides.flatMap((_, at) => isFresh[at] === true ? [at] : []);
|
|
1108
|
+
const cruft = merge === void 0 ? yield* classBitsOf(input, sides, fresh) : void 0;
|
|
1109
|
+
const wanted = /* @__PURE__ */ new Set([...rowSet, ...refs]);
|
|
1110
|
+
const cruftCounts = classPacks(cruft).map((each) => each.count);
|
|
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;
|
|
1119
|
+
}, {
|
|
1120
|
+
from,
|
|
1121
|
+
goesOn: goesOnIn(() => keptPutCalls(input, cruftCounts, 0, heldBytes(wanted.size, sides.length)) + startsPuts + walkStart)
|
|
1122
|
+
});
|
|
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
|
+
}
|
|
1131
|
+
const rowsBy = passed.found;
|
|
1132
|
+
const caught = refs.filter((oid) => !reached(oid, rowsBy.get(oid) ?? []));
|
|
1133
|
+
if (caught.length > 0) return { caught };
|
|
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 };
|
|
1136
|
+
const cruftRows = rows.filter((row) => {
|
|
1137
|
+
const holders = rowsBy.get(row.oid) ?? [];
|
|
1138
|
+
return !reached(row.oid, holders) && !apart(holders);
|
|
1139
|
+
});
|
|
712
1140
|
if (cruftRows.length > 0) return { cruft: yield* rowsCruft(input, cruftRows, most) };
|
|
713
|
-
const copies =
|
|
714
|
-
if (copies.length === 0) return { start };
|
|
1141
|
+
const copies = [...cruft.values()].filter((each) => each.set > 0);
|
|
1142
|
+
if (copies.length === 0) return { start: yield* out.finish };
|
|
715
1143
|
const n = (classes?.n ?? -1) + 1;
|
|
716
1144
|
const bytes = yield* putClasses(input, classesKey(input.listed.repo, at, n), copies);
|
|
717
1145
|
return { classes: {
|
|
@@ -722,6 +1150,23 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
722
1150
|
bytes
|
|
723
1151
|
} };
|
|
724
1152
|
}));
|
|
1153
|
+
if ("stopped" in first) return first.stopped;
|
|
1154
|
+
if ("caught" in first) {
|
|
1155
|
+
const walked = yield* walkOn(input, scratch, first.caught, rows, lost, calls, roots, {
|
|
1156
|
+
known: reachedRuns,
|
|
1157
|
+
spent: ran
|
|
1158
|
+
});
|
|
1159
|
+
return saving({
|
|
1160
|
+
...carried,
|
|
1161
|
+
r: "more" in walked ? {
|
|
1162
|
+
saved: walked.more,
|
|
1163
|
+
refs: carry.refs
|
|
1164
|
+
} : {
|
|
1165
|
+
done: walked.runs,
|
|
1166
|
+
refs: refsJoined(carry.refs, walked.refs)
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
725
1170
|
if ("cruft" in first) return first.cruft;
|
|
726
1171
|
if ("classes" in first) return {
|
|
727
1172
|
step: {
|
|
@@ -730,72 +1175,145 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
730
1175
|
},
|
|
731
1176
|
mark: { classes: first.classes }
|
|
732
1177
|
};
|
|
733
|
-
const
|
|
734
|
-
|
|
1178
|
+
const startsAny = keptFirst?.starts ?? (first.start?.rows ?? 0) > 0;
|
|
1179
|
+
keepNow.first = { starts: startsAny };
|
|
735
1180
|
if (packs.old.length > 0 && (neededCarry === void 0 || "saved" in neededCarry)) {
|
|
736
|
-
const
|
|
737
|
-
const
|
|
1181
|
+
const keep = calls === void 0 ? void 0 : yield* saved(["r"]);
|
|
1182
|
+
const start = (neededCarry === void 0 ? first.start : void 0) ?? [];
|
|
1183
|
+
const walked = yield* walkOn(input, named, start, rows, () => void 0, calls, roots, {
|
|
1184
|
+
saved: neededCarry?.saved,
|
|
1185
|
+
known: neededCarry === void 0 ? reachedRuns : void 0,
|
|
1186
|
+
spent: ran
|
|
1187
|
+
});
|
|
738
1188
|
return saving({
|
|
739
1189
|
...carried,
|
|
740
1190
|
n: "more" in walked ? { saved: walked.more } : { done: walked.runs }
|
|
1191
|
+
}, keep);
|
|
1192
|
+
}
|
|
1193
|
+
const keptN = prior.keep?.n;
|
|
1194
|
+
const savedN = keptN === void 0 ? void 0 : yield* readBits(input, keepKey(input.listed.repo, at, "n", keptN.n), keptN.bytes);
|
|
1195
|
+
if (savedN !== void 0 && keptN !== void 0) keepNow.n = keptN;
|
|
1196
|
+
keeping.changed ||= keptN !== void 0 && savedN === void 0;
|
|
1197
|
+
const merges = neededDone === void 0 ? 0 : keepMergeCalls(input, input.listed.packs, neededDone) + keptPutCalls(input, listedCounts, rowOids.length);
|
|
1198
|
+
if (neededDone !== void 0 && savedN === void 0 && !goesOn(merges)) return yield* stopped;
|
|
1199
|
+
const mergedN = neededDone === void 0 || savedN !== void 0 ? savedN && { bits: savedN } : yield* keepBitsOn(input, named, neededDone, rowOids, () => void 0, {
|
|
1200
|
+
from: yield* bitsFrom(partialOf("n")),
|
|
1201
|
+
goesOn: goesOnIn(bitsCalls)
|
|
1202
|
+
});
|
|
1203
|
+
if (mergedN !== void 0 && "stopped" in mergedN) return yield* stoppedBits("n", mergedN.stopped, mergedN.bits);
|
|
1204
|
+
const neededRuns = mergedN?.bits;
|
|
1205
|
+
if (neededRuns !== void 0 && savedN === void 0) {
|
|
1206
|
+
ran = true;
|
|
1207
|
+
unsaved.push({
|
|
1208
|
+
kind: "n",
|
|
1209
|
+
bits: neededRuns
|
|
741
1210
|
});
|
|
742
1211
|
}
|
|
743
|
-
const
|
|
744
|
-
const
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
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()));
|
|
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));
|
|
1217
|
+
const moved = merge !== void 0 && classes !== void 0 ? merge : void 0;
|
|
1218
|
+
const before = moved === void 0 || classes === void 0 ? void 0 : yield* readClasses(input, classesKey(input.listed.repo, at, classes.n), classes.bytes);
|
|
1219
|
+
const byPack = new Map((before ?? []).map((each) => [each.pack, each.bits]));
|
|
1220
|
+
const inputs = new Set(moved?.value.inputs);
|
|
1221
|
+
const unclassed = ({ pack, rank }) => {
|
|
1222
|
+
const id = sides[pack]?.id;
|
|
1223
|
+
if (id === void 0 || isYoung[pack] === true || !inputs.has(id)) return false;
|
|
1224
|
+
const set = byPack.get(id);
|
|
1225
|
+
return set === void 0 || !hasBit(set, rank);
|
|
1226
|
+
};
|
|
1227
|
+
const rewriting = moved === void 0 ? [...sides.flatMap((_, at) => isOld[at] === true && isFenced[at] !== true ? [at] : []), ...sides.flatMap((_, at) => isFresh[at] === true ? [at] : [])] : [];
|
|
1228
|
+
const kept = yield* classBitsOf(input, sides, rewriting);
|
|
1229
|
+
const outside = sides.map((pack, at) => isYoung[at] !== true && cruftOf(read, pack) === void 0);
|
|
1230
|
+
const isOutside = (holders) => holders.some(({ pack }) => outside[pack] === true);
|
|
1231
|
+
const whole = (oid, holders) => keep(oid, holders) || holders.some(({ pack }) => isFenced[pack] === true);
|
|
1232
|
+
if (!goesOn(holdersCalls + walkStart)) return yield* stopped;
|
|
1233
|
+
const behindOf = neededRuns !== void 0 && startsAny;
|
|
1234
|
+
const lastAt = partialOf("last");
|
|
1235
|
+
const from = yield* holdersFrom(lastAt, kept);
|
|
1236
|
+
const behind = yield* startsOut(from?.starts, behindOf);
|
|
1237
|
+
let missed = lastAt?.missed ?? false;
|
|
1238
|
+
let markFits = lastAt?.fits ?? true;
|
|
1239
|
+
const wanted = /* @__PURE__ */ new Set([...rowSet, ...bits.rows]);
|
|
1240
|
+
const keptCounts = classPacks(kept).map((each) => each.count);
|
|
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);
|
|
1244
|
+
if (moved !== void 0) {
|
|
1245
|
+
missed ||= keeps && holders.some(unclassed);
|
|
1246
|
+
return wrote;
|
|
1247
|
+
}
|
|
1248
|
+
for (const holder of holders) if (keeps || ownBit(holder)) setClass(kept, holder);
|
|
1249
|
+
if (!markFits) return wrote;
|
|
1250
|
+
const wholly = keeps || holders.some(({ pack }) => isFenced[pack] === true);
|
|
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;
|
|
1254
|
+
}, {
|
|
1255
|
+
from,
|
|
1256
|
+
goesOn: goesOnIn(() => keptPutCalls(input, keptCounts, 0, heldBytes(wanted.size, sides.length)) + startsPuts + walkStart)
|
|
1257
|
+
});
|
|
1258
|
+
if (passed.stopped !== void 0) return yield* stoppedAt({
|
|
1259
|
+
merge: "last",
|
|
1260
|
+
places: passed.stopped,
|
|
1261
|
+
missed,
|
|
1262
|
+
fits: markFits,
|
|
1263
|
+
starts: yield* behind.finish
|
|
1264
|
+
}, classPacks(kept), { held: passed.found });
|
|
1265
|
+
const rowsBy = passed.found;
|
|
1266
|
+
if (behindOf) for (const oid of rowOids) {
|
|
1267
|
+
const holders = rowsBy.get(oid) ?? [];
|
|
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) {
|
|
1272
|
+
const keep = calls === void 0 ? void 0 : yield* saved(["r"]);
|
|
1273
|
+
const walked = yield* walkOn(input, named, behindRuns, rows, () => void 0, calls, roots, {
|
|
1274
|
+
known: neededDone,
|
|
1275
|
+
spent: ran
|
|
1276
|
+
});
|
|
751
1277
|
return saving({
|
|
752
1278
|
...carried,
|
|
753
1279
|
n: "more" in walked ? { saved: walked.more } : { done: walked.runs }
|
|
754
|
-
});
|
|
1280
|
+
}, keep);
|
|
755
1281
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
const inFenced = holds(fenced);
|
|
759
|
-
const inFresh = holds(fresh);
|
|
760
|
-
const needed = neededRuns === void 0 ? /* @__PURE__ */ new Set() : bitsOf(neededRuns, [...merging, ...young]);
|
|
761
|
-
const apart = (oid) => inYoung(oid) || inFenced(oid);
|
|
762
|
-
const inRows = new Set(rowOids);
|
|
763
|
-
const keep = (oid) => reached.has(oid) || !apart(oid) && (inFresh(oid) || inRows.has(oid) || needed.has(oid));
|
|
764
|
-
if (merge !== void 0 && classes !== void 0) {
|
|
765
|
-
const before = yield* readClasses(input, classesKey(input.listed.repo, at, classes.n), classes.bytes);
|
|
766
|
-
const byPack = new Map((before ?? []).map((each) => [each.pack, each.bits]));
|
|
767
|
-
const inputs = new Set(merge.value.inputs);
|
|
768
|
-
if (!merging.some(({ pack, index }) => {
|
|
769
|
-
if (!inputs.has(pack.id)) return false;
|
|
770
|
-
const set = byPack.get(pack.id);
|
|
771
|
-
for (let rank = 0; rank < index.count; rank += 1) if ((set === void 0 || !hasBit(set, rank)) && keep(index.oidAt(rank))) return true;
|
|
772
|
-
return false;
|
|
773
|
-
})) {
|
|
1282
|
+
if (moved !== void 0) {
|
|
1283
|
+
if (!missed) {
|
|
774
1284
|
const listing = keptListing(read, {
|
|
775
1285
|
reads: digest,
|
|
776
1286
|
packs: ids
|
|
777
1287
|
}, rowOids, landed);
|
|
778
|
-
|
|
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");
|
|
779
1299
|
}
|
|
780
1300
|
if (redos + 1 >= 3) return {
|
|
781
1301
|
waits: `pushes moved its refs onto what its rewrite was about to drop, 3 times in a row`,
|
|
782
1302
|
busy: true
|
|
783
1303
|
};
|
|
784
1304
|
return {
|
|
785
|
-
step: droppedStep(
|
|
1305
|
+
step: droppedStep(moved),
|
|
786
1306
|
mark: {
|
|
787
1307
|
classes: void 0,
|
|
788
1308
|
redos: redos + 1
|
|
789
1309
|
}
|
|
790
1310
|
};
|
|
791
1311
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
return set !== void 0 && hasBit(set, rank) || keep(indexed.index.oidAt(rank));
|
|
796
|
-
})).filter((each) => oldIds.has(each.pack) || each.set < each.count);
|
|
1312
|
+
const rowKeep = (oid) => keep(oid, rowsBy.get(oid) ?? []);
|
|
1313
|
+
if (rows.some((row) => !rowKeep(row.oid))) return yield* rowsStep(input, rows, rowKeep, most);
|
|
1314
|
+
const rewrites = [...kept.values()].filter((each) => oldIds.has(each.pack) || each.set < each.count);
|
|
797
1315
|
const emptied = rewrites.filter((each) => each.set === 0);
|
|
798
|
-
if (emptied.length > 0) return { step: yield* emptiedStep(input, read, emptied) };
|
|
1316
|
+
if (emptied.length > 0) return { step: yield* emptiedStep(input, read, emptied, remap) };
|
|
799
1317
|
if (rewrites.length > 0) {
|
|
800
1318
|
const n = (classes?.n ?? -1) + 1;
|
|
801
1319
|
const value = {
|
|
@@ -831,9 +1349,10 @@ const passSteps = /* @__PURE__ */ Effect.fnUntraced(function* (input, read, pack
|
|
|
831
1349
|
},
|
|
832
1350
|
more: false
|
|
833
1351
|
};
|
|
834
|
-
const
|
|
835
|
-
const
|
|
836
|
-
|
|
1352
|
+
const rowsWhole = (oid) => whole(oid, rowsBy.get(oid) ?? []);
|
|
1353
|
+
const rowsReach = (oid) => reached(oid, rowsBy.get(oid) ?? []);
|
|
1354
|
+
const rowsOutside = (oid) => isOutside(rowsBy.get(oid) ?? []);
|
|
1355
|
+
if (held && reachedBits.every((each) => each !== void 0) && markFits && reachesOnly(rows, rowsReach, bits.rows, rowsWhole, rowsOutside)) step.reaches = true;
|
|
837
1356
|
return {
|
|
838
1357
|
step,
|
|
839
1358
|
last: true
|
|
@@ -875,6 +1394,11 @@ const passDue = (input, prune, read, objectRows) => {
|
|
|
875
1394
|
};
|
|
876
1395
|
};
|
|
877
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
|
+
/**
|
|
878
1402
|
* Upkeep's prune, as Q270 says: a pass at most once each `prune`, or each hour while the repo's
|
|
879
1403
|
* `ReachedMark` doesn't hold, and at once after a newer clear; while it holds with no cruft listed,
|
|
880
1404
|
* just the pass's row with no walk. A pass walks to sorted runs whatever the repo's count, and is
|
|
@@ -886,12 +1410,14 @@ const passDue = (input, prune, read, objectRows) => {
|
|
|
886
1410
|
* dropped, and it looks again within the hour. A marked pass whose try is `retried`, after one
|
|
887
1411
|
* that died or failed, waits for the next period, as does one whose walk is past what one walk
|
|
888
1412
|
* holds or makes no step, and one whose rewrite pushes caught up with `redosMost` times: each
|
|
889
|
-
* writes the wait to its mark
|
|
1413
|
+
* writes the wait to its mark, drops its merge under way and its keep's objects, with a log line.
|
|
1414
|
+
* A step whose try's calls end before the pass's next merge keeps what its merges found on its
|
|
1415
|
+
* mark, for the next try to go on from (#2412). A pass that waits
|
|
890
1416
|
* before its walk logs too, and writes nothing but its mark's end of a count of periods pushes
|
|
891
1417
|
* held it, as every wait for anything but pushes does. `step` is `undefined` when no pass is
|
|
892
1418
|
* due; `next` is when the next one is, and `undefined` for a repo that holds no object.
|
|
893
1419
|
*/
|
|
894
|
-
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) {
|
|
895
1421
|
const due = passDue(input, prune, read, objectRows);
|
|
896
1422
|
if (due === void 0) return {
|
|
897
1423
|
step: void 0,
|
|
@@ -903,7 +1429,6 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
903
1429
|
next
|
|
904
1430
|
};
|
|
905
1431
|
const last = read.pass?.at;
|
|
906
|
-
const markHeld = markHolds(read.mark);
|
|
907
1432
|
const merge = read.merges.prune;
|
|
908
1433
|
const uncounted = countEnded(read);
|
|
909
1434
|
const waitsElse = (step) => uncounted === void 0 ? step : alsoPuts(step, uncounted);
|
|
@@ -923,7 +1448,7 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
923
1448
|
},
|
|
924
1449
|
next
|
|
925
1450
|
};
|
|
926
|
-
if (
|
|
1451
|
+
if (passAlone(read)) return {
|
|
927
1452
|
step: {
|
|
928
1453
|
change: {
|
|
929
1454
|
put: [{
|
|
@@ -932,9 +1457,10 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
932
1457
|
}],
|
|
933
1458
|
rows: noRows
|
|
934
1459
|
},
|
|
935
|
-
more:
|
|
1460
|
+
more: false
|
|
936
1461
|
},
|
|
937
|
-
next: input.at + pruneWait(prune)
|
|
1462
|
+
next: input.at + pruneWait(prune),
|
|
1463
|
+
alone: true
|
|
938
1464
|
};
|
|
939
1465
|
const most = (repack === false ? void 0 : repack.maxPackSize) ?? defaultRepack.maxPackSize;
|
|
940
1466
|
const until = input.at + pruneWait(prune);
|
|
@@ -999,16 +1525,26 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
999
1525
|
change,
|
|
1000
1526
|
more: true
|
|
1001
1527
|
};
|
|
1002
|
-
|
|
1528
|
+
const kept = keptKeys(input.listed.repo, started.at, started.keep);
|
|
1529
|
+
const dropped = kept.length === 0 ? Effect.void : bucketDeleteMany(input.bucket, kept);
|
|
1530
|
+
return Effect.andThen(dropped, Effect.as(later(why), {
|
|
1003
1531
|
step,
|
|
1004
1532
|
next: until
|
|
1005
|
-
});
|
|
1533
|
+
}));
|
|
1006
1534
|
};
|
|
1007
1535
|
if (retried) return yield* waits("its last try died or failed with the pass under way");
|
|
1008
|
-
const
|
|
1536
|
+
const keeping = {
|
|
1537
|
+
changed: false,
|
|
1538
|
+
keep: void 0
|
|
1539
|
+
};
|
|
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" } })));
|
|
1009
1541
|
if ("waits" in stepped) return yield* waits(stepped.waits, "busy" in stepped);
|
|
1010
1542
|
const { change } = stepped.step;
|
|
1011
|
-
const
|
|
1543
|
+
const marked = "mark" in stepped ? stepped.mark : void 0;
|
|
1544
|
+
const patch = keeping.changed && (marked === void 0 || !("keep" in marked)) ? {
|
|
1545
|
+
...marked,
|
|
1546
|
+
keep: keeping.keep
|
|
1547
|
+
} : marked;
|
|
1012
1548
|
const step = patch === void 0 ? stepped.step : {
|
|
1013
1549
|
...stepped.step,
|
|
1014
1550
|
change: {
|
|
@@ -1043,4 +1579,4 @@ const pruneStep = /* @__PURE__ */ Effect.fnUntraced(function* (input, prune, rep
|
|
|
1043
1579
|
next
|
|
1044
1580
|
};
|
|
1045
1581
|
});
|
|
1046
|
-
export { CruftRow, PassClasses, PruneCleared, PrunePass, PruneStarted,
|
|
1582
|
+
export { CruftRow, PassClasses, PassKeep, PruneCleared, PrunePass, PruneStarted, cruftOf, heldWantedBytes, mergesAlone, passAlone, passDue, passScratch, pruneClearedKey, prunePassKey, pruneStartedKey, pruneStep, reachOf, reachesOnly, readPrune, walkPackOf };
|