@ref0/git 0.6.0 → 0.7.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/namespace.d.mts +2 -0
- package/dist/access/private-refs.d.mts +6 -29
- package/dist/access/private-refs.mjs +28 -13
- package/dist/access/public.d.mts +6 -0
- package/dist/access/public.mjs +9 -0
- package/dist/auth/access-jwt.d.mts +10 -6
- package/dist/auth/access-jwt.mjs +59 -40
- package/dist/auth/auth-namespace.d.mts +6 -0
- package/dist/auth/auth-namespace.mjs +12 -0
- package/dist/auth/auth.d.mts +3 -6
- package/dist/auth/auth.mjs +2 -9
- package/dist/auth/authorize.mjs +4 -5
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +17 -8
- package/dist/auth/identify.mjs +2 -1
- package/dist/auth/namespaces.d.mts +2 -2
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/tokens-layer.d.mts +42 -0
- package/dist/auth/tokens-layer.mjs +29 -0
- package/dist/auth/tokens-namespace.d.mts +2 -0
- package/dist/auth/tokens-public.d.mts +6 -0
- package/dist/auth/tokens-public.mjs +29 -0
- package/dist/auth/tokens.d.mts +13 -6
- package/dist/auth/tokens.mjs +5 -5
- package/dist/auth.d.mts +2 -2
- package/dist/auth.mjs +2 -2
- package/dist/client/git-http.mjs +1 -1
- package/dist/client/local.mjs +4 -3
- package/dist/client/remote-helper.mjs +3 -8
- package/dist/client/remote.mjs +26 -7
- package/dist/client/run-remote-helper.d.mts +1 -1
- package/dist/client/run-remote-helper.mjs +2 -2
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +18 -10
- package/dist/contracts/access.mjs +17 -0
- package/dist/contracts/actors.d.mts +17 -1
- package/dist/contracts/actors.mjs +8 -1
- package/dist/contracts/authorize.d.mts +7 -4
- package/dist/contracts/blobs.d.mts +1 -1
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/calls-spent.d.mts +6 -4
- package/dist/contracts/calls-spent.mjs +10 -8
- package/dist/contracts/commits.d.mts +2 -2
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +1 -1
- package/dist/contracts/events.d.mts +33 -22
- package/dist/contracts/events.mjs +13 -4
- package/dist/contracts/files.d.mts +2 -2
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +58 -58
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-events.d.mts +50 -0
- package/dist/contracts/git-events.mjs +23 -0
- package/dist/contracts/git-hooks.d.mts +37 -0
- package/dist/contracts/git-hooks.mjs +10 -0
- package/dist/contracts/git.d.mts +93 -42
- package/dist/contracts/git.mjs +6 -5
- package/dist/contracts/ids.d.mts +16 -0
- package/dist/contracts/ids.mjs +19 -4
- package/dist/contracts/lfs.d.mts +2 -0
- package/dist/contracts/namespaces.d.mts +2 -2
- package/dist/contracts/objects.d.mts +1 -1
- package/dist/contracts/opaque.mjs +9 -0
- package/dist/contracts/operations.d.mts +293 -100
- package/dist/contracts/promises.d.mts +2 -0
- package/dist/contracts/push-uploads.d.mts +4 -1
- package/dist/contracts/push-uploads.mjs +9 -4
- package/dist/contracts/queue.d.mts +218 -47
- package/dist/contracts/queue.mjs +81 -6
- package/dist/contracts/refs.d.mts +30 -8
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +42 -21
- package/dist/contracts/remote.mjs +22 -0
- package/dist/contracts/repo-records.d.mts +2 -2
- package/dist/contracts/repos.d.mts +126 -79
- package/dist/contracts/repos.mjs +43 -5
- package/dist/contracts/result.d.mts +46 -31
- package/dist/contracts/result.mjs +43 -16
- package/dist/contracts/rules.d.mts +50 -44
- package/dist/contracts/rules.mjs +5 -1
- package/dist/contracts/server.d.mts +282 -198
- package/dist/contracts/services.d.mts +1 -7
- package/dist/contracts/services.mjs +1 -3
- package/dist/contracts/signin.d.mts +140 -43
- package/dist/contracts/signin.mjs +35 -1
- package/dist/contracts/store.d.mts +1 -1
- package/dist/contracts/sync.d.mts +112 -90
- package/dist/contracts/sync.mjs +34 -7
- package/dist/contracts/tags.d.mts +1 -1
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +232 -57
- package/dist/contracts/tokens.mjs +80 -19
- package/dist/contracts/topics.d.mts +22 -10
- package/dist/contracts/topics.mjs +6 -3
- package/dist/contracts/trees.d.mts +2 -2
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +2 -2
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +10 -10
- package/dist/core/access.mjs +31 -8
- package/dist/core/clock.mjs +1 -1
- package/dist/core/events/deliver.d.mts +3 -2
- package/dist/core/events/deliver.mjs +170 -92
- package/dist/core/forks.mjs +49 -24
- package/dist/core/hooks/groups.d.mts +27 -0
- package/dist/core/hooks/groups.mjs +74 -0
- package/dist/core/hooks/namespace.d.mts +2 -0
- package/dist/core/hooks/order.d.mts +2 -2
- package/dist/core/hooks/order.mjs +6 -6
- package/dist/core/hooks/public.d.mts +7 -0
- package/dist/core/hooks/public.mjs +5 -0
- package/dist/core/imports.mjs +94 -10
- package/dist/core/index-job.mjs +11 -8
- package/dist/core/merge-parts.d.mts +1 -1
- package/dist/core/merge-parts.mjs +1 -1
- package/dist/core/mirror-rows.mjs +18 -0
- package/dist/core/names.mjs +1 -1
- package/dist/core/namespaces.d.mts +2 -1
- package/dist/core/objects/commit-writes.mjs +5 -5
- package/dist/core/objects/merges.mjs +1 -1
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/reading.mjs +52 -7
- package/dist/core/objects/tree-edits.mjs +13 -28
- package/dist/core/objects/trees.mjs +4 -4
- package/dist/core/objects/writing.mjs +3 -3
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +22 -3
- package/dist/core/parts.mjs +5 -3
- package/dist/core/promise.mjs +23 -3
- package/dist/core/purge.d.mts +2 -2
- package/dist/core/purge.mjs +80 -30
- package/dist/core/push.mjs +55 -74
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +28 -4
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +2 -2
- package/dist/core/refs.mjs +41 -10
- package/dist/core/registered-records.mjs +30 -0
- package/dist/core/{claim-rows.mjs → registered-rows.mjs} +6 -6
- package/dist/core/repack.d.mts +2 -2
- package/dist/core/repack.mjs +11 -9
- package/dist/core/repo-info.mjs +59 -25
- package/dist/core/repos.mjs +17 -11
- package/dist/core/rules/changes.mjs +2 -2
- package/dist/core/rules/commit-changes.mjs +1 -1
- package/dist/core/rules/context.d.mts +4 -5
- package/dist/core/rules/context.mjs +3 -4
- package/dist/core/rules/fetch.mjs +74 -21
- package/dist/core/saved-caller-views.d.mts +72 -0
- package/dist/core/saved-caller-views.mjs +123 -0
- package/dist/core/saved-callers-public.d.mts +5 -0
- package/dist/core/saved-callers-public.mjs +10 -0
- package/dist/core/saved-callers.mjs +95 -0
- package/dist/core/seam.d.mts +12 -1
- package/dist/core/seam.mjs +4 -2
- package/dist/core/tokens.mjs +5 -1
- package/dist/core/view.d.mts +1 -1
- package/dist/core/view.mjs +1 -1
- package/dist/core/work.mjs +6 -5
- package/dist/effect.d.mts +2 -2
- package/dist/effect.mjs +2 -2
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/diff.mjs +2 -2
- package/dist/engine/merge-base-walk.d.mts +2 -2
- package/dist/engine/merge-base-walk.mjs +1 -1
- package/dist/engine/merge-renames.mjs +1 -1
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +1 -1
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +2 -2
- package/dist/event-streams/event-streams.d.mts +6 -2
- package/dist/event-streams/event-streams.mjs +6 -2
- package/dist/event-streams/stream.mjs +5 -2
- package/dist/extend.d.mts +3 -3
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +4 -3
- package/dist/http/core-parts.mjs +2 -2
- package/dist/http/handler.mjs +1 -1
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-uploads.mjs +7 -5
- package/dist/http/receive-pack.mjs +3 -3
- package/dist/http/upload-pack.mjs +6 -5
- package/dist/index.d.mts +33 -20
- package/dist/index.mjs +13 -7
- package/dist/lfs/base.d.mts +2 -2
- package/dist/lfs/calls.mjs +3 -2
- package/dist/lfs/layer.d.mts +5 -4
- package/dist/lfs/layer.mjs +17 -16
- package/dist/lfs/locks.mjs +3 -3
- package/dist/lfs/objects.d.mts +3 -2
- package/dist/lfs/objects.mjs +149 -34
- package/dist/lfs/pointers.mjs +1 -1
- package/dist/lfs/purge.mjs +1 -1
- package/dist/lfs/rows.mjs +1 -1
- package/dist/lfs/upkeep.mjs +13 -9
- package/dist/lfs/wire.mjs +1 -1
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +1 -1
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/hmac-sha256.mjs +3 -6
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +2 -2
- package/dist/protocol/diff/read.d.mts +1 -1
- package/dist/protocol/diff/read.mjs +1 -1
- package/dist/protocol/diff/tree-diff.d.mts +1 -1
- package/dist/protocol/diff/tree-diff.mjs +11 -11
- package/dist/protocol/objects/lfs-pointer.mjs +6 -1
- package/dist/protocol/objects/tag.mjs +1 -1
- package/dist/protocol/objects/tree.mjs +1 -1
- package/dist/protocol/packs/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +1 -1
- package/dist/protocol/packs/idx.mjs +1 -1
- package/dist/protocol/packs/parts.mjs +1 -1
- package/dist/protocol/packs/reader.d.mts +1 -1
- package/dist/protocol/packs/reader.mjs +2 -2
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +4 -4
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +1 -1
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +1 -1
- package/dist/protocol/wire/lines.mjs +2 -2
- package/dist/protocol/wire/push-uploads.mjs +4 -2
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +2 -2
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/queue/advance.mjs +155 -63
- package/dist/queue/callers.mjs +56 -69
- package/dist/queue/calls.mjs +20 -11
- package/dist/queue/commit.mjs +28 -22
- package/dist/queue/host.d.mts +10 -11
- package/dist/queue/host.mjs +15 -7
- package/dist/queue/lanes.mjs +9 -18
- package/dist/queue/layer.d.mts +3 -3
- package/dist/queue/layer.mjs +11 -10
- package/dist/queue/limits.mjs +17 -5
- package/dist/queue/rows.mjs +5 -10
- package/dist/queue/schedule.mjs +6 -5
- package/dist/queue/search.mjs +8 -13
- package/dist/queue/state.mjs +7 -2
- package/dist/queue/trim.mjs +10 -5
- package/dist/rest/api.d.mts +1 -1
- package/dist/rest/blobs.d.mts +20 -20
- package/dist/rest/caller.d.mts +22 -20
- package/dist/rest/client.mjs +6 -6
- package/dist/rest/commits.d.mts +335 -335
- package/dist/rest/errors.d.mts +10 -10
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/events.d.mts +13 -11
- package/dist/rest/events.mjs +3 -1
- package/dist/rest/files.d.mts +30 -30
- package/dist/rest/forks.d.mts +150 -150
- package/dist/rest/handler.mjs +4 -3
- package/dist/rest/handlers.mjs +13 -7
- package/dist/rest/layer.d.mts +3 -3
- package/dist/rest/layer.mjs +8 -7
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/me.d.mts +18 -20
- package/dist/rest/me.mjs +1 -1
- package/dist/rest/merges.d.mts +10 -10
- package/dist/rest/queue.d.mts +140 -140
- package/dist/rest/queue.mjs +1 -1
- package/dist/rest/refs.d.mts +95 -95
- package/dist/rest/refs.mjs +1 -1
- package/dist/rest/repos.d.mts +127 -127
- package/dist/rest/tags.d.mts +30 -30
- package/dist/rest/tokens.d.mts +250 -260
- package/dist/rest/tokens.mjs +10 -42
- package/dist/rest/topics.d.mts +63 -63
- package/dist/rest/topics.mjs +1 -1
- package/dist/rest/trees.d.mts +106 -106
- package/dist/rest/wire.d.mts +6 -4
- package/dist/rest/wire.mjs +4 -3
- package/dist/rest/work.d.mts +69 -69
- package/dist/rest/work.mjs +1 -1
- package/dist/server/check-fetch.mjs +9 -0
- package/dist/server/extension.mjs +3 -115
- package/dist/server/git-layer.d.mts +20 -3
- package/dist/server/git-layer.mjs +30 -19
- package/dist/server/git-namespace.d.mts +4 -4
- package/dist/server/git-namespace.mjs +6 -4
- package/dist/server/joined.d.mts +83 -0
- package/dist/server/joined.mjs +91 -0
- package/dist/server/registry.d.mts +7 -3
- package/dist/server/registry.mjs +135 -31
- package/dist/server/routes.mjs +2 -2
- package/dist/server/server.d.mts +9 -2
- package/dist/server/server.mjs +279 -191
- package/dist/signin/context.d.mts +2 -1
- package/dist/signin/context.mjs +32 -37
- package/dist/signin/device.mjs +5 -5
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -3
- package/dist/signin/grants.mjs +5 -5
- package/dist/signin/layer.d.mts +9 -0
- package/dist/signin/layer.mjs +41 -0
- package/dist/signin/namespace.d.mts +2 -0
- package/dist/signin/public.d.mts +6 -0
- package/dist/signin/public.mjs +5 -0
- package/dist/signin/route.mjs +47 -21
- package/dist/signin/web.mjs +3 -3
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +4 -4
- package/dist/storage/clean-up.mjs +12 -5
- package/dist/storage/counted-bucket.mjs +34 -51
- package/dist/storage/fetch.mjs +1 -1
- package/dist/storage/host-bucket.mjs +1 -1
- package/dist/storage/index-build.d.mts +2 -2
- package/dist/storage/index-build.mjs +3 -3
- package/dist/storage/index-fetch.mjs +10 -6
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +1 -1
- package/dist/storage/index-visible.mjs +1 -1
- package/dist/storage/memory-budget.mjs +7 -1
- package/dist/storage/merge-cut.mjs +24 -1
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-plan.mjs +5 -2
- package/dist/storage/merge-row.mjs +1 -1
- package/dist/storage/merge-stream.mjs +16 -7
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -2
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +2 -2
- package/dist/storage/object-rows.mjs +3 -3
- package/dist/storage/pack-ranges.d.mts +3 -1
- package/dist/storage/pack-ranges.mjs +168 -69
- package/dist/storage/pack-reads.mjs +4 -4
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +7 -9
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +45 -52
- package/dist/storage/placed-reads.mjs +81 -15
- package/dist/storage/prune-seen.mjs +126 -0
- package/dist/storage/prune-walk.mjs +87 -99
- package/dist/storage/prune.mjs +49 -14
- package/dist/storage/push-uploads.mjs +4 -2
- package/dist/storage/quarantine.d.mts +2 -2
- package/dist/storage/ready.d.mts +2 -2
- package/dist/storage/ready.mjs +3 -3
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +1 -1
- package/dist/storage/receive-steps.mjs +1 -1
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.d.mts +2 -2
- package/dist/storage/repack-job.mjs +5 -4
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +9 -3
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +15 -6
- package/dist/storage/send-list.mjs +6 -6
- package/dist/storage/single-flight.mjs +2 -2
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +1 -1
- package/dist/store/call-count.d.mts +1 -1
- package/dist/store/call-count.mjs +125 -34
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +2 -2
- package/dist/store/crossing.mjs +2 -6
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/errors.d.mts +7 -3
- package/dist/store/errors.mjs +41 -13
- package/dist/store/job-try.mjs +119 -15
- package/dist/store/list-job.mjs +5 -5
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +75 -16
- package/dist/store/promises.d.mts +2 -2
- package/dist/store/promises.mjs +31 -6
- package/dist/store/queue-jobs.mjs +1 -1
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +16 -24
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +6 -6
- package/dist/store/reservations.mjs +35 -8
- package/dist/store/scopes.mjs +6 -4
- package/dist/store/topic-jobs.mjs +8 -8
- package/dist/sync/bound.d.mts +1 -3
- package/dist/sync/bound.mjs +30 -42
- package/dist/sync/bridge.d.mts +6 -0
- package/dist/sync/bridge.mjs +29 -0
- package/dist/sync/github.d.mts +5 -6
- package/dist/sync/github.mjs +37 -42
- package/dist/sync/http.mjs +15 -0
- package/dist/sync/import.mjs +17 -18
- package/dist/sync/layer.d.mts +9 -0
- package/dist/sync/layer.mjs +68 -0
- package/dist/sync/mirror.mjs +137 -58
- package/dist/sync/publish.mjs +3 -6
- package/dist/sync/step.mjs +217 -79
- package/dist/sync/tries.mjs +22 -15
- package/dist/sync.d.mts +3 -6
- package/dist/sync.mjs +3 -6
- package/dist/topics/advance.mjs +205 -90
- package/dist/topics/calls.mjs +8 -8
- package/dist/topics/directory.mjs +35 -12
- package/dist/topics/host.d.mts +5 -8
- package/dist/topics/host.mjs +42 -19
- package/dist/topics/layer.d.mts +381 -0
- package/dist/topics/layer.mjs +62 -0
- package/dist/topics/members.mjs +1 -1
- package/dist/topics/namespace.d.mts +2 -0
- package/dist/topics/public.d.mts +6 -0
- package/dist/topics/public.mjs +13 -0
- package/dist/topics/rows.mjs +12 -3
- package/dist/topics/topic.mjs +11 -10
- package/package.json +8 -13
- package/dist/access.d.mts +0 -2
- package/dist/access.mjs +0 -1
- package/dist/core/hooks/post-receive.mjs +0 -216
- package/dist/core/hooks/pre-receive.d.mts +0 -12
- package/dist/core/hooks/pre-receive.mjs +0 -36
- package/dist/server/extension.d.mts +0 -21
- package/dist/sync/import.d.mts +0 -10
- package/dist/sync/jobs.d.mts +0 -9
- package/dist/sync/jobs.mjs +0 -75
- package/dist/sync/mirror.d.mts +0 -13
- package/dist/sync/publish.d.mts +0 -6
- /package/dist/core/{claim-rows.d.mts → registered-rows.d.mts} +0 -0
|
@@ -1,12 +1,65 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
3
|
+
import "../protocol/packs/idx.mjs";
|
|
3
4
|
import { stepEffect } from "../protocol/packs/step.mjs";
|
|
4
5
|
import { basesBlock, openBases } from "./index-files.mjs";
|
|
5
6
|
import { indexFiles } from "./layout.mjs";
|
|
6
7
|
import { indexBytes, loadedLookup, rangedLookup } from "./pack-reads.mjs";
|
|
7
|
-
import {
|
|
8
|
+
import { openPlacedTables, placedEntries, placedEntriesBytes, placedEntriesGets, rangeRanks, searchReads } from "./pack-ranges.mjs";
|
|
8
9
|
import { basesReadBytes, basesRuns } from "./send-list.mjs";
|
|
9
10
|
import * as Effect from "effect/Effect";
|
|
11
|
+
// src/storage/placed-reads.ts
|
|
12
|
+
/**
|
|
13
|
+
* #1722: the trees and commits a fetch's walk holds positions for, read whole at their place in
|
|
14
|
+
* their pack rather than by ID, so a near have's walk loads no covered pack's `.idx` and `.rev`
|
|
15
|
+
* whole. Each pack of a read is read one of three ways:
|
|
16
|
+
*
|
|
17
|
+
* - **Loaded:** the reader holds its `.idx` and `.rev` already, so each place's offset is read
|
|
18
|
+
* from them, with no get.
|
|
19
|
+
* - **By place:** each `REF_DELTA`'s chain of bases found by position in its layer's `.bases`,
|
|
20
|
+
* then every place's ID and offset read by range, as `placedEntries` reads them, and each object
|
|
21
|
+
* resolved from its offset, its bases found among those IDs.
|
|
22
|
+
* - **Whole:** past `placedReadGetsMost(pack, levels)` gets spent by place on that pack or
|
|
23
|
+
* `placedReadGetsCap` across the fetch, or where its `.idx` and `.rev` hold no more than reading
|
|
24
|
+
* by place would, they're loaded, as a read by ID loads them, and read as a loaded pack is. So a
|
|
25
|
+
* walk spends at most that bound's gets more than a read by ID would.
|
|
26
|
+
*
|
|
27
|
+
* A position past every pack is a region row, read through `outside`.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* One-time bucket gets opening a pack's `.rev` header (1) and its layer's `.bases` header and
|
|
31
|
+
* tail (2) cost on the first placed read.
|
|
32
|
+
*/
|
|
33
|
+
const placedReadOpenGets = 3;
|
|
34
|
+
/**
|
|
35
|
+
* The fewest bucket gets one pack's placed reads are allowed once walked: matches the former
|
|
36
|
+
* fixed budget so no small pack with a delta chain crossing several `.bases` blocks is worse off
|
|
37
|
+
* than on `main` (#522).
|
|
38
|
+
*/
|
|
39
|
+
const placedReadGetsFloor = 64;
|
|
40
|
+
/**
|
|
41
|
+
* Sizing heuristic for one walk level of `pack` read by place (not a strict upper bound: a single
|
|
42
|
+
* delta chain can cross more than `2` `.bases` blocks within one level, which `placedReadGetsFloor`
|
|
43
|
+
* covers for small packs): its most spans of ranks, one for every other `rangeRanks` (32,768)
|
|
44
|
+
* window, as `placedEntries` reads them, each span's `.idx` tables (`3` under 2 GiB, `4` past it)
|
|
45
|
+
* and a `.rev` span, and `2` `.bases` runs for a level straddling a 4,096-position block boundary.
|
|
46
|
+
*
|
|
47
|
+
* - 48k pack (2 windows, 1 span): `6` (+ 3 open = `9` -> floored to `64` at depth 1 and depth 3).
|
|
48
|
+
* - 83k pack (3 windows, 2 spans, 3-pack 250k `deep7`): `10` (+ 3 open = `13` -> `64` at depth 1, `93` at depth 9).
|
|
49
|
+
* - 168.5k pack (6 windows, 3 spans, 1-pack `clone-svelte`): `14` (+ 3 open = `17` -> `64` at depth 1, `115` at depth 8).
|
|
50
|
+
* - 250k pack (8 windows, 4 spans, 1-pack `flat50`): `18` (+ 3 open = `21` -> `64` at depth 1 and depth 3).
|
|
51
|
+
* - 1M pack (31 windows, 16 spans): `66` under 2 GiB / `82` past 2 GiB (+ 3 open = `69` / `85` at depth 1).
|
|
52
|
+
*/
|
|
53
|
+
const placedReadLevelGets = (pack) => {
|
|
54
|
+
return Math.ceil(Math.ceil(pack.count / rangeRanks) / 2) * ((pack.pack.bytes > 2147483647 ? 4 : 3) + 1) + 2;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The most bucket gets reading `pack` by place may spend over `levels` walk levels (1 for commits,
|
|
58
|
+
* 2 for commits + root trees, ...): a sizing heuristic floored at `placedReadGetsFloor` (64) so no
|
|
59
|
+
* small pack is worse off than before and capped at `placedReadGetsCap` (512) so a wide or very
|
|
60
|
+
* deep walk loads whole instead of outspending a Worker's bucket call limit (#522).
|
|
61
|
+
*/
|
|
62
|
+
const placedReadGetsMost = (pack, levels) => levels <= 0 ? 0 : Math.min(512, Math.max(placedReadGetsFloor, placedReadOpenGets + levels * placedReadLevelGets(pack)));
|
|
10
63
|
/** The gets reading `places` of `pack` by place makes: its `.rev`'s header unless it's `open`. */
|
|
11
64
|
const placedReadGets = (pack, places, open) => (open ? 0 : 1) + placedEntriesGets(pack.count, pack.pack.bytes, places);
|
|
12
65
|
const loss = (message) => gitError("DATA_LOSS", message);
|
|
@@ -30,12 +83,20 @@ const baseIn = (rows, position) => {
|
|
|
30
83
|
const placedReads = (input) => {
|
|
31
84
|
const { ranges, layers, listed, bucket, read, ahead } = input;
|
|
32
85
|
const listedOf = new Map(listed.packs.map((pack) => [pack.id, pack]));
|
|
33
|
-
const
|
|
86
|
+
const opens = /* @__PURE__ */ new Map();
|
|
34
87
|
const opened = /* @__PURE__ */ new Map();
|
|
35
88
|
let spent = 0;
|
|
36
|
-
|
|
37
|
-
const
|
|
89
|
+
let level = 0;
|
|
90
|
+
const packSpent = /* @__PURE__ */ new Map();
|
|
91
|
+
const packLevels = /* @__PURE__ */ new Map();
|
|
92
|
+
const packLastLevel = /* @__PURE__ */ new Map();
|
|
93
|
+
const fits = (pack, gets) => {
|
|
94
|
+
const limit = placedReadGetsMost(pack, packLevels.get(pack.pack.id) ?? 0);
|
|
95
|
+
return spent + gets <= 512 && (packSpent.get(pack.pack.id) ?? 0) + gets <= limit;
|
|
96
|
+
};
|
|
97
|
+
const spend = (pack, gets) => {
|
|
38
98
|
spent += gets;
|
|
99
|
+
packSpent.set(pack.pack.id, (packSpent.get(pack.pack.id) ?? 0) + gets);
|
|
39
100
|
return ahead({
|
|
40
101
|
bucket: gets,
|
|
41
102
|
store: 0
|
|
@@ -86,8 +147,8 @@ const placedReads = (input) => {
|
|
|
86
147
|
const runs = basesRuns((block) => blocks.has(block) && !rows.has(block), layer.first, end);
|
|
87
148
|
const open = opened.get(layer);
|
|
88
149
|
const gets = runs.length + (open === void 0 ? 2 : 0);
|
|
89
|
-
if (!fits(gets + placedReadGets(pack, placesOf(pack, all),
|
|
90
|
-
yield* spend(gets);
|
|
150
|
+
if (!fits(pack, gets + placedReadGets(pack, placesOf(pack, all), opens.has(pack.pack.id)))) return yield* Effect.as(read.release(held), void 0);
|
|
151
|
+
yield* spend(pack, gets);
|
|
91
152
|
const bases = open ?? (yield* openBases(bucket, indexFiles(listed.repo, layer.build).bases, end));
|
|
92
153
|
opened.set(layer, bases);
|
|
93
154
|
for (const run of runs) {
|
|
@@ -126,20 +187,20 @@ const placedReads = (input) => {
|
|
|
126
187
|
const all = yield* chainsOf(pack, asked);
|
|
127
188
|
if (all === void 0 || whole(all.size)) return void 0;
|
|
128
189
|
const places = placesOf(pack, all);
|
|
129
|
-
const known =
|
|
190
|
+
const known = opens.get(pack.pack.id);
|
|
130
191
|
const gets = placedReadGets(pack, places, known !== void 0);
|
|
131
|
-
if (!fits(gets)) return void 0;
|
|
132
|
-
yield* spend(gets);
|
|
133
|
-
const
|
|
134
|
-
|
|
192
|
+
if (!fits(pack, gets)) return void 0;
|
|
193
|
+
yield* spend(pack, gets);
|
|
194
|
+
const tables = known ?? (yield* openPlacedTables(bucket, pack.pack, pack.count));
|
|
195
|
+
opens.set(pack.pack.id, tables);
|
|
135
196
|
yield* read.hold(placedEntriesBytes(places.length) + places.length * 64);
|
|
136
|
-
const entries = yield* placedEntries(
|
|
197
|
+
const entries = yield* placedEntries(tables, places);
|
|
137
198
|
const found = /* @__PURE__ */ new Map();
|
|
138
199
|
for (let slot = 0; slot < places.length; slot += 1) found.set(hexOf(entries.ids.subarray(slot * 20, slot * 20 + 20)), entries.offsets[slot] ?? 0);
|
|
139
200
|
yield* read.release(placedEntriesBytes(places.length));
|
|
140
201
|
const search = rangedLookup(pack);
|
|
141
202
|
const searched = Effect.fnUntraced(function* (oid) {
|
|
142
|
-
yield* spend(searchReads(pack.count) + 1);
|
|
203
|
+
yield* spend(pack, searchReads(pack.count) + 1);
|
|
143
204
|
return yield* stepEffect(search.find(oid));
|
|
144
205
|
});
|
|
145
206
|
const lookup = {
|
|
@@ -160,7 +221,8 @@ const placedReads = (input) => {
|
|
|
160
221
|
kept: places.length * 64
|
|
161
222
|
};
|
|
162
223
|
});
|
|
163
|
-
return { read: Effect.fnUntraced(function* (asked) {
|
|
224
|
+
return { read: Effect.fnUntraced(function* (asked, newLevel = true) {
|
|
225
|
+
if (newLevel || level === 0) level += 1;
|
|
164
226
|
const byPack = /* @__PURE__ */ new Map();
|
|
165
227
|
const beside = [];
|
|
166
228
|
for (const ask of asked) {
|
|
@@ -178,6 +240,10 @@ const placedReads = (input) => {
|
|
|
178
240
|
for (const [pack, group] of byPack) {
|
|
179
241
|
const listedPack = listedOf.get(pack.pack.id);
|
|
180
242
|
if (listedPack === void 0) return yield* Effect.fail(loss(`Pack ${pack.pack.id} isn't listed`));
|
|
243
|
+
if (packLastLevel.get(pack.pack.id) !== level) {
|
|
244
|
+
packLastLevel.set(pack.pack.id, level);
|
|
245
|
+
packLevels.set(pack.pack.id, (packLevels.get(pack.pack.id) ?? 0) + 1);
|
|
246
|
+
}
|
|
181
247
|
const loaded = read.loadedOf?.(listedPack);
|
|
182
248
|
const placed = loaded === void 0 ? yield* placedAt(pack, listedPack, group) : void 0;
|
|
183
249
|
kept += placed?.kept ?? 0;
|
|
@@ -202,4 +268,4 @@ const placedReads = (input) => {
|
|
|
202
268
|
};
|
|
203
269
|
/** The places of `positions` in `pack`, ascending. */
|
|
204
270
|
const placesOf = (pack, positions) => Uint32Array.from(positions, (position) => position - pack.base).sort();
|
|
205
|
-
export { placedReadGets, placedReads };
|
|
271
|
+
export { placedReadGets, placedReadGetsMost, placedReads };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { gitError } from "../contracts/result.mjs";
|
|
2
|
+
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
3
|
+
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
// src/storage/prune-seen.ts
|
|
7
|
+
/**
|
|
8
|
+
* #2019: the history objects a prune walk has seen, in place of a table of their IDs: a bit for
|
|
9
|
+
* each object of each listed pack, at its rank in the first pack that lists it, and for an object
|
|
10
|
+
* no listed pack holds, a row's or one listed since, its ID in a set of at most `outsideMost`. Its
|
|
11
|
+
* bytes grow with the repo's objects at an eighth of a byte each, never with what the walk reaches,
|
|
12
|
+
* and a part's save puts them whole, so the next try reads one object, not every ID reached.
|
|
13
|
+
*
|
|
14
|
+
* Its bits are kept by each pack's ID, not by where the listing names it, since a later try may
|
|
15
|
+
* list other packs: one a repack listed since reads back as nothing seen, and one it let go of
|
|
16
|
+
* takes its bits with it. What those packs held is seen again, so the walk reads it again, and
|
|
17
|
+
* the tree levels' merge drops the rows it reaches twice: work, never an object missed.
|
|
18
|
+
*/
|
|
19
|
+
/** A listed pack a seen set holds bits for: its ID and its objects, one bit each. */
|
|
20
|
+
const SeenPack = /* @__PURE__ */ Schema.Struct({
|
|
21
|
+
id: Schema.String,
|
|
22
|
+
objects: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* A seen set as a save names it: its object's key, and the layout of its bytes, each pack's bits
|
|
26
|
+
* in turn, then `outside` IDs of 20 bytes.
|
|
27
|
+
*/
|
|
28
|
+
const SeenSaved = /* @__PURE__ */ Schema.Struct({
|
|
29
|
+
key: Schema.String,
|
|
30
|
+
packs: Schema.Array(SeenPack),
|
|
31
|
+
outside: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))
|
|
32
|
+
});
|
|
33
|
+
/** The bytes of `packs`' bits and `outside` IDs, as a save puts them. */
|
|
34
|
+
const seenLength = (packs, outside) => packs.reduce((sum, pack) => sum + Math.ceil(pack.objects / 8), 0) + outside * 20;
|
|
35
|
+
/**
|
|
36
|
+
* A seen set over `packs`, at most `outsideMost` objects outside them, empty or from `from`, a
|
|
37
|
+
* save's bytes and layout: the bits of each pack the save and `packs` both hold, by its ID, and
|
|
38
|
+
* each outside ID. A pack the save doesn't hold starts with none seen, and one it holds that
|
|
39
|
+
* `packs` doesn't is let go: what it held is seen again where the walk finds it now. An ID outside
|
|
40
|
+
* the save's listing that `packs` now hold, as a fold of the rows lists them, is `from.place`'s
|
|
41
|
+
* bit, so only those still outside count. Bytes that aren't the layout's, or more outside IDs
|
|
42
|
+
* than `outsideMost` once placed, are `DATA_LOSS`.
|
|
43
|
+
*/
|
|
44
|
+
const seenSet = /* @__PURE__ */ Effect.fnUntraced(function* (packs, outsideMost, from) {
|
|
45
|
+
const bits = new Map(packs.map((pack) => [pack.id, new Uint8Array(Math.ceil(pack.objects / 8))]));
|
|
46
|
+
const outside = /* @__PURE__ */ new Set();
|
|
47
|
+
let count = 0;
|
|
48
|
+
/**
|
|
49
|
+
* Whether `oid`, at `at` or outside the listed packs, is seen for the first time, and marks it:
|
|
50
|
+
* `'full'` when it's outside and the set holds `outsideMost` such already.
|
|
51
|
+
*/
|
|
52
|
+
const add = (oid, at) => {
|
|
53
|
+
const set = at === void 0 ? void 0 : bits.get(at.pack);
|
|
54
|
+
if (set !== void 0 && at !== void 0) {
|
|
55
|
+
const byte = at.rank >>> 3;
|
|
56
|
+
const bit = 1 << (at.rank & 7);
|
|
57
|
+
if (((set[byte] ?? 0) & bit) !== 0) return false;
|
|
58
|
+
set[byte] = (set[byte] ?? 0) | bit;
|
|
59
|
+
count += 1;
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (outside.has(oid)) return false;
|
|
63
|
+
if (outside.size >= outsideMost) return "full";
|
|
64
|
+
outside.add(oid);
|
|
65
|
+
count += 1;
|
|
66
|
+
return true;
|
|
67
|
+
};
|
|
68
|
+
if (from !== void 0) {
|
|
69
|
+
const { saved, bytes, place } = from;
|
|
70
|
+
const length = seenLength(saved.packs, saved.outside);
|
|
71
|
+
if (bytes.byteLength !== length) return yield* Effect.fail(gitError("DATA_LOSS", `A walk's seen object holds ${bytes.byteLength} bytes; its save says ${length}`));
|
|
72
|
+
let at = 0;
|
|
73
|
+
for (const pack of saved.packs) {
|
|
74
|
+
const length = Math.ceil(pack.objects / 8);
|
|
75
|
+
const into = bits.get(pack.id);
|
|
76
|
+
const held = bytes.subarray(at, at + length);
|
|
77
|
+
at += length;
|
|
78
|
+
if (into?.byteLength !== length) continue;
|
|
79
|
+
into.set(held);
|
|
80
|
+
for (const byte of held) count += popCount(byte);
|
|
81
|
+
}
|
|
82
|
+
for (let first = 0; first < saved.outside; first += 64) {
|
|
83
|
+
const batch = [];
|
|
84
|
+
for (let id = first; id < Math.min(saved.outside, first + 64); id += 1) batch.push(hexOf(bytes.subarray(at + id * 20, at + id * 20 + 20)));
|
|
85
|
+
const placed = yield* place(batch);
|
|
86
|
+
for (const oid of batch) if (add(oid, placed.get(oid)) === "full") return yield* Effect.fail(gitError("DATA_LOSS", `A walk's save holds more than ${outsideMost} objects no listed pack holds`));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** The set's bytes, and the layout a save names them by under `key`. */
|
|
90
|
+
const saved = (key) => {
|
|
91
|
+
const layout = {
|
|
92
|
+
key,
|
|
93
|
+
packs: packs.map(({ id, objects }) => ({
|
|
94
|
+
id,
|
|
95
|
+
objects
|
|
96
|
+
})),
|
|
97
|
+
outside: outside.size
|
|
98
|
+
};
|
|
99
|
+
const bytes = new Uint8Array(seenLength(layout.packs, layout.outside));
|
|
100
|
+
let at = 0;
|
|
101
|
+
for (const pack of packs) {
|
|
102
|
+
const set = bits.get(pack.id);
|
|
103
|
+
if (set !== void 0) bytes.set(set, at);
|
|
104
|
+
at += Math.ceil(pack.objects / 8);
|
|
105
|
+
}
|
|
106
|
+
for (const oid of [...outside].sort()) {
|
|
107
|
+
bytes.set(oidBytes(oid), at);
|
|
108
|
+
at += 20;
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
layout,
|
|
112
|
+
bytes
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
return {
|
|
116
|
+
add,
|
|
117
|
+
saved,
|
|
118
|
+
size: () => count
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
const popCount = (byte) => {
|
|
122
|
+
let bits = 0;
|
|
123
|
+
for (let rest = byte; rest !== 0; rest &= rest - 1) bits += 1;
|
|
124
|
+
return bits;
|
|
125
|
+
};
|
|
126
|
+
export { SeenSaved, seenLength, seenSet };
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
3
3
|
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
4
|
-
import { checkTypesHeader, typeAt, typeCode } from "../protocol/packs/types-file.mjs";
|
|
5
4
|
import { bestEffort } from "../store/errors.mjs";
|
|
6
5
|
import { randomText } from "../store/random.mjs";
|
|
7
6
|
import { readerFloors, readerMost } from "./budget.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
7
|
+
import { readWhole } from "./calls.mjs";
|
|
8
|
+
import { putOnce } from "./index-build.mjs";
|
|
9
|
+
import { runKey } from "./layout.mjs";
|
|
10
|
+
import { pruneSeenBytes, upkeepMemoryOf, upkeepRuns, upkeepTooLarge } from "./memory-budget.mjs";
|
|
12
11
|
import { blockBytes, blocksHeld, indexBytes, packReader } from "./pack-reads.mjs";
|
|
13
|
-
import {
|
|
12
|
+
import { SeenSaved, seenSet } from "./prune-seen.mjs";
|
|
13
|
+
import { StoredRuns, dedupeTableBytes, dropRuns, mergeHeld, mergeRuns, narrowed, narrowedCalls, runWriter, writerHeld } from "./runs.mjs";
|
|
14
14
|
import { countedReads } from "./walk.mjs";
|
|
15
|
-
import * as Schema from "effect/Schema";
|
|
16
15
|
import * as Effect from "effect/Effect";
|
|
16
|
+
import * as Schema from "effect/Schema";
|
|
17
17
|
import * as Data from "effect/Data";
|
|
18
18
|
// src/storage/prune-walk.ts
|
|
19
|
-
/**
|
|
20
|
-
* The most history objects, commits and tags, a prune pass's walk holds in its table: about
|
|
21
|
-
* 34 MB at `historySlotBytes` (maintenance-1m, invariant 2). A repo past it is refused by name.
|
|
22
|
-
*/
|
|
23
|
-
const pruneCommitsMost = 1e6;
|
|
24
19
|
/** The tree IDs a level reads at once, in pack order, at `fetchEntryBytes` each: about 9.2 MB. */
|
|
25
20
|
const pruneTreesAtOnce = 131072;
|
|
26
21
|
/** The bytes of a reached run, and of a frontier's. */
|
|
@@ -46,8 +41,6 @@ const frontierDedupe = {
|
|
|
46
41
|
},
|
|
47
42
|
hash: (bytes, at) => (bytes[at] ?? 0) << 24 | (bytes[at + 1] ?? 0) << 16 | (bytes[at + 2] ?? 0) << 8 | (bytes[at + 3] ?? 0)
|
|
48
43
|
};
|
|
49
|
-
/** The history table's bytes a slot: a 20-byte ID, at most 60% full, so about 34 B an object. */
|
|
50
|
-
const historySlotBytes = 20;
|
|
51
44
|
/** `a`'s runs and `b`'s, of one width, as one: `kind` names where a merge of them narrows. */
|
|
52
45
|
const joined = (a, b, kind = a.kind) => {
|
|
53
46
|
const { keys, lengths, rows } = b;
|
|
@@ -90,33 +83,31 @@ const pruneWalkSizes = (objects, blocks) => {
|
|
|
90
83
|
/** A walk's sizes at its bounds, the most any repo's take. */
|
|
91
84
|
const boundSizes = /* @__PURE__ */ pruneWalkSizes(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
92
85
|
/**
|
|
93
|
-
* What a walk at `sizes` holds besides its
|
|
86
|
+
* What a walk at `sizes` holds besides its seen set and its reader's: its trees, its
|
|
94
87
|
* writers and the frontier's dedupe table, and its merge. At the bounds unless given.
|
|
95
88
|
*/
|
|
96
89
|
const pruneWalkTables = (sizes = boundSizes) => sizes.trees * 70 + 2 * writerHeld(rowBytes, sizes.runBytes) + dedupeTableBytes(sizes.runBytes, rowBytes) + mergeHeld(rowBytes, sizes.runs);
|
|
97
|
-
/** The slots a history table for `count` objects is made with, so it's at most 60% full. */
|
|
98
|
-
const historySlots = (count) => Math.max(1, Math.ceil(count * 5 / 3));
|
|
99
90
|
/**
|
|
100
|
-
* What a walk
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* invariant 2).
|
|
91
|
+
* What a walk at `sizes` holds at its most besides its seen set, the IDs it starts from and its
|
|
92
|
+
* reader's indexes: its tables, and its reader's blocks and cache at their most. At the bounds
|
|
93
|
+
* unless given.
|
|
104
94
|
*/
|
|
105
|
-
const pruneWalkHeld = (
|
|
95
|
+
const pruneWalkHeld = (sizes = boundSizes) => pruneWalkTables(sizes) + sizes.blocks + readerMost.cache;
|
|
106
96
|
/** A save's count, checked as a row's is, so a bad one is refused at its decode. */
|
|
107
97
|
const Count = /* @__PURE__ */ Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
108
98
|
/** The ID a save's merge stopped at, likewise. */
|
|
109
99
|
const LastId = /* @__PURE__ */ Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}$/));
|
|
110
100
|
/**
|
|
111
101
|
* Where a walk stopped, for its next try to go on from, as `PruneStarted.walk` holds it: in its
|
|
112
|
-
* history, the runs it has put, the IDs it has yet to read
|
|
113
|
-
* level, the runs reached so far and the next level's
|
|
114
|
-
* level after it. `refs` holds the `start` its first
|
|
102
|
+
* history, the runs it has put, the IDs it has yet to read, how many history objects it has seen
|
|
103
|
+
* and its seen set's object; or after a tree level, the runs reached so far and the next level's
|
|
104
|
+
* frontier, and with `at` partway through the level after it. `refs` holds the `start` its first
|
|
115
105
|
* try was given, which a later try walks from whatever the refs are then.
|
|
116
106
|
*/
|
|
117
107
|
const WalkSaved = /* @__PURE__ */ Schema.Union([Schema.Struct({
|
|
118
108
|
phase: Schema.Literal("history"),
|
|
119
109
|
count: Count,
|
|
110
|
+
seen: SeenSaved,
|
|
120
111
|
refs: StoredRuns,
|
|
121
112
|
reached: StoredRuns,
|
|
122
113
|
frontier: StoredRuns,
|
|
@@ -142,67 +133,30 @@ const fits = (calls, needs) => {
|
|
|
142
133
|
const made = calls.made();
|
|
143
134
|
return made.bucket + needs < calls.most.bucket && made.subrequests + needs < calls.most.subrequests;
|
|
144
135
|
};
|
|
145
|
-
/**
|
|
146
|
-
* A walk refused: its history past `pruneCommitsMost`, its charge past its allotment, or one step
|
|
147
|
-
* past a whole try's calls.
|
|
148
|
-
*/
|
|
136
|
+
/** A walk refused: its charge past its allotment, or one step past a whole try's calls. */
|
|
149
137
|
var PruneWalkTooLarge = class extends Data.TaggedError("PruneWalkTooLarge") {};
|
|
150
|
-
/** The all-zero ID, which names no object: a free slot's. */
|
|
151
|
-
const empty = /* @__PURE__ */ new Uint8Array(20);
|
|
152
|
-
/** Whether the 20-byte IDs at `a`'s `at` and `b`'s `bt` are one. */
|
|
153
|
-
const sameId = (a, at, b, bt) => {
|
|
154
|
-
for (let i = 0; i < 20; i += 1) if (a[at + i] !== b[bt + i]) return false;
|
|
155
|
-
return true;
|
|
156
|
-
};
|
|
157
138
|
/**
|
|
158
|
-
* The
|
|
159
|
-
*
|
|
139
|
+
* The bucket keys `saved` names: its runs, and in its history its seen set's object, so a pass
|
|
140
|
+
* that drops what its walks left can keep what its mark still reads.
|
|
160
141
|
*/
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
add,
|
|
179
|
-
size: () => size
|
|
180
|
-
};
|
|
142
|
+
const walkKeys = (saved) => {
|
|
143
|
+
const keys = (saved.phase === "history" ? [
|
|
144
|
+
saved.refs,
|
|
145
|
+
saved.reached,
|
|
146
|
+
saved.frontier,
|
|
147
|
+
saved.pending,
|
|
148
|
+
saved.known
|
|
149
|
+
] : [
|
|
150
|
+
saved.refs,
|
|
151
|
+
saved.reached,
|
|
152
|
+
saved.frontier,
|
|
153
|
+
saved.at?.reached,
|
|
154
|
+
saved.at?.frontier,
|
|
155
|
+
saved.at?.trees
|
|
156
|
+
]).flatMap((each) => each?.keys ?? []);
|
|
157
|
+
return saved.phase === "history" ? [...keys, saved.seen.key] : keys;
|
|
181
158
|
};
|
|
182
159
|
/**
|
|
183
|
-
* The most history objects a walk from `refs` can reach: the commits and tags the listed packs'
|
|
184
|
-
* `.types` count, an object each tag names, each ref's own and each of `rows` object rows. Read
|
|
185
|
-
* by range, `typesRunRanks` bytes at a time.
|
|
186
|
-
*/
|
|
187
|
-
const historyCount = /* @__PURE__ */ Effect.fnUntraced(function* (input, refs, rows) {
|
|
188
|
-
const commit = typeCode("commit");
|
|
189
|
-
const tag = typeCode("tag");
|
|
190
|
-
let commits = 0;
|
|
191
|
-
let tags = 0;
|
|
192
|
-
for (const pack of input.listed.packs) {
|
|
193
|
-
const key = isPackId(pack.id) ? packFiles(pack.id).types : pack.id;
|
|
194
|
-
const head = yield* readExactly(input.bucket, key, 0, 12);
|
|
195
|
-
yield* Effect.mapError(checkTypesHeader(head, pack.objects), (error) => gitError("DATA_LOSS", `Pack ${pack.id}'s types: ${error.message}`));
|
|
196
|
-
for (let rank = 0; rank < pack.objects; rank += typesRunRanks) {
|
|
197
|
-
const length = Math.min(typesRunRanks, pack.objects - rank);
|
|
198
|
-
const types = yield* readExactly(input.bucket, key, typeAt(rank), length);
|
|
199
|
-
for (const byte of types) if (byte === commit) commits += 1;
|
|
200
|
-
else if (byte === tag) tags += 1;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return commits + 2 * tags + refs + rows;
|
|
204
|
-
});
|
|
205
|
-
/**
|
|
206
160
|
* `walk` in its own scope, a fresh walk's runs dropped once it's refused, so it keeps none. A walk
|
|
207
161
|
* that goes on from `saved` or `known` keeps them: the pass's mark names them, and the parked
|
|
208
162
|
* pass's retry goes on from there.
|
|
@@ -210,7 +164,8 @@ const historyCount = /* @__PURE__ */ Effect.fnUntraced(function* (input, refs, r
|
|
|
210
164
|
const droppedOnRefusal = (walk, input, pack, _start, _missing, options = {}) => Effect.tapError(Effect.scoped(walk), (error) => error instanceof PruneWalkTooLarge && options.saved === void 0 && options.known === void 0 ? bestEffort(dropRuns(input.bucket, pack)) : Effect.void);
|
|
211
165
|
/**
|
|
212
166
|
* Every object `start` reaches, as reached runs under `pack`: the history first, commits and tags
|
|
213
|
-
* in a
|
|
167
|
+
* each marked in a seen set of a bit an object of the listed packs; then the trees a level at a
|
|
168
|
+
* time, each level's
|
|
214
169
|
* frontier merged against the runs reached so far, which the merge carries on as the next
|
|
215
170
|
* level's, so a tree is read once and a blob put once, by the ID its tree names and never read.
|
|
216
171
|
* `missing` says what an object the repo doesn't hold does to the walk: a tree it passes over is
|
|
@@ -222,10 +177,10 @@ const droppedOnRefusal = (walk, input, pack, _start, _missing, options = {}) =>
|
|
|
222
177
|
* try given it as `saved` goes on from there, never from `start`. A batch reads as many objects as
|
|
223
178
|
* their delta chains' gets fit. A step that passes a whole try is refused by name.
|
|
224
179
|
* `known`'s rows, from an earlier walk, are reached already: a tree they hold isn't read again.
|
|
225
|
-
* A refused fresh walk drops its runs; one given `saved` or `known` keeps them. A test sets
|
|
226
|
-
*
|
|
180
|
+
* A refused fresh walk drops its runs; one given `saved` or `known` keeps them. A test sets
|
|
181
|
+
* `treesAtOnce` below its bound.
|
|
227
182
|
*/
|
|
228
|
-
const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, start, missing, { rows = 0,
|
|
183
|
+
const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, start, missing, { rows = 0, treesAtOnce = pruneTreesAtOnce, calls, saved, known } = {}) {
|
|
229
184
|
const { allotment, listed } = input;
|
|
230
185
|
const objects = listed.packs.reduce((sum, each) => sum + each.objects, 0) + rows;
|
|
231
186
|
const blocks = listed.packs.reduce((sum, each) => sum + Math.ceil(each.bytes / blockBytes), 0);
|
|
@@ -238,14 +193,14 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
238
193
|
const knownRuns = history?.known ?? known;
|
|
239
194
|
if (knownRuns !== void 0 && knownRuns.width !== rowBytes) return yield* Effect.fail(gitError("DATA_LOSS", `The known runs are not ${rowBytes}-byte rows`));
|
|
240
195
|
const named = new Set(start).size;
|
|
241
|
-
const
|
|
196
|
+
const outsideMost = rows + named;
|
|
242
197
|
const namesBytes = (saved === void 0 ? named : history?.pending.rows ?? 0) * 70;
|
|
243
|
-
const
|
|
198
|
+
const seenBytes = saved?.phase === "trees" ? 0 : pruneSeenBytes(listed.packs, outsideMost);
|
|
244
199
|
const indexes = listed.packs.reduce((sum, each) => sum + indexBytes(each), 0);
|
|
245
|
-
const charge = pruneWalkHeld(
|
|
200
|
+
const charge = pruneWalkHeld(sizes) + namesBytes + seenBytes + indexes;
|
|
246
201
|
if (charge - own > allotment.growable) return yield* new PruneWalkTooLarge({ message: `its walk charges ${charge} bytes with its packs' indexes, past the ${own + allotment.growable} its allotment holds: the repo is past what one prune walk holds` });
|
|
247
|
-
|
|
248
|
-
|
|
202
|
+
const heldBytes = namesBytes + seenBytes;
|
|
203
|
+
yield* Effect.acquireRelease(allotment.grow(heldBytes, upkeepTooLarge), () => Effect.sync(() => allotment.shrink(heldBytes)));
|
|
249
204
|
const reader = packReader({
|
|
250
205
|
...input,
|
|
251
206
|
memory
|
|
@@ -260,6 +215,25 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
260
215
|
allotment.shrink(bytes);
|
|
261
216
|
});
|
|
262
217
|
const reads = countedReads(reader, objects + 1e6, charged, void 0, release);
|
|
218
|
+
/** Where each of `oids` is for the seen set: its first listed pack and its rank there. */
|
|
219
|
+
const ranksOf = Effect.fnUntraced(function* (oids) {
|
|
220
|
+
const at = /* @__PURE__ */ new Map();
|
|
221
|
+
let left = [...oids];
|
|
222
|
+
for (const pack of listed.packs) {
|
|
223
|
+
if (left.length === 0) break;
|
|
224
|
+
const { index } = yield* reader.indexed(pack);
|
|
225
|
+
left = left.filter((oid) => {
|
|
226
|
+
const rank = index.rankOf(oid);
|
|
227
|
+
if (rank === void 0) return true;
|
|
228
|
+
at.set(oid, {
|
|
229
|
+
pack: pack.id,
|
|
230
|
+
rank
|
|
231
|
+
});
|
|
232
|
+
return false;
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return at;
|
|
236
|
+
});
|
|
263
237
|
/** Lets go of what `found` holds of `batch`, once each of it is put. */
|
|
264
238
|
const letGo = (found, batch) => {
|
|
265
239
|
for (const object of found.values()) reads.letGo(object);
|
|
@@ -388,9 +362,16 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
388
362
|
let names = [...new Set(start)];
|
|
389
363
|
let parents = [];
|
|
390
364
|
let prior;
|
|
365
|
+
let seenFrom;
|
|
391
366
|
if (history !== void 0) {
|
|
392
|
-
const rebuild =
|
|
367
|
+
const rebuild = narrowedCalls(history.reached.lengths, rowBytes, sizes.runs, input.bucket.multipart).calls + narrowedCalls(history.frontier.lengths, rowBytes, sizes.runs, input.bucket.multipart).calls + mergeCalls(history.pending) + 1;
|
|
393
368
|
if (!fits(calls, rebuild + 6)) return yield* tooMany("a history resume", rebuild + 6);
|
|
369
|
+
const bytes = yield* readWhole(input.bucket, history.seen.key);
|
|
370
|
+
if (bytes === void 0) return yield* Effect.fail(gitError("DATA_LOSS", `The walk's seen object ${history.seen.key} is gone`));
|
|
371
|
+
seenFrom = {
|
|
372
|
+
saved: history.seen,
|
|
373
|
+
bytes
|
|
374
|
+
};
|
|
394
375
|
const narrow = (runs, kind) => narrowed(input.bucket, pack, {
|
|
395
376
|
...runs,
|
|
396
377
|
kind: `${kind}.${tried}`
|
|
@@ -400,9 +381,12 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
400
381
|
frontier: yield* narrow(history.frontier, "frontier-h")
|
|
401
382
|
};
|
|
402
383
|
names = [];
|
|
403
|
-
yield* eachOf(prior.reached, (id) => void table.add(id));
|
|
404
384
|
yield* eachOf(history.pending, (id, tag) => (tag === tags.tree ? names : parents).push(hexOf(id)));
|
|
405
385
|
}
|
|
386
|
+
const seen = yield* seenSet(listed.packs, outsideMost, seenFrom === void 0 ? void 0 : {
|
|
387
|
+
...seenFrom,
|
|
388
|
+
place: ranksOf
|
|
389
|
+
});
|
|
406
390
|
const reached = writer("reached-0", sizes.runBytes);
|
|
407
391
|
const frontier = frontierWriter("frontier-0");
|
|
408
392
|
while (names.length > 0 || parents.length > 0) {
|
|
@@ -412,7 +396,7 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
412
396
|
else parents = [];
|
|
413
397
|
for (let at = 0; at < level.length;) {
|
|
414
398
|
const left = level.length - at + names.length + parents.length;
|
|
415
|
-
const { count: admits, needs } = yield* admitted(level.slice(at, at + 64),
|
|
399
|
+
const { count: admits, needs } = yield* admitted(level.slice(at, at + 64), 5 + putCalls(left));
|
|
416
400
|
if (admits === 0) {
|
|
417
401
|
if (!moved) return yield* tooMany("a history batch", needs);
|
|
418
402
|
const reachedRuns = yield* reached.finish;
|
|
@@ -421,9 +405,13 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
421
405
|
const rest = level.slice(at);
|
|
422
406
|
for (const oid of fromNames ? [...rest, ...names] : names) yield* put(pending, oidBytes(oid), tags.tree);
|
|
423
407
|
for (const oid of fromNames ? parents : [...rest, ...parents]) yield* put(pending, oidBytes(oid), tags.reached);
|
|
408
|
+
const key = runKey(pack, `seen.${tried}`, 0);
|
|
409
|
+
const { layout, bytes } = seen.saved(key);
|
|
410
|
+
yield* putOnce(input.bucket, key, bytes);
|
|
424
411
|
return { more: {
|
|
425
412
|
phase: "history",
|
|
426
|
-
count,
|
|
413
|
+
count: seen.size(),
|
|
414
|
+
seen: layout,
|
|
427
415
|
refs,
|
|
428
416
|
reached: after(prior?.reached, reachedRuns),
|
|
429
417
|
frontier: after(prior?.frontier, frontierRuns),
|
|
@@ -435,12 +423,12 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
435
423
|
const slice = level.slice(at, at + admits);
|
|
436
424
|
at += admits;
|
|
437
425
|
const blobs = fromNames ? yield* reader.wholeBlobs(slice) : /* @__PURE__ */ new Set();
|
|
426
|
+
const ranked = yield* ranksOf(slice);
|
|
438
427
|
const batch = [];
|
|
439
428
|
for (const oid of slice) {
|
|
440
429
|
const id = oidBytes(oid);
|
|
441
|
-
const added =
|
|
442
|
-
if (added === "full"
|
|
443
|
-
if (added === "full") return yield* Effect.fail(gitError("DATA_LOSS", `The packs' types count ${count} history objects: the walk reaches more`));
|
|
430
|
+
const added = seen.add(oid, ranked.get(oid));
|
|
431
|
+
if (added === "full") return yield* Effect.fail(gitError("DATA_LOSS", `The walk reaches more than ${outsideMost} objects no listed pack holds: past its rows and refs`));
|
|
444
432
|
if (!added) continue;
|
|
445
433
|
if (blobs.has(oid)) yield* put(reached, id, tags.reached);
|
|
446
434
|
else batch.push(oid);
|
|
@@ -465,7 +453,7 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
465
453
|
runs = after(prior?.reached, yield* reached.finish);
|
|
466
454
|
next = after(prior?.frontier, yield* frontier.finish);
|
|
467
455
|
if (knownRuns !== void 0) runs = joined(runs, knownRuns);
|
|
468
|
-
commits =
|
|
456
|
+
commits = seen.size();
|
|
469
457
|
}
|
|
470
458
|
let within = saved?.phase === "trees" ? saved.at : void 0;
|
|
471
459
|
for (let depth = from + 1; next.rows > 0; depth += 1) {
|
|
@@ -575,4 +563,4 @@ const pruneWalk = /* @__PURE__ */ Effect.fnUntraced(function* (input, pack, star
|
|
|
575
563
|
refs
|
|
576
564
|
};
|
|
577
565
|
}, droppedOnRefusal);
|
|
578
|
-
export { PruneWalkTooLarge, WalkSaved,
|
|
566
|
+
export { PruneWalkTooLarge, WalkSaved, pruneTreesAtOnce, pruneWalk, pruneWalkHeld, pruneWalkSizes, pruneWalkTables, reachedRunBytes, walkKeys };
|