@ref0/git 0.2.0 → 0.4.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/_virtual/_rolldown/runtime.mjs +12 -0
- package/dist/access/private-refs.d.mts +12 -9
- package/dist/access/private-refs.mjs +69 -46
- package/dist/auth/access-jwt.mjs +7 -7
- package/dist/auth/auth.d.mts +41 -0
- package/dist/auth/auth.mjs +39 -0
- package/dist/auth/authorize.mjs +57 -80
- package/dist/auth/bridge.mjs +30 -0
- package/dist/auth/fences.d.mts +23 -3
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.d.mts +25 -0
- package/dist/auth/grants.mjs +29 -34
- package/dist/auth/helpers.mjs +4 -4
- package/dist/auth/host-function.d.mts +9 -2
- package/dist/auth/host-function.mjs +36 -9
- package/dist/auth/identify.d.mts +4 -1
- package/dist/auth/identify.mjs +9 -11
- package/dist/auth/namespaces.d.mts +3 -0
- package/dist/auth/policy.d.mts +57 -0
- package/dist/auth/policy.mjs +56 -0
- package/dist/auth/token-rows.mjs +6 -6
- package/dist/auth/token-text.mjs +16 -4
- package/dist/auth/tokens.d.mts +4 -1
- package/dist/auth/tokens.mjs +51 -13
- package/dist/auth.d.mts +2 -1
- package/dist/auth.mjs +2 -1
- package/dist/client/answer.mjs +49 -11
- package/dist/client/client.d.mts +2 -2
- package/dist/client/client.mjs +5 -6
- package/dist/client/git-http.d.mts +6 -0
- package/dist/client/git-http.mjs +23 -36
- package/dist/client/helper-node.d.mts +12 -0
- package/dist/client/helper-node.mjs +108 -5
- package/dist/client/local.mjs +97 -92
- package/dist/client/negotiate.mjs +10 -8
- package/dist/client/push-upload.d.mts +14 -0
- package/dist/client/push-upload.mjs +12 -12
- package/dist/client/remote-helper.mjs +22 -20
- package/dist/client/remote.mjs +28 -22
- package/dist/client/run-remote-helper.d.mts +40 -16
- package/dist/client/run-remote-helper.mjs +147 -154
- package/dist/client/scrub.d.mts +8 -2
- package/dist/client/scrub.mjs +76 -4
- package/dist/client/slice-push.d.mts +77 -0
- package/dist/client/slice-push.mjs +169 -0
- package/dist/client/slice-report.mjs +188 -0
- package/dist/client/slices.d.mts +44 -0
- package/dist/client/slices.mjs +131 -0
- package/dist/client/transport.d.mts +1 -0
- package/dist/client/transport.mjs +30 -26
- package/dist/contracts/access.d.mts +36 -9
- package/dist/contracts/actors.d.mts +28 -10
- package/dist/contracts/actors.mjs +17 -0
- package/dist/contracts/authorize.d.mts +77 -0
- package/dist/contracts/authorize.mjs +25 -0
- package/dist/contracts/blobs.d.mts +48 -15
- package/dist/contracts/blobs.mjs +30 -0
- package/dist/contracts/calls-spent.d.mts +1 -0
- package/dist/contracts/calls-spent.mjs +60 -19
- package/dist/contracts/client.d.mts +14 -16
- package/dist/contracts/commits.d.mts +558 -76
- package/dist/contracts/commits.mjs +147 -0
- package/dist/contracts/engine.d.mts +91 -55
- package/dist/contracts/engine.mjs +103 -0
- package/dist/contracts/events.d.mts +1382 -205
- package/dist/contracts/events.mjs +485 -0
- package/dist/contracts/files.d.mts +295 -50
- package/dist/contracts/files.mjs +100 -0
- package/dist/contracts/forks.d.mts +306 -25
- package/dist/contracts/forks.mjs +39 -0
- package/dist/contracts/git.d.mts +107 -0
- package/dist/contracts/git.mjs +23 -0
- package/dist/contracts/grants.d.mts +2 -2
- package/dist/contracts/handlers.d.mts +2 -1
- package/dist/contracts/ids.d.mts +23 -8
- package/dist/contracts/ids.mjs +40 -5
- package/dist/contracts/lfs.d.mts +9 -4
- package/dist/contracts/merges.d.mts +68 -16
- package/dist/contracts/merges.mjs +27 -0
- package/dist/contracts/namespaces.d.mts +14 -0
- package/dist/contracts/object-values.d.mts +96 -0
- package/dist/contracts/object-values.mjs +104 -0
- package/dist/contracts/objects.d.mts +324 -88
- package/dist/contracts/operations.d.mts +24 -16
- package/dist/contracts/promises.d.mts +17 -31
- package/dist/contracts/promises.mjs +13 -0
- package/dist/contracts/push-uploads.d.mts +39 -24
- package/dist/contracts/push-uploads.mjs +54 -0
- package/dist/contracts/queue.d.mts +445 -139
- package/dist/contracts/queue.mjs +197 -0
- package/dist/contracts/refs.d.mts +248 -45
- package/dist/contracts/refs.mjs +117 -0
- package/dist/contracts/repo-records.d.mts +34 -0
- package/dist/contracts/repo-records.mjs +18 -0
- package/dist/contracts/repos.d.mts +411 -58
- package/dist/contracts/repos.mjs +136 -0
- package/dist/contracts/result.d.mts +342 -69
- package/dist/contracts/result.mjs +350 -5
- package/dist/contracts/rules.d.mts +60 -48
- package/dist/contracts/rules.mjs +9 -0
- package/dist/contracts/server.d.mts +173 -80
- package/dist/contracts/services.d.mts +15 -24
- package/dist/contracts/services.mjs +5 -9
- package/dist/contracts/signin.d.mts +64 -31
- package/dist/contracts/signin.mjs +18 -0
- package/dist/contracts/store.d.mts +45 -5
- package/dist/contracts/store.mjs +31 -0
- package/dist/contracts/sync.d.mts +82 -47
- package/dist/contracts/sync.mjs +41 -2
- package/dist/contracts/tags.d.mts +204 -22
- package/dist/contracts/tags.mjs +51 -1
- package/dist/contracts/tokens.d.mts +32 -7
- package/dist/contracts/tokens.mjs +31 -1
- package/dist/contracts/topics.d.mts +128 -66
- package/dist/contracts/topics.mjs +109 -0
- package/dist/contracts/trees.d.mts +132 -52
- package/dist/contracts/trees.mjs +105 -0
- package/dist/contracts/work.d.mts +127 -20
- package/dist/contracts/work.mjs +69 -0
- package/dist/core/access.d.mts +26 -15
- package/dist/core/access.mjs +77 -108
- package/dist/core/ancestry.mjs +86 -18
- package/dist/core/call-names.d.mts +1 -0
- package/dist/core/call-names.mjs +94 -0
- package/dist/core/call-services.mjs +73 -0
- package/dist/core/changes.d.mts +31 -0
- package/dist/core/changes.mjs +5 -0
- package/dist/core/clock.mjs +3 -3
- package/dist/core/events/deliver.mjs +130 -37
- package/dist/core/events/seen.mjs +124 -0
- package/dist/core/forks.mjs +371 -159
- package/dist/core/hooks/order.d.mts +9 -0
- package/dist/core/hooks/order.mjs +25 -0
- package/dist/core/hooks/post-receive.mjs +25 -16
- package/dist/core/hooks/pre-receive.d.mts +8 -1
- package/dist/core/hooks/pre-receive.mjs +8 -6
- package/dist/core/imports.mjs +212 -0
- package/dist/core/index-job.mjs +131 -38
- package/dist/core/merge-parts.d.mts +30 -0
- package/dist/core/merge-parts.mjs +31 -0
- package/dist/core/names.mjs +4 -16
- package/dist/core/namespaces.d.mts +2 -0
- package/dist/core/objects/blobs.mjs +4 -4
- package/dist/core/objects/commit-writes.mjs +19 -17
- package/dist/core/objects/commits.mjs +12 -12
- package/dist/core/objects/files.mjs +10 -11
- package/dist/core/objects/lines.mjs +15 -32
- package/dist/core/objects/merges.mjs +4 -4
- package/dist/core/objects/objects-layer.d.mts +21 -0
- package/dist/core/objects/objects-layer.mjs +47 -0
- package/dist/core/objects/objects-namespace.d.mts +6 -0
- package/dist/core/objects/objects-namespace.mjs +13 -0
- package/dist/core/objects/objects.d.mts +49 -0
- package/dist/core/objects/objects.mjs +18 -0
- package/dist/core/objects/peel.mjs +3 -3
- package/dist/core/objects/reading.mjs +135 -40
- package/dist/core/objects/tags.mjs +7 -7
- package/dist/core/objects/tree-edits.mjs +40 -27
- package/dist/core/objects/trees.mjs +23 -18
- package/dist/core/objects/writing.mjs +43 -44
- package/dist/core/own-writes.mjs +3 -3
- package/dist/core/parts.d.mts +125 -0
- package/dist/core/parts.mjs +59 -0
- package/dist/core/promise.mjs +39 -17
- package/dist/core/publish.mjs +27 -17
- package/dist/core/purge.mjs +242 -0
- package/dist/core/push-decide.mjs +93 -28
- package/dist/core/push.mjs +301 -156
- package/dist/core/receipts.d.mts +4 -3
- package/dist/core/receipts.mjs +20 -12
- package/dist/core/ref-conflicts.mjs +70 -4
- package/dist/core/ref-index-job.mjs +181 -0
- package/dist/core/ref-index.d.mts +25 -0
- package/dist/core/ref-index.mjs +136 -0
- package/dist/core/ref-view.mjs +166 -0
- package/dist/core/refs.mjs +313 -95
- package/dist/core/repack.d.mts +10 -0
- package/dist/core/repack.mjs +261 -81
- package/dist/core/repo-info.mjs +99 -0
- package/dist/core/repos.mjs +114 -80
- package/dist/core/rules/changes.mjs +48 -20
- package/dist/core/rules/check.mjs +29 -22
- package/dist/core/rules/commit-changes.d.mts +13 -0
- package/dist/core/rules/commit-changes.mjs +100 -91
- package/dist/core/rules/context.d.mts +67 -8
- package/dist/core/rules/context.mjs +88 -51
- package/dist/core/rules/facts.mjs +1 -1
- package/dist/core/rules/fetch.mjs +24 -26
- package/dist/core/rules/files.d.mts +13 -0
- package/dist/core/rules/files.mjs +27 -28
- package/dist/core/rules/namespace.d.mts +2 -0
- package/dist/core/rules/patterns.mjs +29 -5
- package/dist/core/rules/protect.d.mts +12 -6
- package/dist/core/rules/protect.mjs +22 -20
- package/dist/core/rules/rules-layer.d.mts +17 -0
- package/dist/core/rules/rules-layer.mjs +26 -0
- package/dist/core/rules/rules.d.mts +8 -0
- package/dist/core/rules/rules.mjs +16 -0
- package/dist/core/rules/service.mjs +18 -0
- package/dist/core/seam.d.mts +10 -5
- package/dist/core/seam.mjs +36 -19
- package/dist/core/tokens.mjs +29 -23
- package/dist/core/view.d.mts +105 -6
- package/dist/core/view.mjs +211 -109
- package/dist/core/work.mjs +40 -14
- package/dist/effect.d.mts +3 -4
- package/dist/effect.mjs +2 -3
- package/dist/engine/allotted-xdiff.d.mts +1 -0
- package/dist/engine/allotted-xdiff.mjs +1 -1
- package/dist/engine/attributes.mjs +1 -1
- package/dist/engine/combined.d.mts +18 -0
- package/dist/engine/combined.mjs +39 -44
- package/dist/engine/commits.mjs +5 -4
- package/dist/engine/content.d.mts +3 -2
- package/dist/engine/content.mjs +2 -2
- package/dist/engine/failures.d.mts +2 -2
- package/dist/engine/failures.mjs +2 -9
- package/dist/engine/merge-base-walk.d.mts +3 -2
- package/dist/engine/merge-base-walk.mjs +1 -1
- package/dist/engine/merge-bases.mjs +3 -2
- package/dist/engine/merge.mjs +568 -566
- package/dist/engine/parts.d.mts +3 -2
- package/dist/engine/parts.mjs +40 -7
- package/dist/engine/reads.d.mts +1 -0
- package/dist/engine/reads.mjs +5 -5
- package/dist/engine/walk.mjs +23 -24
- package/dist/engine/xdiff.d.mts +2 -33
- package/dist/engine/xdiff.mjs +6 -3
- package/dist/event-streams/event-streams.d.mts +25 -0
- package/dist/event-streams/event-streams.mjs +22 -0
- package/dist/event-streams/namespace.d.mts +2 -0
- package/dist/event-streams/stream.d.mts +42 -0
- package/dist/{core/events → event-streams}/stream.mjs +112 -48
- package/dist/extend.d.mts +5 -2
- package/dist/extend.mjs +3 -1
- package/dist/http/answers.mjs +8 -4
- package/dist/http/bodies.mjs +84 -56
- package/dist/http/core-parts.mjs +206 -60
- package/dist/http/handler.d.mts +2 -0
- package/dist/http/handler.mjs +17 -11
- package/dist/http/node.mjs +10 -6
- package/dist/http/parts.d.mts +12 -0
- package/dist/http/push-uploads.d.mts +9 -0
- package/dist/http/push-uploads.mjs +76 -66
- package/dist/http/receive-pack.mjs +162 -28
- package/dist/http/upload-pack.mjs +106 -81
- package/dist/index.d.mts +48 -28
- package/dist/index.mjs +29 -7
- package/dist/lfs/calls.mjs +2 -2
- package/dist/lfs/locks.mjs +24 -20
- package/dist/lfs/objects.d.mts +7 -0
- package/dist/lfs/objects.mjs +32 -27
- package/dist/lfs/pointers.mjs +7 -7
- package/dist/lfs/purge.mjs +50 -0
- package/dist/lfs/repo.mjs +5 -5
- package/dist/lfs/rows.mjs +9 -9
- package/dist/lfs/service.d.mts +9 -0
- package/dist/lfs/service.mjs +32 -25
- package/dist/lfs/upkeep.mjs +5 -5
- package/dist/lfs/wire.mjs +80 -38
- package/dist/merges/merges.d.mts +20 -0
- package/dist/merges/merges.mjs +32 -0
- package/dist/merges/namespace.d.mts +2 -0
- package/dist/merges/public.d.mts +6 -0
- package/dist/merges/public.mjs +10 -0
- package/dist/node.d.mts +1 -2
- package/dist/node.mjs +1 -3
- package/dist/protocol/bytes/buffers.d.mts +9 -3
- package/dist/protocol/bytes/buffers.mjs +11 -5
- package/dist/protocol/bytes/deflate.d.mts +7 -5
- package/dist/protocol/bytes/deflate.mjs +59 -23
- package/dist/protocol/bytes/inflate.d.mts +4 -3
- package/dist/protocol/bytes/inflate.mjs +61 -26
- package/dist/protocol/bytes/reader.mjs +61 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +3 -1
- package/dist/protocol/bytes/sha1-hasher.mjs +13 -3
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +5 -5
- package/dist/protocol/bytes/streams.mjs +16 -6
- package/dist/protocol/diff/patch.d.mts +4 -0
- package/dist/protocol/diff/patch.mjs +1 -1
- package/dist/protocol/diff/paths.mjs +1 -1
- package/dist/protocol/diff/read.d.mts +1 -1
- package/dist/protocol/diff/read.mjs +102 -90
- package/dist/protocol/framing/pkt-line.d.mts +1 -0
- package/dist/protocol/framing/pkt-line.mjs +40 -6
- package/dist/protocol/objects/checked-blobs.d.mts +1 -0
- package/dist/protocol/objects/fsck.mjs +7 -1
- package/dist/protocol/objects/held.mjs +5 -11
- package/dist/protocol/objects/ident.mjs +1 -1
- package/dist/protocol/objects/object-rules.mjs +15 -7
- package/dist/protocol/objects/object.d.mts +6 -2
- package/dist/protocol/objects/object.mjs +5 -2
- package/dist/protocol/objects/tag.d.mts +3 -1
- package/dist/protocol/objects/tag.mjs +27 -1
- package/dist/protocol/objects/tree.mjs +1 -1
- package/dist/protocol/packs/delta.d.mts +1 -1
- package/dist/protocol/packs/delta.mjs +2 -2
- package/dist/protocol/packs/graph.mjs +55 -56
- package/dist/protocol/packs/idx.d.mts +4 -2
- package/dist/protocol/packs/idx.mjs +156 -63
- package/dist/protocol/packs/indexer.d.mts +22 -4
- package/dist/protocol/packs/indexer.mjs +14 -35
- package/dist/protocol/packs/parts.mjs +5 -5
- package/dist/protocol/packs/pos.mjs +12 -5
- package/dist/protocol/packs/reader.d.mts +19 -12
- package/dist/protocol/packs/reader.mjs +252 -25
- package/dist/protocol/packs/rev.d.mts +1 -1
- package/dist/protocol/packs/rev.mjs +42 -24
- package/dist/protocol/packs/types-file.mjs +85 -0
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +2 -2
- package/dist/protocol/packs/writer.d.mts +40 -15
- package/dist/protocol/packs/writer.mjs +142 -49
- package/dist/protocol/wire/advertisement.d.mts +39 -14
- package/dist/protocol/wire/advertisement.mjs +127 -31
- package/dist/protocol/wire/fetch.d.mts +57 -19
- package/dist/protocol/wire/fetch.mjs +57 -26
- package/dist/protocol/wire/json.mjs +25 -0
- package/dist/protocol/wire/lines.d.mts +10 -0
- package/dist/protocol/wire/lines.mjs +20 -6
- package/dist/protocol/wire/push-limits.d.mts +6 -0
- package/dist/protocol/wire/push-limits.mjs +88 -0
- package/dist/protocol/wire/push-uploads.mjs +3 -28
- package/dist/protocol/wire/receive-pack.d.mts +30 -14
- package/dist/protocol/wire/receive-pack.mjs +29 -2
- package/dist/protocol/wire/report-status.d.mts +30 -11
- package/dist/protocol/wire/report-status.mjs +21 -2
- package/dist/protocol/wire/v2.d.mts +56 -29
- package/dist/protocol/wire/v2.mjs +91 -16
- package/dist/protocol.d.mts +4 -3
- package/dist/protocol.mjs +7 -6
- package/dist/queue/advance.mjs +191 -121
- package/dist/queue/callers.mjs +12 -9
- package/dist/queue/calls.mjs +311 -155
- package/dist/queue/commit.mjs +70 -26
- package/dist/queue/host.d.mts +40 -13
- package/dist/queue/host.mjs +37 -39
- package/dist/queue/lanes.mjs +1 -1
- package/dist/queue/layer.d.mts +14 -0
- package/dist/queue/layer.mjs +55 -0
- package/dist/queue/limits.mjs +13 -2
- package/dist/queue/namespace.d.mts +2 -0
- package/dist/queue/pages.mjs +1 -1
- package/dist/queue/public.d.mts +6 -0
- package/dist/queue/public.mjs +21 -0
- package/dist/queue/push-option.mjs +49 -30
- package/dist/queue/rows.mjs +24 -16
- package/dist/queue/schedule.mjs +23 -23
- package/dist/queue/search.mjs +8 -7
- package/dist/queue/state.mjs +49 -13
- package/dist/queue/steps.mjs +6 -3
- package/dist/remote-helper.d.mts +5 -2
- package/dist/remote-helper.mjs +5 -2
- package/dist/rest/api.d.mts +1 -1
- package/dist/rest/blobs.d.mts +799 -32
- package/dist/rest/blobs.mjs +4 -4
- package/dist/rest/caller.d.mts +4163 -36
- package/dist/rest/caller.mjs +2 -2
- package/dist/rest/client.mjs +82 -72
- package/dist/rest/commits.d.mts +3253 -182
- package/dist/rest/commits.mjs +18 -64
- package/dist/rest/errors.d.mts +2082 -22
- package/dist/rest/errors.mjs +46 -89
- package/dist/rest/events.d.mts +394 -11
- package/dist/rest/events.mjs +13 -9
- package/dist/rest/files.d.mts +1239 -88
- package/dist/rest/files.mjs +11 -42
- package/dist/rest/forks.d.mts +2005 -62
- package/dist/rest/forks.mjs +10 -13
- package/dist/rest/handler.d.mts +4 -0
- package/dist/rest/handler.mjs +57 -26
- package/dist/rest/handlers.mjs +55 -62
- package/dist/rest/listen.d.mts +5 -8
- package/dist/rest/listen.mjs +23 -29
- package/dist/rest/me.d.mts +393 -10
- package/dist/rest/me.mjs +2 -2
- package/dist/rest/merges.d.mts +399 -16
- package/dist/rest/merges.mjs +3 -17
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/queue.d.mts +5615 -240
- package/dist/rest/queue.mjs +15 -130
- package/dist/rest/refs.d.mts +2859 -132
- package/dist/rest/refs.mjs +19 -39
- package/dist/rest/repos.d.mts +2392 -64
- package/dist/rest/repos.mjs +10 -33
- package/dist/rest/tags.d.mts +1211 -60
- package/dist/rest/tags.mjs +6 -34
- package/dist/rest/tokens.d.mts +2473 -170
- package/dist/rest/tokens.mjs +7 -4
- package/dist/rest/topics.d.mts +2060 -113
- package/dist/rest/topics.mjs +23 -71
- package/dist/rest/trees.d.mts +1610 -75
- package/dist/rest/trees.mjs +16 -57
- package/dist/rest/wire.d.mts +402 -0
- package/dist/rest/wire.mjs +32 -46
- package/dist/rest/work.d.mts +1179 -38
- package/dist/rest/work.mjs +7 -51
- package/dist/rest.d.mts +3 -3
- package/dist/server/extension.d.mts +11 -4
- package/dist/server/extension.mjs +85 -53
- package/dist/server/git-layer.d.mts +23 -0
- package/dist/server/git-layer.mjs +107 -0
- package/dist/server/git-namespace.d.mts +6 -0
- package/dist/server/git-namespace.mjs +15 -0
- package/dist/server/lifecycle.d.mts +2 -0
- package/dist/server/lifecycle.mjs +82 -0
- package/dist/server/namespaces.d.mts +2 -0
- package/dist/server/registry.d.mts +9 -0
- package/dist/server/registry.mjs +167 -0
- package/dist/server/route-match.mjs +88 -0
- package/dist/server/routes.d.mts +15 -8
- package/dist/server/routes.mjs +35 -33
- package/dist/server/server.d.mts +27 -2
- package/dist/server/server.mjs +493 -234
- package/dist/signin/codes.mjs +9 -6
- package/dist/signin/context.d.mts +2 -1
- package/dist/signin/context.mjs +4 -4
- package/dist/signin/device.mjs +8 -8
- package/dist/signin/forms.mjs +11 -29
- package/dist/signin/grants.d.mts +5 -3
- package/dist/signin/grants.mjs +20 -19
- package/dist/signin/route.mjs +2 -2
- package/dist/signin/web.mjs +7 -7
- package/dist/signin/wire.mjs +6 -6
- package/dist/storage/bits.mjs +41 -0
- package/dist/storage/budget.mjs +51 -18
- package/dist/storage/calls.d.mts +22 -4
- package/dist/storage/calls.mjs +347 -110
- package/dist/storage/clean-up.mjs +80 -35
- package/dist/storage/counted-bucket.mjs +115 -0
- package/dist/storage/fetch.d.mts +5 -1
- package/dist/storage/fetch.mjs +428 -79
- package/dist/storage/fsck.mjs +56 -7
- package/dist/storage/held-types.d.mts +7 -0
- package/dist/storage/held-types.mjs +263 -0
- package/dist/storage/host-bucket.mjs +28 -0
- package/dist/storage/id-mix.d.mts +1 -0
- package/dist/storage/id-mix.mjs +55 -0
- package/dist/storage/index-bitmaps.d.mts +2 -1
- package/dist/storage/index-bitmaps.mjs +233 -101
- package/dist/storage/index-build.d.mts +7 -3
- package/dist/storage/index-build.mjs +674 -174
- package/dist/storage/index-fetch.d.mts +4 -1
- package/dist/storage/index-fetch.mjs +365 -342
- package/dist/storage/index-files.mjs +25 -27
- package/dist/storage/index-graph.d.mts +2 -1
- package/dist/storage/index-graph.mjs +127 -91
- package/dist/storage/index-layers.d.mts +11 -0
- package/dist/storage/index-layers.mjs +258 -78
- package/dist/storage/index-reach.mjs +181 -75
- package/dist/storage/index-remap.mjs +74 -32
- package/dist/storage/index-shallow.mjs +311 -0
- package/dist/storage/index-visible.mjs +168 -0
- package/dist/storage/layout.d.mts +1 -0
- package/dist/storage/layout.mjs +39 -8
- package/dist/storage/lfs-pointers.d.mts +3 -1
- package/dist/storage/lfs-pointers.mjs +25 -9
- package/dist/storage/link-join.d.mts +4 -0
- package/dist/storage/link-join.mjs +50 -12
- package/dist/storage/links.mjs +89 -4
- package/dist/storage/listed-ids.mjs +10 -0
- package/dist/storage/loose.d.mts +11 -4
- package/dist/storage/loose.mjs +103 -69
- package/dist/storage/memory-budget.d.mts +5 -0
- package/dist/storage/memory-budget.mjs +530 -102
- package/dist/storage/merge-choose.mjs +258 -0
- package/dist/storage/merge-cut.mjs +47 -0
- package/dist/storage/merge-fence.mjs +89 -0
- package/dist/storage/merge-index.mjs +347 -0
- package/dist/storage/merge-most.mjs +202 -0
- package/dist/storage/merge-plan.mjs +171 -0
- package/dist/storage/merge-row.mjs +258 -0
- package/dist/storage/merge-stream.mjs +497 -0
- package/dist/storage/merge-walk.mjs +199 -0
- package/dist/storage/merge-write.mjs +129 -0
- package/dist/storage/merge.d.mts +10 -0
- package/dist/storage/merge.mjs +82 -306
- package/dist/storage/object-rows.d.mts +4 -2
- package/dist/storage/object-rows.mjs +101 -17
- package/dist/storage/pack-order.d.mts +1 -1
- package/dist/storage/pack-order.mjs +71 -54
- package/dist/storage/pack-ranges.d.mts +1 -1
- package/dist/storage/pack-ranges.mjs +396 -60
- package/dist/storage/pack-reads.d.mts +6 -2
- package/dist/storage/pack-reads.mjs +613 -124
- package/dist/storage/pack-receive.d.mts +7 -2
- package/dist/storage/pack-receive.mjs +820 -237
- package/dist/storage/packs-memory.d.mts +25 -0
- package/dist/storage/packs-memory.mjs +49 -0
- package/dist/storage/packs.d.mts +9 -7
- package/dist/storage/packs.mjs +562 -218
- package/dist/storage/placed-reads.mjs +205 -0
- package/dist/storage/promise-calls.mjs +29 -0
- package/dist/storage/prune-keep.mjs +164 -0
- package/dist/storage/prune-walk.mjs +578 -0
- package/dist/storage/prune.mjs +739 -332
- package/dist/storage/push-allotment.mjs +3 -3
- package/dist/storage/push-uploads.mjs +24 -14
- package/dist/storage/pushed-commits.mjs +8 -9
- package/dist/storage/quarantine.d.mts +10 -0
- package/dist/storage/quarantine.mjs +28 -25
- package/dist/storage/range-cache.mjs +71 -0
- package/dist/storage/raw-ids.mjs +20 -1
- package/dist/storage/ready.d.mts +6 -4
- package/dist/storage/ready.mjs +109 -48
- package/dist/storage/receive-admission.mjs +67 -0
- package/dist/storage/receive-bounds.d.mts +1 -0
- package/dist/storage/receive-bounds.mjs +202 -0
- package/dist/storage/receive-files.mjs +248 -0
- package/dist/storage/receive-links.mjs +281 -244
- package/dist/storage/receive-state.d.mts +9 -0
- package/dist/storage/receive-state.mjs +150 -0
- package/dist/storage/receive-steps.mjs +344 -0
- package/dist/storage/receive-sweep.mjs +160 -0
- package/dist/storage/receive-table.d.mts +3 -0
- package/dist/storage/receive-table.mjs +197 -0
- package/dist/storage/repack-backlog.mjs +70 -0
- package/dist/storage/repack-contained.mjs +269 -0
- package/dist/storage/repack-job.d.mts +3 -0
- package/dist/storage/repack-job.mjs +24 -7
- package/dist/storage/repack.d.mts +6 -6
- package/dist/storage/repack.mjs +156 -77
- package/dist/storage/roots.mjs +23 -7
- package/dist/storage/rows.d.mts +6 -3
- package/dist/storage/rows.mjs +41 -8
- package/dist/storage/runs.d.mts +8 -0
- package/dist/storage/runs.mjs +731 -0
- package/dist/storage/send-list.d.mts +9 -0
- package/dist/storage/send-list.mjs +504 -0
- package/dist/storage/shallow.d.mts +3 -3
- package/dist/storage/shallow.mjs +7 -7
- package/dist/storage/single-flight.mjs +47 -0
- package/dist/storage/stream-whole.mjs +121 -54
- package/dist/storage/swap-walk.mjs +188 -0
- package/dist/storage/unpack.mjs +54 -23
- package/dist/storage/visible.mjs +58 -39
- package/dist/storage/walk.d.mts +4 -1
- package/dist/storage/walk.mjs +33 -14
- package/dist/storage/wants.mjs +185 -33
- package/dist/storage/written-bases.mjs +172 -0
- package/dist/store/call-count.d.mts +69 -4
- package/dist/store/call-count.mjs +193 -51
- package/dist/store/catalogue.d.mts +18 -4
- package/dist/store/catalogue.mjs +135 -48
- package/dist/store/closed.d.mts +21 -0
- package/dist/store/closed.mjs +34 -0
- package/dist/store/crossing.mjs +10 -9
- package/dist/store/cursor-seal.d.mts +12 -1
- package/dist/store/cursor-seal.mjs +11 -7
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +120 -26
- package/dist/store/git-store.mjs +21 -2
- package/dist/store/list-job.mjs +5 -5
- package/dist/store/outbox.d.mts +15 -5
- package/dist/store/outbox.mjs +110 -30
- package/dist/store/promises.d.mts +6 -0
- package/dist/store/promises.mjs +317 -0
- package/dist/store/queue-jobs.mjs +12 -12
- package/dist/store/records.d.mts +64 -1
- package/dist/store/records.mjs +101 -32
- package/dist/store/ref-rows.d.mts +18 -2
- package/dist/store/ref-rows.mjs +62 -5
- package/dist/store/repo-record.mjs +11 -9
- package/dist/store/reservations.mjs +9 -8
- package/dist/store/scopes.mjs +13 -1
- package/dist/store/settle.mjs +1 -1
- package/dist/store/topic-jobs.mjs +4 -4
- package/dist/sync/bound.d.mts +5 -3
- package/dist/sync/bound.mjs +41 -7
- package/dist/sync/github.mjs +7 -7
- package/dist/sync/import.d.mts +2 -0
- package/dist/sync/import.mjs +46 -50
- package/dist/sync/jobs.d.mts +3 -3
- package/dist/sync/jobs.mjs +36 -41
- package/dist/sync/mirror.d.mts +5 -1
- package/dist/sync/mirror.mjs +121 -44
- package/dist/sync/publish.d.mts +1 -0
- package/dist/sync/publish.mjs +10 -12
- package/dist/sync/step.mjs +439 -71
- package/dist/sync/tries.mjs +52 -34
- package/dist/sync.d.mts +3 -3
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +105 -87
- package/dist/topics/calls.mjs +99 -69
- package/dist/topics/directory.mjs +31 -11
- package/dist/topics/host.d.mts +1 -2
- package/dist/topics/host.mjs +3 -13
- package/dist/topics/members.mjs +30 -24
- package/dist/topics/rows.mjs +10 -9
- package/dist/topics/topic.mjs +42 -16
- package/package.json +8 -15
- package/dist/auth/authorize.d.mts +0 -5
- package/dist/contracts/objects.mjs +0 -54
- package/dist/core/events/stream.d.mts +0 -19
- package/dist/core/rules/define.d.mts +0 -5
- package/dist/core/rules/define.mjs +0 -13
- package/dist/core/rules/fetch.d.mts +0 -5
- package/dist/core/sight.mjs +0 -99
- package/dist/engine/engine.d.mts +0 -25
- package/dist/engine/engine.mjs +0 -49
- package/dist/engine/xdiff/NOTICE.md +0 -63
- package/dist/engine/xdiff/compiled.d.mts +0 -7
- package/dist/engine/xdiff/compiled.mjs +0 -9
- package/dist/engine/xdiff/embedded.mjs +0 -4
- package/dist/engine/xdiff/node.d.mts +0 -7
- package/dist/engine/xdiff/node.mjs +0 -10
- package/dist/engine/xdiff/upstream/LGPL-2.1 +0 -511
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine.d.mts +0 -3
- package/dist/engine.mjs +0 -3
- package/dist/storage/distinct-ids.mjs +0 -39
- package/dist/storage/held-memo.mjs +0 -188
- package/dist/storage/index-remap.d.mts +0 -8
- package/dist/sync/records.mjs +0 -73
|
@@ -1,28 +1,33 @@
|
|
|
1
|
+
import { gitError, isGitError } from "../contracts/result.mjs";
|
|
1
2
|
import { BufferError, BufferMeter } from "../protocol/bytes/buffers.mjs";
|
|
2
3
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
3
4
|
import { Sha1 } from "../protocol/bytes/sha1.mjs";
|
|
4
5
|
import { sha1Now } from "../protocol/bytes/sha1-hasher.mjs";
|
|
5
6
|
import { objectHeader, objectId } from "../protocol/objects/object.mjs";
|
|
6
7
|
import { DeltaError, deltaResultSize } from "../protocol/packs/delta.mjs";
|
|
7
|
-
import { readPackIndex } from "../protocol/packs/idx.mjs";
|
|
8
|
-
import { readPackReverse } from "../protocol/packs/rev.mjs";
|
|
9
|
-
import { IndexerCache, PackIndexer
|
|
8
|
+
import { oidBytes, ownedPackIndex, readPackIndex } from "../protocol/packs/idx.mjs";
|
|
9
|
+
import { ownedPackReverse, readPackReverse } from "../protocol/packs/rev.mjs";
|
|
10
|
+
import { IndexerCache, PackIndexer } from "../protocol/packs/indexer.mjs";
|
|
10
11
|
import { stepEffect } from "../protocol/packs/step.mjs";
|
|
11
|
-
import { PackError, packReadBytes, readEntryHeader, readPackFrom } from "../protocol/packs/reader.mjs";
|
|
12
|
+
import { PackError, openEntryReader, packReadBytes, readEntryHeader, readPackFrom } from "../protocol/packs/reader.mjs";
|
|
12
13
|
import { callScope } from "../store/call-count.mjs";
|
|
13
14
|
import { forkIn, noCall, runIn } from "../store/crossing.mjs";
|
|
14
|
-
import { gitError } from "../store/errors.mjs";
|
|
15
15
|
import { decodePacks } from "../store/git-store.mjs";
|
|
16
16
|
import { collections, repoScope } from "../store/scopes.mjs";
|
|
17
|
-
import {
|
|
17
|
+
import { bucketDo, bucketStream, bucketTry, readWhole } from "./calls.mjs";
|
|
18
18
|
import { isPackId, objectCollections, packFiles } from "./layout.mjs";
|
|
19
|
-
import {
|
|
19
|
+
import { idsStartingWith, openRanges, rankOf } from "./pack-ranges.mjs";
|
|
20
|
+
import { eachHeldRow, gitObjectOf, rowHeaders, rowSizes, rowsStartingWith, startingOf } from "./object-rows.mjs";
|
|
20
21
|
import { LeavingRow, decodeHeld } from "./rows.mjs";
|
|
22
|
+
import { SingleFlight } from "./single-flight.mjs";
|
|
21
23
|
import { allotted, keptOrLeft } from "./allotted.mjs";
|
|
22
24
|
import * as Effect from "effect/Effect";
|
|
23
|
-
import * as
|
|
24
|
-
import * as Cause from "effect/Cause";
|
|
25
|
+
import * as Predicate from "effect/Predicate";
|
|
25
26
|
import * as Hex from "effect/encoding/Hex";
|
|
27
|
+
import * as Result from "effect/Result";
|
|
28
|
+
import * as Cause from "effect/Cause";
|
|
29
|
+
import * as Option from "effect/Option";
|
|
30
|
+
import * as Stream from "effect/Stream";
|
|
26
31
|
import * as Fiber from "effect/Fiber";
|
|
27
32
|
// src/storage/pack-reads.ts
|
|
28
33
|
/** The largest object `packs()` reads whole: a file past it is stored and sent as it is. */
|
|
@@ -57,16 +62,20 @@ const blockBytes = 1048576;
|
|
|
57
62
|
/** What a block takes as a cache counts it: its bytes and its entry's overhead. */
|
|
58
63
|
const blockHeld = (bytes) => bytes + 384;
|
|
59
64
|
/**
|
|
65
|
+
* What `count` blocks take as a cache counts them, of a pack of `length` bytes when it's shorter:
|
|
66
|
+
* each block's `blockHeld`, so a floor of `count` blocks keeps that many, its entries included.
|
|
67
|
+
*/
|
|
68
|
+
const blocksHeld = (count, length = count * blockBytes) => {
|
|
69
|
+
let held = 0;
|
|
70
|
+
for (let at = 0; at < count * 1048576 && at < length; at += blockBytes) held += blockHeld(Math.min(blockBytes, length - at));
|
|
71
|
+
return held;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
60
74
|
* The `leaving` rows a read takes at a time, while it still looks for objects: each is small, so a
|
|
61
75
|
* page stays far below a store's answer limit.
|
|
62
76
|
*/
|
|
63
77
|
const leavingPageRows = 1e3;
|
|
64
78
|
const lost = (message) => gitError("DATA_LOSS", message);
|
|
65
|
-
/** The whole of a file, or `undefined` when the bucket has none. */
|
|
66
|
-
const readWhole = (bucket, key, range) => bucketCall(async (signal) => {
|
|
67
|
-
const body = await bucket.read(key, range, { signal });
|
|
68
|
-
return body === void 0 ? void 0 : new Uint8Array(await new Response(body).arrayBuffer());
|
|
69
|
-
});
|
|
70
79
|
/**
|
|
71
80
|
* Blocks kept by key, each counted with `blockHeld`, the least recently used let go first: the one
|
|
72
81
|
* rule `PackBlocks` keeps them by, and its forecast replays.
|
|
@@ -74,6 +83,10 @@ const readWhole = (bucket, key, range) => bucketCall(async (signal) => {
|
|
|
74
83
|
var KeptBlocks = class {
|
|
75
84
|
#kept = /* @__PURE__ */ new Map();
|
|
76
85
|
held = 0;
|
|
86
|
+
/** Whether the block at `key` is kept, its recency left as it is. */
|
|
87
|
+
has(key) {
|
|
88
|
+
return this.#kept.has(key);
|
|
89
|
+
}
|
|
77
90
|
/** The block at `key`, made the most recent, or `undefined`. */
|
|
78
91
|
get(key) {
|
|
79
92
|
const kept = this.#kept.get(key);
|
|
@@ -99,14 +112,18 @@ var KeptBlocks = class {
|
|
|
99
112
|
});
|
|
100
113
|
this.held += bytes;
|
|
101
114
|
}
|
|
102
|
-
|
|
115
|
+
/** Lets the least recent go until it holds `bytes`, telling `evicted` each key it let go. */
|
|
116
|
+
evictTo(bytes, evicted) {
|
|
103
117
|
for (const [key, each] of this.#kept) {
|
|
104
118
|
if (this.held <= bytes) break;
|
|
105
119
|
this.#kept.delete(key);
|
|
106
120
|
this.held -= each.bytes;
|
|
121
|
+
evicted?.(key);
|
|
107
122
|
}
|
|
108
123
|
}
|
|
109
124
|
};
|
|
125
|
+
/** The keys of blocks a reader let go that it remembers, to know a read of one again (#1197). */
|
|
126
|
+
const evictedKept = 64;
|
|
110
127
|
/** A block's key, by its pack and the offset it starts at. */
|
|
111
128
|
const blockKey = (pack, start) => `${pack.id}@${start}`;
|
|
112
129
|
/** The length of the block at `start`: `blockBytes`, or less at the pack's end. */
|
|
@@ -120,17 +137,67 @@ var PackBlocks = class {
|
|
|
120
137
|
#bucket;
|
|
121
138
|
#room;
|
|
122
139
|
#kept = new KeptBlocks();
|
|
140
|
+
/** `headIn`'s bytes across a blocks' edge, filled again by its next such read. */
|
|
141
|
+
#head = /* @__PURE__ */ new Uint8Array(64);
|
|
142
|
+
/** Bounded meter for this instance's reused entry reader: inflater, 64 KiB output and header. */
|
|
143
|
+
#entryMeter = new BufferMeter(entryReaderBytes);
|
|
144
|
+
#entryReader;
|
|
145
|
+
#entryReaderInUse = false;
|
|
146
|
+
#closeReaderOnFinish = false;
|
|
147
|
+
/** The last `evictedKept` blocks it let go, oldest first. */
|
|
148
|
+
#evicted = /* @__PURE__ */ new Set();
|
|
149
|
+
#forget = (key) => {
|
|
150
|
+
this.#evicted.add(key);
|
|
151
|
+
for (const oldest of this.#evicted) {
|
|
152
|
+
if (this.#evicted.size <= evictedKept) break;
|
|
153
|
+
this.#evicted.delete(oldest);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
123
156
|
/** `room`: what it may keep, each block counted with `blockHeld`. */
|
|
124
157
|
constructor(bucket, room) {
|
|
125
158
|
this.#bucket = bucket;
|
|
126
159
|
this.#room = room;
|
|
127
|
-
room.watch((bytes) =>
|
|
160
|
+
room.watch((bytes) => {
|
|
161
|
+
this.#kept.evictTo(bytes, this.#forget);
|
|
162
|
+
if (this.#entryReaderInUse) this.#closeReaderOnFinish = true;
|
|
163
|
+
else this.#releaseEntryReader();
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/** Releases the reused entry reader's inflater, buffers and meter allotments once idle. */
|
|
167
|
+
close() {
|
|
168
|
+
if (this.#entryReaderInUse) {
|
|
169
|
+
this.#closeReaderOnFinish = true;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
this.#releaseEntryReader();
|
|
128
173
|
}
|
|
129
|
-
|
|
174
|
+
/** Bytes currently held on this instance's entry-reader meter (for memory verification). */
|
|
175
|
+
get entryReaderHeld() {
|
|
176
|
+
return this.#entryMeter.held;
|
|
177
|
+
}
|
|
178
|
+
/** Peak bytes held on this instance's entry-reader meter (for memory verification). */
|
|
179
|
+
get entryReaderMost() {
|
|
180
|
+
return this.#entryMeter.most;
|
|
181
|
+
}
|
|
182
|
+
#releaseEntryReader() {
|
|
183
|
+
this.#closeReaderOnFinish = false;
|
|
184
|
+
this.#entryReader?.close();
|
|
185
|
+
this.#entryReader = void 0;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The block at `start`, kept or read. One it let go and reads again first waits for its room to
|
|
189
|
+
* grow by it, before its get, where the room waits: so a reader whose blocks rotate past a floor
|
|
190
|
+
* that a live operation's caches hold it to waits for that operation, and is refused its busy,
|
|
191
|
+
* spending no get, rather than reading the same blocks until its calls run out (#1197). A first
|
|
192
|
+
* read never waits: one that doesn't fit evicts, so a reader streaming through a pack goes on.
|
|
193
|
+
*/
|
|
194
|
+
block = Effect.fnUntraced({ self: this }, function* (pack, start) {
|
|
130
195
|
const key = blockKey(pack, start);
|
|
131
196
|
const kept = this.#kept.get(key);
|
|
132
197
|
if (kept !== void 0) return kept;
|
|
133
198
|
const length = blockLength(pack, start);
|
|
199
|
+
const short = this.#kept.held + blockHeld(length) - this.#room.bytes;
|
|
200
|
+
if (this.#evicted.delete(key) && short > 0 && !this.#room.grow(short)) yield* this.#room.growWithin?.(short) ?? Effect.void;
|
|
134
201
|
const bytes = yield* readWhole(this.#bucket, packFiles(pack.id).pack, {
|
|
135
202
|
offset: start,
|
|
136
203
|
length
|
|
@@ -139,9 +206,13 @@ var PackBlocks = class {
|
|
|
139
206
|
this.#kept.add(key, bytes, length);
|
|
140
207
|
const over = this.#kept.held - this.#room.bytes;
|
|
141
208
|
if (over <= 0 || this.#room.grow(over)) return bytes;
|
|
142
|
-
this.#kept.evictTo(this.#room.bytes);
|
|
209
|
+
this.#kept.evictTo(this.#room.bytes, this.#forget);
|
|
143
210
|
return bytes;
|
|
144
211
|
});
|
|
212
|
+
/** Whether the block holding `pack`'s byte at `offset` is kept now, so reading it takes no get. */
|
|
213
|
+
keeps(pack, offset) {
|
|
214
|
+
return this.#kept.has(blockKey(pack, offset - offset % blockBytes));
|
|
215
|
+
}
|
|
145
216
|
/**
|
|
146
217
|
* The bucket gets reading each of `entries`' bytes in turn would take, with no I/O: their blocks
|
|
147
218
|
* replayed through `KeptBlocks`, in a room left at its floor, which a shrink may leave it at any
|
|
@@ -174,9 +245,39 @@ var PackBlocks = class {
|
|
|
174
245
|
}) };
|
|
175
246
|
}
|
|
176
247
|
/** Up to `headerBytesMost` bytes of the pack from `offset`, across a neighbourhood's end. */
|
|
177
|
-
headAt = (pack, offset) =>
|
|
248
|
+
headAt = (pack, offset) => this.#fill(pack, offset, new Uint8Array(Math.min(64, pack.bytes - offset)));
|
|
249
|
+
/**
|
|
250
|
+
* `headAt`'s bytes, borrowed for a serial walk (#1678), which reads its `headerBytesMost` at most
|
|
251
|
+
* before its next read: a view of the kept block holding them, or else this reader's own scratch,
|
|
252
|
+
* filled across the blocks' edge again by its next such read. At once when its block is kept.
|
|
253
|
+
*/
|
|
254
|
+
headIn(pack, offset) {
|
|
178
255
|
const length = Math.min(64, pack.bytes - offset);
|
|
179
|
-
const
|
|
256
|
+
const start = offset - offset % blockBytes;
|
|
257
|
+
if (offset + length > start + 1048576) return this.#fill(pack, offset, this.#head.subarray(0, length));
|
|
258
|
+
const block = this.#blockStep(pack, start);
|
|
259
|
+
return Effect.isEffect(block) ? Effect.map(block, (bytes) => bytes.subarray(offset - start, offset - start + length)) : block.subarray(offset - start, offset - start + length);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* `[from, to)` of the pack, each block's piece handed to `each` as the kept block, where in it the
|
|
263
|
+
* piece starts and its length, borrowed until `each` answers: the blocks `sourceAt` reads, in its
|
|
264
|
+
* order, at once while each is kept.
|
|
265
|
+
*/
|
|
266
|
+
spans(pack, from, to, each) {
|
|
267
|
+
for (let at = from; at < to;) {
|
|
268
|
+
const start = at - at % blockBytes;
|
|
269
|
+
const block = this.#blockStep(pack, start);
|
|
270
|
+
const here = at;
|
|
271
|
+
const end = Math.min(start + blockBytes, to);
|
|
272
|
+
const piece = (bytes) => each(bytes, here - start, end - here);
|
|
273
|
+
const handed = Effect.isEffect(block) ? Effect.flatMap(block, (bytes) => stepEffect(piece(bytes))) : piece(block);
|
|
274
|
+
if (Effect.isEffect(handed)) return Effect.flatMap(handed, () => stepEffect(this.spans(pack, end, to, each)));
|
|
275
|
+
at = end;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/** `head` filled with the pack's bytes from `offset`, across a neighbourhood's end. */
|
|
279
|
+
#fill = Effect.fnUntraced({ self: this }, function* (pack, offset, head) {
|
|
280
|
+
const length = head.byteLength;
|
|
180
281
|
for (let at = 0; at < length;) {
|
|
181
282
|
const start = offset + at - (offset + at) % blockBytes;
|
|
182
283
|
const piece = (yield* this.block(pack, start)).subarray(offset + at - start, offset + length - start);
|
|
@@ -185,19 +286,160 @@ var PackBlocks = class {
|
|
|
185
286
|
}
|
|
186
287
|
return head;
|
|
187
288
|
});
|
|
289
|
+
#blockStep(pack, start) {
|
|
290
|
+
const kept = this.#kept.get(blockKey(pack, start));
|
|
291
|
+
if (kept !== void 0) return kept;
|
|
292
|
+
return this.block(pack, start);
|
|
293
|
+
}
|
|
294
|
+
#stepSourceAt(pack, offset) {
|
|
295
|
+
let next = offset;
|
|
296
|
+
return () => {
|
|
297
|
+
if (next >= pack.bytes) return void 0;
|
|
298
|
+
const start = next - next % blockBytes;
|
|
299
|
+
const loaded = this.#blockStep(pack, start);
|
|
300
|
+
const slice = (bytes) => {
|
|
301
|
+
const from = next - start;
|
|
302
|
+
const piece = bytes.subarray(from, Math.min(bytes.byteLength, from + packReadBytes));
|
|
303
|
+
next += piece.byteLength;
|
|
304
|
+
return piece;
|
|
305
|
+
};
|
|
306
|
+
return Effect.isEffect(loaded) ? Effect.map(loaded, slice) : slice(loaded);
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
#ensureEntryReader() {
|
|
310
|
+
if (this.#entryReader !== void 0 && !this.#entryReader.closed) return Result.succeed(this.#entryReader);
|
|
311
|
+
const opened = openEntryReader(this.#entryMeter);
|
|
312
|
+
if (Result.isSuccess(opened)) this.#entryReader = opened.success;
|
|
313
|
+
return opened;
|
|
314
|
+
}
|
|
315
|
+
#syncSourceAt(pack, offset) {
|
|
316
|
+
let next = offset;
|
|
317
|
+
return () => {
|
|
318
|
+
if (next >= pack.bytes) return void 0;
|
|
319
|
+
const start = next - next % blockBytes;
|
|
320
|
+
const kept = this.#kept.get(blockKey(pack, start));
|
|
321
|
+
if (kept === void 0) return "miss";
|
|
322
|
+
const from = next - start;
|
|
323
|
+
const piece = kept.subarray(from, Math.min(kept.byteLength, from + packReadBytes));
|
|
324
|
+
next += piece.byteLength;
|
|
325
|
+
return piece;
|
|
326
|
+
};
|
|
327
|
+
}
|
|
188
328
|
/**
|
|
189
329
|
* The entry at `offset`, read whole, `before` run on its header before its data is held; a
|
|
190
330
|
* stored pack that won't read is `DATA_LOSS`.
|
|
191
331
|
*/
|
|
192
|
-
entryAt = (pack, offset, before) =>
|
|
332
|
+
entryAt = (pack, offset, before) => Effect.suspend(() => {
|
|
333
|
+
const mapUnreadable = (error) => error instanceof PackError || error instanceof BufferError ? lost(`Pack ${pack.id} is unreadable at ${offset}: ${error.message}`) : error;
|
|
334
|
+
let resume;
|
|
335
|
+
const firstStart = offset - offset % blockBytes;
|
|
336
|
+
if (!this.#entryReaderInUse && (offset >= pack.bytes || this.#kept.has(blockKey(pack, firstStart)))) {
|
|
337
|
+
const ensured = this.#ensureEntryReader();
|
|
338
|
+
if (Result.isFailure(ensured)) return Effect.fail(mapUnreadable(ensured.failure));
|
|
339
|
+
const sync = ensured.success.tryReadSync(this.#syncSourceAt(pack, offset), offset, packIndexerLimits, before);
|
|
340
|
+
if (sync instanceof PackError) return Effect.fail(mapUnreadable(sync));
|
|
341
|
+
if (sync === "too big" || !("async" in sync)) return Effect.succeed(sync);
|
|
342
|
+
resume = sync.async;
|
|
343
|
+
}
|
|
344
|
+
const startOffset = resume === void 0 ? offset : offset + resume.headerLength;
|
|
345
|
+
const runAsync = Effect.acquireUseRelease(Effect.suspend(() => {
|
|
346
|
+
if (this.#entryReaderInUse) {
|
|
347
|
+
const opened = openEntryReader(new BufferMeter(entryReaderBytes));
|
|
348
|
+
return Result.isFailure(opened) ? Effect.fail(opened.failure) : Effect.succeed({
|
|
349
|
+
reader: opened.success,
|
|
350
|
+
shared: false
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
const ensured = this.#ensureEntryReader();
|
|
354
|
+
if (Result.isFailure(ensured)) return Effect.fail(ensured.failure);
|
|
355
|
+
this.#entryReaderInUse = true;
|
|
356
|
+
return Effect.succeed({
|
|
357
|
+
reader: ensured.success,
|
|
358
|
+
shared: true
|
|
359
|
+
});
|
|
360
|
+
}), ({ reader }) => reader.read(this.#stepSourceAt(pack, startOffset), offset, packIndexerLimits, resume === void 0 ? before : void 0, resume), ({ reader, shared }) => Effect.sync(() => {
|
|
361
|
+
if (!shared) {
|
|
362
|
+
reader.close();
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
reader.reset();
|
|
366
|
+
this.#entryReaderInUse = false;
|
|
367
|
+
if (this.#closeReaderOnFinish || reader.closed) this.#releaseEntryReader();
|
|
368
|
+
})).pipe(Effect.mapError(mapUnreadable));
|
|
369
|
+
return resume?.before === void 0 ? runAsync : Effect.flatMap(resume.before, () => runAsync);
|
|
370
|
+
});
|
|
193
371
|
};
|
|
194
372
|
/**
|
|
373
|
+
* `pack`'s bytes `[from, to)` as a `PackRun`, its get counted on the operation's calls, as every
|
|
374
|
+
* bucket call is. Each read of its body waits for a piece, and an interruption cancels the body
|
|
375
|
+
* through the read's own canceller, so it adds no listener to any signal.
|
|
376
|
+
*/
|
|
377
|
+
const packRun = (bucket, pack, from, to) => {
|
|
378
|
+
let reader;
|
|
379
|
+
let piece = /* @__PURE__ */ new Uint8Array(0);
|
|
380
|
+
let pieceAt = from;
|
|
381
|
+
const missing = (at) => lost(`Pack ${pack.id} is missing its bytes from ${at}`);
|
|
382
|
+
const open = Effect.gen(function* () {
|
|
383
|
+
const body = yield* bucketStream(bucket, packFiles(pack.id).pack, {
|
|
384
|
+
offset: from,
|
|
385
|
+
length: to - from
|
|
386
|
+
});
|
|
387
|
+
if (body === void 0) return yield* Effect.fail(missing(from));
|
|
388
|
+
return body.getReader();
|
|
389
|
+
});
|
|
390
|
+
const cancel = (opened) => Effect.promise(() => opened.cancel().catch(() => void 0));
|
|
391
|
+
/**
|
|
392
|
+
* The body's next piece, or its end, its failure as `bucketTry` maps one: a closed server's, and
|
|
393
|
+
* one past a call bound, stay defects. An interruption cancels the body. The read takes no signal,
|
|
394
|
+
* so it adds no listener to one.
|
|
395
|
+
*/
|
|
396
|
+
const nextPiece = (opened) => bucketTry(() => opened.read()).pipe(Effect.onInterrupt(() => cancel(opened)));
|
|
397
|
+
return {
|
|
398
|
+
from,
|
|
399
|
+
to,
|
|
400
|
+
reads: (offset) => offset >= pieceAt && offset < to,
|
|
401
|
+
read: Effect.fnUntraced(function* (offset, end) {
|
|
402
|
+
if (offset < pieceAt || end > to) return yield* Effect.die(/* @__PURE__ */ new Error(`a run of ${from} to ${to} can't read ${offset} to ${end}`));
|
|
403
|
+
reader ??= yield* open;
|
|
404
|
+
while (offset >= pieceAt + piece.byteLength) {
|
|
405
|
+
pieceAt += piece.byteLength;
|
|
406
|
+
const next = yield* nextPiece(reader);
|
|
407
|
+
if (next.done) return yield* Effect.fail(missing(pieceAt));
|
|
408
|
+
const { value } = next;
|
|
409
|
+
piece = value.buffer instanceof ArrayBuffer ? new Uint8Array(value.buffer, value.byteOffset, value.byteLength) : value.slice();
|
|
410
|
+
}
|
|
411
|
+
return piece.subarray(offset - pieceAt, Math.min(piece.byteLength, end - pieceAt));
|
|
412
|
+
}),
|
|
413
|
+
close: Effect.suspend(() => {
|
|
414
|
+
const opened = reader;
|
|
415
|
+
piece = /* @__PURE__ */ new Uint8Array(0);
|
|
416
|
+
return opened === void 0 ? Effect.void : cancel(opened);
|
|
417
|
+
})
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
/**
|
|
421
|
+
* The most of the index cache's room one receive's seed may take, as a share of `room.most`: a
|
|
422
|
+
* pack's entry past it is read by a load instead, so one push never fills half of what the cache can
|
|
423
|
+
* ever hold. 1b's largest receive, about 1.24M objects, holds about 40 MiB of `.idx` and `.rev`.
|
|
424
|
+
*/
|
|
425
|
+
const indexSeedShare = 1 / 2;
|
|
426
|
+
/**
|
|
427
|
+
* What a seed holds at once, which its charge covers: the files as written, and the entry `seed`
|
|
428
|
+
* parses from them, a copy of each with its overhead.
|
|
429
|
+
*/
|
|
430
|
+
const seedBytes = (files) => 384 + 2 * (files.index.byteLength + files.reverse.byteLength);
|
|
431
|
+
/**
|
|
195
432
|
* The `.idx` and `.rev` of each pack a server has read, across every repo, by the pack's ID: a
|
|
196
433
|
* pack's files never change, so one is checked once, its trailer against the index's and the
|
|
197
434
|
* reverse index against both, and kept until the cache is full.
|
|
198
435
|
*/
|
|
199
436
|
var PackIndexes = class {
|
|
200
437
|
#kept = /* @__PURE__ */ new Map();
|
|
438
|
+
/**
|
|
439
|
+
* Each pack's load under way, which every other load of it waits on. One that stopped for its
|
|
440
|
+
* caller alone is loaded again by a waiter, and a failed one is never kept.
|
|
441
|
+
*/
|
|
442
|
+
#loading = new SingleFlight();
|
|
201
443
|
#room;
|
|
202
444
|
#held = 0;
|
|
203
445
|
/**
|
|
@@ -208,7 +450,15 @@ var PackIndexes = class {
|
|
|
208
450
|
this.#room = room;
|
|
209
451
|
room.watch((bytes) => this.#evictTo(bytes));
|
|
210
452
|
}
|
|
211
|
-
|
|
453
|
+
/**
|
|
454
|
+
* `listed`'s `.idx` and `.rev`, kept or read. One load of a pack runs at a time, whoever asks:
|
|
455
|
+
* the cache owns it, and every other caller waits on it, so 16 cold reads of one pack make one
|
|
456
|
+
* load's calls, and its bytes are kept, and charged to the room, once. A failed load fails each
|
|
457
|
+
* caller waiting on it, and nothing keeps it; one interrupted, or past its caller's own call
|
|
458
|
+
* bound, is loaded again by a waiter under the waiter's, so no waiter hangs on a caller that went
|
|
459
|
+
* away or answers for another's calls.
|
|
460
|
+
*/
|
|
461
|
+
load = Effect.fnUntraced({ self: this }, function* (bucket, listed) {
|
|
212
462
|
const { id } = listed;
|
|
213
463
|
if (!isPackId(id)) return yield* Effect.fail(lost(`The pack row '${id}' doesn't name a pack`));
|
|
214
464
|
const pack = {
|
|
@@ -225,20 +475,26 @@ var PackIndexes = class {
|
|
|
225
475
|
reverse: kept.reverse
|
|
226
476
|
};
|
|
227
477
|
}
|
|
478
|
+
const loaded = yield* this.#loading.run(id, this.#read(bucket, listed, pack));
|
|
479
|
+
return Option.isSome(loaded) ? loaded.value : yield* this.load(bucket, listed);
|
|
480
|
+
});
|
|
481
|
+
/** `load`'s reads of `listed`'s files, its checks, and the cache's keep of them. */
|
|
482
|
+
#read = Effect.fnUntraced({ self: this }, function* (bucket, listed, pack) {
|
|
483
|
+
const { id } = pack;
|
|
228
484
|
const files = packFiles(id);
|
|
229
|
-
const bytes = yield*
|
|
485
|
+
const bytes = yield* readInto(bucket, files.idx, idxMostBytes(listed), `Pack ${id}'s index`);
|
|
230
486
|
if (bytes === void 0) return yield* Effect.fail(lost(`Pack ${id} has no index`));
|
|
231
|
-
const index = yield*
|
|
487
|
+
const index = yield* ownedPackIndex(bytes).pipe(Effect.mapError((error) => lost(`Pack ${id}'s index is unreadable: ${error.message}`)));
|
|
232
488
|
if (index.count !== listed.objects) return yield* Effect.fail(lost(`Pack ${id}'s index lists ${index.count} objects; its row, ${listed.objects}`));
|
|
233
489
|
const trailer = yield* readWhole(bucket, files.pack, {
|
|
234
490
|
offset: listed.bytes - 20,
|
|
235
491
|
length: 20
|
|
236
492
|
});
|
|
237
493
|
if (trailer === void 0 || Hex.encode(trailer) !== index.packChecksum) return yield* Effect.fail(lost(`Pack ${id}'s bytes aren't those its index lists`));
|
|
238
|
-
const reversed = yield*
|
|
494
|
+
const reversed = yield* readInto(bucket, files.rev, revBytes(listed), `Pack ${id}'s reverse index`);
|
|
239
495
|
if (reversed === void 0) return yield* Effect.fail(lost(`Pack ${id} has no reverse index`));
|
|
240
|
-
const reverse = yield*
|
|
241
|
-
const held = 384 + bytes.byteLength + reversed.byteLength;
|
|
496
|
+
const reverse = yield* ownedPackReverse(reversed, index).pipe(Effect.mapError((error) => lost(`Pack ${id}'s reverse index is unreadable: ${error.message}`)));
|
|
497
|
+
const held = 384 + bytes.buffer.byteLength + reversed.buffer.byteLength;
|
|
242
498
|
this.#remember(id, {
|
|
243
499
|
index,
|
|
244
500
|
reverse,
|
|
@@ -251,8 +507,67 @@ var PackIndexes = class {
|
|
|
251
507
|
};
|
|
252
508
|
});
|
|
253
509
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
510
|
+
* A receive's `.idx` and `.rev` kept from the bytes it just wrote, with `load`'s checks and no
|
|
511
|
+
* call: its count, its pack checksum, and the reverse index against both. It runs once the
|
|
512
|
+
* receive's rooms are released, on `seed.charge`, which covers the written bytes and the parsed
|
|
513
|
+
* entry until the parse ends; then the charge goes back, and the entry is kept only when the
|
|
514
|
+
* room grows to it, evicting nothing. Skipped when the cache keeps the pack already, a load of it
|
|
515
|
+
* is under way, which keeps what it reads, the charge falls short of `seedBytes`, or the entry
|
|
516
|
+
* is past `indexSeedShare` of the room's most. A failed check keeps nothing and is logged by
|
|
517
|
+
* name, since the writer's own bytes failing them is a bug in it, not bad input; it never fails
|
|
518
|
+
* the receive.
|
|
519
|
+
*/
|
|
520
|
+
seed = (seed) => Effect.ensuring(this.#seed(seed), Effect.sync(() => seed.charge.release()));
|
|
521
|
+
#seed = Effect.fnUntraced({ self: this }, function* ({ listed, files, charge }) {
|
|
522
|
+
const { id } = listed;
|
|
523
|
+
if (!isPackId(id) || this.#kept.has(id) || this.#loading.running(id)) return;
|
|
524
|
+
if (charge.bytes < seedBytes(files)) return;
|
|
525
|
+
const held = 384 + files.index.byteLength + files.reverse.byteLength;
|
|
526
|
+
if (held > .5 * this.#room.most) return;
|
|
527
|
+
const failed = (check, counts) => Effect.logWarning(`Pack ${id}'s seed failed its ${check} check (${counts}); nothing kept`);
|
|
528
|
+
const index = yield* Effect.option(readPackIndex(files.index));
|
|
529
|
+
if (Option.isNone(index)) return yield* failed("index", `${files.index.byteLength} bytes`);
|
|
530
|
+
if (index.value.count !== listed.objects) return yield* failed("count", `${index.value.count} listed, ${listed.objects} on its row`);
|
|
531
|
+
if (index.value.packChecksum !== files.checksum) return yield* failed("trailer", `${index.value.packChecksum} against ${files.checksum}`);
|
|
532
|
+
const reverse = yield* Effect.option(readPackReverse(files.reverse, index.value));
|
|
533
|
+
if (Option.isNone(reverse)) return yield* failed("reverse index", `${files.reverse.byteLength} bytes`);
|
|
534
|
+
charge.release();
|
|
535
|
+
const over = this.#held + held - this.#room.bytes;
|
|
536
|
+
if (over > 0 && !this.#room.grow(over)) return;
|
|
537
|
+
this.#remember(id, {
|
|
538
|
+
index: index.value,
|
|
539
|
+
reverse: reverse.value,
|
|
540
|
+
bytes: held
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
/**
|
|
544
|
+
* Lets go of pack `id`'s kept `.idx` and `.rev`, for a pack whose files were deleted. A load of it
|
|
545
|
+
* under way when it's called keeps what it reads once it ends, so a pack is forgotten only once
|
|
546
|
+
* no load of it is running.
|
|
547
|
+
*/
|
|
548
|
+
forget = (id) => {
|
|
549
|
+
if (!isPackId(id)) return;
|
|
550
|
+
const kept = this.#kept.get(id);
|
|
551
|
+
if (kept === void 0) return;
|
|
552
|
+
this.#kept.delete(id);
|
|
553
|
+
this.#held -= kept.bytes;
|
|
554
|
+
};
|
|
555
|
+
/**
|
|
556
|
+
* The `.idx` the cache keeps for pack `id`, read by no call and made the most recent, or
|
|
557
|
+
* `undefined` when it keeps none: a lookup that must hold no `.idx` of its own reads one held
|
|
558
|
+
* here, and reads any other by range.
|
|
559
|
+
*/
|
|
560
|
+
peek = (id) => {
|
|
561
|
+
if (!isPackId(id)) return void 0;
|
|
562
|
+
const kept = this.#kept.get(id);
|
|
563
|
+
if (kept === void 0) return void 0;
|
|
564
|
+
this.#kept.delete(id);
|
|
565
|
+
this.#kept.set(id, kept);
|
|
566
|
+
return kept.index;
|
|
567
|
+
};
|
|
568
|
+
/**
|
|
569
|
+
* `kept` at `id`, the most recent. One already there, which one load of a pack at a time leaves
|
|
570
|
+
* none of, would be let go first, so `#held` is always the sum of the indexes kept: a second load
|
|
256
571
|
* costs its reads, never a charge that outlives its entry.
|
|
257
572
|
*/
|
|
258
573
|
#remember(id, kept) {
|
|
@@ -328,13 +643,13 @@ const checkedNow = (pack, oid, type, bytes) => {
|
|
|
328
643
|
* An object resolved from a stored pack, hashed again against the ID its index lists: at once
|
|
329
644
|
* below `hashedNowMost`, through `objectId` from it up.
|
|
330
645
|
*/
|
|
331
|
-
const checkedObject = Effect.fnUntraced(function* (pack, oid, resolved) {
|
|
646
|
+
const checkedObject = /* @__PURE__ */ Effect.fnUntraced(function* (pack, oid, resolved) {
|
|
332
647
|
if (resolved.kind !== "resolved") return yield* Effect.fail(unresolvedEntry(pack, oid, resolved));
|
|
333
648
|
const { kind: type } = resolved.object;
|
|
334
649
|
const bytes = new Uint8Array(resolved.object.bytes);
|
|
335
650
|
if (bytes.byteLength < 65536) {
|
|
336
651
|
const checked = checkedNow(pack, oid, type, bytes);
|
|
337
|
-
return
|
|
652
|
+
return isGitError(checked) ? yield* Effect.fail(checked) : checked;
|
|
338
653
|
}
|
|
339
654
|
const hashed = yield* objectId({
|
|
340
655
|
type,
|
|
@@ -347,6 +662,19 @@ const checkedObject = Effect.fnUntraced(function* (pack, oid, resolved) {
|
|
|
347
662
|
bytes
|
|
348
663
|
};
|
|
349
664
|
});
|
|
665
|
+
const loadedLookup = (indexed) => ({
|
|
666
|
+
pack: indexed.pack,
|
|
667
|
+
find: (oid) => indexed.index.find(oid)?.offset
|
|
668
|
+
});
|
|
669
|
+
/** A lookup of `ranges`: `rankOf`'s reads, then the offset's. */
|
|
670
|
+
const rangedLookup = (ranges) => ({
|
|
671
|
+
pack: ranges.pack,
|
|
672
|
+
find: Effect.fnUntraced(function* (oid) {
|
|
673
|
+
const rank = yield* rankOf(ranges, oidBytes(oid));
|
|
674
|
+
if (rank === void 0) return void 0;
|
|
675
|
+
return (yield* ranges.offsets(rank, 1))[0];
|
|
676
|
+
})
|
|
677
|
+
});
|
|
350
678
|
/**
|
|
351
679
|
* Objects of stored packs, each resolved whole from its offset and hashed again against its ID:
|
|
352
680
|
* one indexer for each pack, and one cache for them all. An indexer holds the pack's index only
|
|
@@ -356,50 +684,58 @@ const checkedObject = Effect.fnUntraced(function* (pack, oid, resolved) {
|
|
|
356
684
|
const packObjects = (blocks, room, outside) => {
|
|
357
685
|
const indexers = /* @__PURE__ */ new Map();
|
|
358
686
|
const cache = new IndexerCache(room);
|
|
359
|
-
const indexingOf = (
|
|
360
|
-
const kept = indexers.get(
|
|
687
|
+
const indexingOf = (pack) => {
|
|
688
|
+
const kept = indexers.get(pack.id);
|
|
361
689
|
if (kept !== void 0) return kept;
|
|
362
|
-
const { pack } = indexed;
|
|
363
690
|
const made = {
|
|
364
691
|
using: void 0,
|
|
365
692
|
resolving: 0,
|
|
366
693
|
indexer: new PackIndexer({
|
|
367
694
|
entryAt: (offset, before) => blocks.entryAt(pack, offset, before),
|
|
368
|
-
offsetOf: (oid) => made.using
|
|
369
|
-
|
|
695
|
+
offsetOf: (oid) => made.using === void 0 ? void 0 : made.using.find(oid),
|
|
696
|
+
allot: outside
|
|
370
697
|
}, packIndexerLimits, cache)
|
|
371
698
|
};
|
|
372
699
|
indexers.set(pack.id, made);
|
|
373
700
|
return made;
|
|
374
701
|
};
|
|
375
|
-
/** `
|
|
376
|
-
const lent = (indexing,
|
|
377
|
-
indexing.using =
|
|
702
|
+
/** `lookup` lent to its pack's indexer while `resolve` runs, and dropped when the last ends. */
|
|
703
|
+
const lent = (indexing, lookup, resolve) => Effect.acquireUseRelease(Effect.sync(() => {
|
|
704
|
+
indexing.using = lookup;
|
|
378
705
|
indexing.resolving += 1;
|
|
379
706
|
}), () => resolve, () => Effect.sync(() => {
|
|
380
707
|
indexing.resolving -= 1;
|
|
381
708
|
if (indexing.resolving === 0) indexing.using = void 0;
|
|
382
709
|
}));
|
|
383
|
-
/** What the entry at `offset` resolves to, reading its chain as it needs
|
|
384
|
-
const
|
|
385
|
-
const indexing = indexingOf(
|
|
386
|
-
return lent(indexing,
|
|
710
|
+
/** What the entry at `offset` resolves to, reading its chain as it needs, its bases found by `lookup`. */
|
|
711
|
+
const resolvingIn = (oid, lookup, offset) => {
|
|
712
|
+
const indexing = indexingOf(lookup.pack);
|
|
713
|
+
return lent(indexing, lookup, stepEffect(indexing.indexer.resolve(offset))).pipe(Effect.catchIf((error) => error instanceof DeltaError, (error) => Effect.fail(lost(`Object ${oid} in pack ${lookup.pack.id} won't resolve: ${error.message}`))));
|
|
387
714
|
};
|
|
715
|
+
const resolving = (oid, indexed, offset) => resolvingIn(oid, loadedLookup(indexed), offset);
|
|
388
716
|
const at = Effect.fnUntraced(function* (oid, indexed, offset) {
|
|
389
717
|
return yield* checkedObject(indexed.pack, oid, yield* resolving(oid, indexed, offset));
|
|
390
718
|
});
|
|
719
|
+
/** `at` with each base found through `lookup`, as a read by place finds them. */
|
|
720
|
+
const atIn = Effect.fnUntraced(function* (oid, lookup, offset) {
|
|
721
|
+
return yield* checkedObject(lookup.pack, oid, yield* resolvingIn(oid, lookup, offset));
|
|
722
|
+
});
|
|
723
|
+
/** `at` for a pack whose `.idx` isn't loaded: each base found through its `ranges`. */
|
|
724
|
+
const inRanges = (oid, ranges, offset) => atIn(oid, rangedLookup(ranges), offset);
|
|
391
725
|
/**
|
|
392
726
|
* What the entry at `offset` resolves to at once, from its pack's indexer's cache, with nothing
|
|
393
727
|
* read; `undefined` when `resolving` must read it.
|
|
394
728
|
*/
|
|
395
|
-
const recalled = (indexed, offset) => indexingOf(indexed).indexer.recalled(offset);
|
|
729
|
+
const recalled = (indexed, offset) => indexingOf(indexed.pack).indexer.recalled(offset);
|
|
396
730
|
/** Lets go of the cache and each pack's indexer. */
|
|
397
731
|
const clear = () => {
|
|
398
732
|
indexers.clear();
|
|
399
733
|
cache.clear();
|
|
400
734
|
};
|
|
401
735
|
return Object.assign(at, {
|
|
736
|
+
atIn,
|
|
402
737
|
clear,
|
|
738
|
+
inRanges,
|
|
403
739
|
recalled,
|
|
404
740
|
resolving
|
|
405
741
|
});
|
|
@@ -425,7 +761,7 @@ const entryStream = (blocks, at, signal, count) => {
|
|
|
425
761
|
wake = void 0;
|
|
426
762
|
});
|
|
427
763
|
});
|
|
428
|
-
const hand =
|
|
764
|
+
const hand = Effect.fnUntraced(function* (bytes) {
|
|
429
765
|
yield* demand;
|
|
430
766
|
const answer = pulled;
|
|
431
767
|
pulled = void 0;
|
|
@@ -442,7 +778,7 @@ const entryStream = (blocks, at, signal, count) => {
|
|
|
442
778
|
}, {
|
|
443
779
|
begin: () => Effect.void,
|
|
444
780
|
entry: () => Effect.void,
|
|
445
|
-
data:
|
|
781
|
+
data: Effect.fnUntraced(function* (bytes) {
|
|
446
782
|
sha.update(bytes);
|
|
447
783
|
if (last !== void 0) yield* hand(last);
|
|
448
784
|
last = bytes.slice();
|
|
@@ -453,7 +789,7 @@ const entryStream = (blocks, at, signal, count) => {
|
|
|
453
789
|
count: 2,
|
|
454
790
|
index: 0,
|
|
455
791
|
offset: at.offset
|
|
456
|
-
}).pipe(Effect.mapError((error) =>
|
|
792
|
+
}).pipe(Effect.mapError((error) => isGitError(error) ? error : lost(`Pack ${at.pack.id} is unreadable at ${at.offset}: ${error.message}`)));
|
|
457
793
|
const hashed = Hex.encode(sha.digest());
|
|
458
794
|
if (hashed !== at.oid) return yield* Effect.fail(lost(`Object ${at.oid} in pack ${at.pack.id} hashes to ${hashed}`));
|
|
459
795
|
if (last !== void 0) yield* hand(last);
|
|
@@ -496,25 +832,36 @@ const entryStream = (blocks, at, signal, count) => {
|
|
|
496
832
|
}, { highWaterMark: 0 });
|
|
497
833
|
};
|
|
498
834
|
/**
|
|
499
|
-
* A reader's memory outside any budget: the read cache and every block it may keep, fixed. For
|
|
500
|
-
* maintenance, whose Durable Object runs one step at a time in its own isolate.
|
|
501
|
-
*/
|
|
502
|
-
const fixedReaderMemory = () => ({
|
|
503
|
-
cache: fixedRoom(readCacheBytes),
|
|
504
|
-
blocks: fixedRoom(8 * blockHeld(blockBytes)),
|
|
505
|
-
index: () => Effect.void,
|
|
506
|
-
outside: () => void 0
|
|
507
|
-
});
|
|
508
|
-
/**
|
|
509
835
|
* What a pack's `.idx` and `.rev` take, by its objects, as an index read holds them: the `.idx`'s
|
|
510
836
|
* header, fan-out and trailer, its ID, CRC and offset for each object, and a large offset for each
|
|
511
837
|
* past 2 GiB; the `.rev`'s header, trailer and a position for each; and their entry's overhead.
|
|
512
838
|
*/
|
|
513
|
-
const indexBytes = (pack) =>
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
839
|
+
const indexBytes = (pack) => idxMostBytes(pack) + revBytes(pack) + 384;
|
|
840
|
+
/**
|
|
841
|
+
* The most a pack's `.idx` takes: its header, fan-out and trailer, and each object's fields. Only
|
|
842
|
+
* a pack past 2 GiB gets large offsets, since this server's writers put no offset under 2^31 in
|
|
843
|
+
* the table (`sortedIndex`). A Git-made index that puts smaller offsets there
|
|
844
|
+
* (`--index-version=2,<offset>`) is longer, and its read refuses it as `DATA_LOSS`. No path
|
|
845
|
+
* stores one.
|
|
846
|
+
*/
|
|
847
|
+
const idxMostBytes = (pack) => 1072 + 28 * pack.objects + (pack.bytes > 2 ** 31 ? 8 * pack.objects : 0);
|
|
848
|
+
/** A pack's `.rev`: its header and trailer, and a position for each object. */
|
|
849
|
+
const revBytes = (pack) => 52 + 4 * pack.objects;
|
|
850
|
+
/**
|
|
851
|
+
* `key`'s whole file in one array of `most` bytes, as `indexBytes` charges it, or `undefined` when
|
|
852
|
+
* the bucket has none: each chunk is copied in as it comes, never joined after, so the file is
|
|
853
|
+
* never held twice (#1132). One past `most` is `lost`, as `named`'s, unreadable.
|
|
854
|
+
*/
|
|
855
|
+
const readInto = (bucket, key, most, named) => bucketDo(Effect.suspend(() => {
|
|
856
|
+
const bytes = new Uint8Array(most);
|
|
857
|
+
let at = 0;
|
|
858
|
+
return bucket.read(key).pipe(Stream.runForEach((chunk) => {
|
|
859
|
+
if (chunk.byteLength > most - at) return Effect.fail(lost(`${named} is unreadable: it's past the ${most} bytes its objects take`));
|
|
860
|
+
bytes.set(chunk, at);
|
|
861
|
+
at += chunk.byteLength;
|
|
862
|
+
return Effect.void;
|
|
863
|
+
}), Effect.map(() => bytes.subarray(0, at)), Effect.catchIf((error) => Predicate.isTagged(error, "NotFound"), () => Effect.succeed(void 0)));
|
|
864
|
+
}));
|
|
518
865
|
/**
|
|
519
866
|
* One operation's reads of a repo's objects under `packs()`: its rows first, a small push's,
|
|
520
867
|
* then each pack its list names, by the pack's `.idx`. An object is resolved from the pack's
|
|
@@ -532,6 +879,21 @@ const packReader = (input) => {
|
|
|
532
879
|
const named = new Set(listed.packs.map((pack) => pack.id));
|
|
533
880
|
const kept = /* @__PURE__ */ new Map();
|
|
534
881
|
const charged = /* @__PURE__ */ new Set();
|
|
882
|
+
const charging = new SingleFlight();
|
|
883
|
+
const loadings = /* @__PURE__ */ new Set();
|
|
884
|
+
/**
|
|
885
|
+
* `pack`'s `.idx` and `.rev` charged to the reader's allotment, once a reader: marked only once
|
|
886
|
+
* granted, so a read at once on the reader waits on the charge before it loads, and a refused or
|
|
887
|
+
* interrupted charge is asked again by the next read, never skipped.
|
|
888
|
+
*/
|
|
889
|
+
const charge = Effect.fnUntraced(function* (pack) {
|
|
890
|
+
if (charged.has(pack.id)) return;
|
|
891
|
+
const granted = yield* charging.run(pack.id, Effect.tap(memory.index(indexBytes(pack)), () => Effect.sync(() => {
|
|
892
|
+
charged.add(pack.id);
|
|
893
|
+
for (const told of loadings) told(pack.id);
|
|
894
|
+
})));
|
|
895
|
+
if (Option.isNone(granted)) yield* charge(pack);
|
|
896
|
+
});
|
|
535
897
|
const unnamed = (pack) => !named.has(pack.id);
|
|
536
898
|
/** The packs the repo lists now that `listed` didn't, such as a merge's that folded rows. */
|
|
537
899
|
const listedSince = Effect.fnUntraced(function* () {
|
|
@@ -570,27 +932,25 @@ const packReader = (input) => {
|
|
|
570
932
|
/**
|
|
571
933
|
* Where each of `oids` is in the listed packs, by the first pack that lists it, then in those
|
|
572
934
|
* listed since, then in those the repo's delete let go of, a page at a time, for any not found:
|
|
573
|
-
* each read apart, so neither collection's rows count against the other's answer.
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
* pack's indexes once, however small that cache is.
|
|
577
|
-
* `IndexedPack` until the reader is released
|
|
578
|
-
* cache: at most every listed pack's `.idx` and `.rev` at once. Each pack's are charged to
|
|
579
|
-
* reader's allotment before its first load, and stay charged until the allotment ends.
|
|
935
|
+
* each read apart, so neither collection's rows count against the other's answer. `from` says
|
|
936
|
+
* which of them it looks in: `listed` the listed packs alone, `beyond` all but them. Each listed
|
|
937
|
+
* pack's indexes it loads are kept by the pack's ID, in the reader's own `kept`, and read before
|
|
938
|
+
* the server's cache: a reader loads a listed pack's indexes once, however small that cache is.
|
|
939
|
+
* It holds only what was loaded, each `IndexedPack` until the reader is released, outside the
|
|
940
|
+
* index cache: at most every listed pack's `.idx` and `.rev` at once. Each pack's are charged to
|
|
941
|
+
* the reader's allotment before its first load, and stay charged until the allotment ends.
|
|
580
942
|
* A pack `listed` doesn't name, listed since or leaving, is this call's alone, through the
|
|
581
|
-
* server's cache, so a reader holds no more than its listing names.
|
|
943
|
+
* server's cache, so a reader holds no more than its listing names. A listed pack in `skip`
|
|
944
|
+
* isn't looked in, its indexes never loaded: an index proves it holds none of `oids` (#522).
|
|
582
945
|
*/
|
|
583
|
-
const found = Effect.fnUntraced(function* (oids,
|
|
946
|
+
const found = Effect.fnUntraced(function* (oids, from = "all", skip) {
|
|
584
947
|
const where = /* @__PURE__ */ new Map();
|
|
585
948
|
let left = [...new Set(oids)];
|
|
586
949
|
const look = Effect.fnUntraced(function* (packs, held, going = false) {
|
|
587
950
|
for (const listedPack of packs) {
|
|
588
951
|
if (left.length === 0) break;
|
|
589
952
|
const known = held.get(listedPack.id);
|
|
590
|
-
if (known === void 0
|
|
591
|
-
yield* memory.index(indexBytes(listedPack));
|
|
592
|
-
charged.add(listedPack.id);
|
|
593
|
-
}
|
|
953
|
+
if (known === void 0) yield* charge(listedPack);
|
|
594
954
|
const indexed = known === void 0 ? yield* indexes.load(bucket, listedPack).pipe(Effect.asSome, Effect.catch((error) => going && error.code === "DATA_LOSS" ? Effect.succeedNone : Effect.fail(error))) : Option.some(known);
|
|
595
955
|
if (Option.isNone(indexed)) continue;
|
|
596
956
|
held.set(listedPack.id, indexed.value);
|
|
@@ -606,8 +966,9 @@ const packReader = (input) => {
|
|
|
606
966
|
});
|
|
607
967
|
}
|
|
608
968
|
});
|
|
609
|
-
|
|
610
|
-
|
|
969
|
+
const looked = skip === void 0 ? listed.packs : listed.packs.filter((pack) => !skip.has(pack.id));
|
|
970
|
+
yield* look(from === "beyond" ? [] : looked, kept);
|
|
971
|
+
if (left.length === 0 || listedOnly === true || from === "listed") return where;
|
|
611
972
|
const unlisted = /* @__PURE__ */ new Map();
|
|
612
973
|
yield* look(yield* listedSince(), unlisted);
|
|
613
974
|
let after;
|
|
@@ -625,8 +986,8 @@ const packReader = (input) => {
|
|
|
625
986
|
* each handed to `row`; then, for what neither holds, the packs listed since and those leaving,
|
|
626
987
|
* as a merge that folded the rows after this read's listing leaves them.
|
|
627
988
|
*/
|
|
628
|
-
const located = Effect.fnUntraced(function* (oids, row) {
|
|
629
|
-
const where = yield* found(oids,
|
|
989
|
+
const located = Effect.fnUntraced(function* (oids, row, skip) {
|
|
990
|
+
const where = yield* found(oids, "listed", skip);
|
|
630
991
|
const unpacked = oids.filter((oid) => !where.has(oid));
|
|
631
992
|
if (unpacked.length === 0) return where;
|
|
632
993
|
const inRows = /* @__PURE__ */ new Set();
|
|
@@ -635,7 +996,9 @@ const packReader = (input) => {
|
|
|
635
996
|
return row(object);
|
|
636
997
|
});
|
|
637
998
|
const missing = unpacked.filter((oid) => !inRows.has(oid));
|
|
638
|
-
if (missing.length > 0) for (const [oid, place] of yield* found(missing)) where.set(oid, place);
|
|
999
|
+
if (missing.length > 0) for (const [oid, place] of yield* found(missing, "all", skip)) where.set(oid, place);
|
|
1000
|
+
const skipped = skip === void 0 ? [] : missing.filter((oid) => !where.has(oid));
|
|
1001
|
+
if (skipped.length > 0) for (const [oid, place] of yield* found(skipped)) where.set(oid, place);
|
|
639
1002
|
return where;
|
|
640
1003
|
});
|
|
641
1004
|
/**
|
|
@@ -643,40 +1006,62 @@ const packReader = (input) => {
|
|
|
643
1006
|
* finds them: the listed packs first, so a walk over a repo whose objects are all packed asks the
|
|
644
1007
|
* store for no row (#647), then the rows, then the packs listed since and those leaving.
|
|
645
1008
|
*/
|
|
646
|
-
const
|
|
647
|
-
const where = yield* located(oids, take);
|
|
1009
|
+
const eachOf = (skip) => Effect.fnUntraced(function* (oids, take) {
|
|
1010
|
+
const where = yield* located(oids, take, skip);
|
|
648
1011
|
for (const [oid, { indexed, offset }] of where) yield* take(yield* wholeAt(oid, indexed, offset));
|
|
649
1012
|
});
|
|
1013
|
+
const each = eachOf();
|
|
1014
|
+
/** Which of `oids` the repo holds, read whole, through `take`'s reads. */
|
|
1015
|
+
const heldOf = (take) => Effect.fnUntraced(function* (oids) {
|
|
1016
|
+
const objects = /* @__PURE__ */ new Map();
|
|
1017
|
+
yield* take(oids, (object) => Effect.sync(() => void objects.set(object.oid, object)));
|
|
1018
|
+
return objects;
|
|
1019
|
+
});
|
|
650
1020
|
/** Which of `oids` the repo holds, read whole. */
|
|
651
|
-
const held =
|
|
1021
|
+
const held = heldOf(each);
|
|
1022
|
+
/** Each of `entries` read whole where the index placed it, as `held` reads one it found. */
|
|
1023
|
+
const heldAt = Effect.fnUntraced(function* (entries) {
|
|
652
1024
|
const objects = /* @__PURE__ */ new Map();
|
|
653
|
-
|
|
1025
|
+
for (const { oid, lookup, offset } of entries) objects.set(oid, yield* wholeAt.atIn(oid, lookup, offset));
|
|
654
1026
|
return objects;
|
|
655
1027
|
});
|
|
656
1028
|
/**
|
|
657
1029
|
* The size of the object an entry holds, from its header, or a delta's from its instructions'
|
|
658
1030
|
* header, its base never read; an entry whose header won't say is resolved whole.
|
|
659
1031
|
*/
|
|
660
|
-
const sizeAt = Effect.fnUntraced(function* (oid,
|
|
661
|
-
const head = yield* blocks.headAt(
|
|
1032
|
+
const sizeAt = Effect.fnUntraced(function* (oid, lookup, offset) {
|
|
1033
|
+
const head = yield* blocks.headAt(lookup.pack, offset);
|
|
662
1034
|
const header = readEntryHeader(head, head.byteLength, offset, headerLimits);
|
|
663
1035
|
if (header.kind === "entry" && header.type !== "ofs" && header.type !== "ref") return header.size;
|
|
664
1036
|
if (header.kind === "entry") {
|
|
665
|
-
const read = yield* blocks.entryAt(
|
|
1037
|
+
const read = yield* blocks.entryAt(lookup.pack, offset);
|
|
666
1038
|
const size = read === "too big" ? void 0 : deltaResultSize(read.data);
|
|
667
1039
|
if (size !== void 0) return size;
|
|
668
1040
|
}
|
|
669
|
-
return (yield* wholeAt(oid,
|
|
1041
|
+
return (yield* wholeAt.atIn(oid, lookup, offset)).bytes.byteLength;
|
|
670
1042
|
});
|
|
671
1043
|
/**
|
|
672
1044
|
* The size of each of `oids` the repo holds, none held whole past its own read: each pack's in
|
|
673
1045
|
* the order of its offsets, so its neighbourhoods are read once.
|
|
674
1046
|
*/
|
|
675
|
-
const
|
|
1047
|
+
const sizesOf = (skip) => Effect.fnUntraced(function* (oids) {
|
|
676
1048
|
const sized = /* @__PURE__ */ new Map();
|
|
677
1049
|
for (const [oid, size] of yield* rowsSized(oids)) sized.set(oid, size);
|
|
678
|
-
const
|
|
679
|
-
|
|
1050
|
+
const unsized = oids.filter((oid) => !sized.has(oid));
|
|
1051
|
+
const where = yield* found(unsized, "all", skip);
|
|
1052
|
+
const skipped = skip === void 0 ? [] : unsized.filter((oid) => !where.has(oid));
|
|
1053
|
+
if (skipped.length > 0) for (const [oid, place] of yield* found(skipped)) where.set(oid, place);
|
|
1054
|
+
for (const [oid, { indexed, offset }] of byPlace(where)) sized.set(oid, yield* sizeAt(oid, loadedLookup(indexed), offset));
|
|
1055
|
+
return sized;
|
|
1056
|
+
});
|
|
1057
|
+
const sizes = sizesOf();
|
|
1058
|
+
/**
|
|
1059
|
+
* The size of each of `at`'s entries of `pack`, in its order, as `sizes` sizes them, with no
|
|
1060
|
+
* look-up by ID: a fetch's send list knows each entry's place from the index (#522).
|
|
1061
|
+
*/
|
|
1062
|
+
const sizesAt = Effect.fnUntraced(function* (pack, at) {
|
|
1063
|
+
const sized = new Float64Array(at.length);
|
|
1064
|
+
for (const [slot, { oid, offset }] of at.entries()) sized[slot] = yield* sizeAt(oid, pack, offset);
|
|
680
1065
|
return sized;
|
|
681
1066
|
});
|
|
682
1067
|
/**
|
|
@@ -742,13 +1127,19 @@ const packReader = (input) => {
|
|
|
742
1127
|
});
|
|
743
1128
|
/**
|
|
744
1129
|
* The type and size of each of `oids` the repo holds, as `git cat-file --batch-check` gives
|
|
745
|
-
* them, from headers alone
|
|
746
|
-
*
|
|
747
|
-
*
|
|
1130
|
+
* them, from headers alone, found in `located`'s order: the listed packs first, so a repo whose
|
|
1131
|
+
* objects are all packed asks the store for no row (#647), then the rows, then the packs listed
|
|
1132
|
+
* since and those leaving, each pack's entries in the order of their offsets. A delta's size is
|
|
1133
|
+
* its result's and its type its chain's, as `typeAt` follows it. An entry whose header or chain
|
|
1134
|
+
* won't say is read whole.
|
|
748
1135
|
*/
|
|
749
1136
|
const headers = Effect.fnUntraced(function* (oids) {
|
|
750
|
-
const
|
|
751
|
-
const
|
|
1137
|
+
const listedAt = yield* found(oids, "listed");
|
|
1138
|
+
const unpacked = oids.filter((oid) => !listedAt.has(oid));
|
|
1139
|
+
const answer = new Map(unpacked.length === 0 ? [] : yield* rowsHeaders(unpacked));
|
|
1140
|
+
const missing = unpacked.filter((oid) => !answer.has(oid));
|
|
1141
|
+
const later = missing.length === 0 ? [] : yield* found(missing, "beyond");
|
|
1142
|
+
const where = byPlace(new Map([...listedAt, ...later]));
|
|
752
1143
|
const known = /* @__PURE__ */ new Map();
|
|
753
1144
|
for (const [oid, { indexed, offset }] of where) {
|
|
754
1145
|
const type = yield* typeAt(indexed, offset, known);
|
|
@@ -762,25 +1153,30 @@ const packReader = (input) => {
|
|
|
762
1153
|
}
|
|
763
1154
|
answer.set(oid, {
|
|
764
1155
|
type,
|
|
765
|
-
size: yield* sizeAt(oid, indexed, offset)
|
|
1156
|
+
size: yield* sizeAt(oid, loadedLookup(indexed), offset)
|
|
766
1157
|
});
|
|
767
1158
|
}
|
|
768
1159
|
return answer;
|
|
769
1160
|
});
|
|
770
1161
|
/**
|
|
771
1162
|
* Which of `oids` the repo holds, and where, by its rows and its packs' indexes, none read: the
|
|
772
|
-
* listed pack an index found it in, by ID, or `undefined` for a row.
|
|
773
|
-
* the packs' indexes it loads, as `found` says, for later calls given it too.
|
|
1163
|
+
* listed pack an index found it in, by ID, or `undefined` for a row.
|
|
774
1164
|
*/
|
|
775
|
-
const heldIn = Effect.fnUntraced(function* (oids
|
|
1165
|
+
const heldIn = Effect.fnUntraced(function* (oids) {
|
|
776
1166
|
const there = /* @__PURE__ */ new Map();
|
|
777
1167
|
for (const oid of (yield* rowsSized(oids)).keys()) there.set(oid, void 0);
|
|
778
|
-
const packed = yield* found(oids.filter((oid) => !there.has(oid))
|
|
1168
|
+
const packed = yield* found(oids.filter((oid) => !there.has(oid)));
|
|
779
1169
|
for (const [oid, { indexed }] of packed) there.set(oid, indexed.pack.id);
|
|
780
1170
|
return there;
|
|
781
1171
|
});
|
|
782
1172
|
/** Which of `oids` the repo holds, as `heldIn` finds them. */
|
|
783
|
-
const has = (oids
|
|
1173
|
+
const has = (oids) => Effect.map(heldIn(oids), (there) => new Set(there.keys()));
|
|
1174
|
+
/**
|
|
1175
|
+
* Where each of `oids` is in the packs listed since this read's listing and those its delete let
|
|
1176
|
+
* go of, as `found` looks in them, the listed packs left out: a lookup that read the listed ones
|
|
1177
|
+
* by range asks these for what they didn't hold.
|
|
1178
|
+
*/
|
|
1179
|
+
const beyond = (oids) => found(oids, "beyond");
|
|
784
1180
|
/** What the entry at `offset` holds, by its header, or `undefined` for one that won't say. */
|
|
785
1181
|
const holdsAt = Effect.fnUntraced(function* (indexed, offset) {
|
|
786
1182
|
const head = yield* blocks.headAt(indexed.pack, offset);
|
|
@@ -798,10 +1194,11 @@ const packReader = (input) => {
|
|
|
798
1194
|
* The entry each of `oids` is stored as, to copy as it is: its length by the pack's `.rev`, its
|
|
799
1195
|
* CRC-32 by its `.idx`, and what it holds by its header, a whole object or a delta on a base it
|
|
800
1196
|
* names by ID. An entry that won't say, or an offset delta, is left out, to be read whole.
|
|
1197
|
+
* A listed pack in `skip` isn't looked in, as `found` says.
|
|
801
1198
|
*/
|
|
802
|
-
const storedOf = Effect.fnUntraced(function* (oids,
|
|
1199
|
+
const storedOf = Effect.fnUntraced(function* (oids, skip) {
|
|
803
1200
|
const entries = /* @__PURE__ */ new Map();
|
|
804
|
-
for (const [oid, { indexed, offset, crc32 }] of byPlace(yield* found(oids,
|
|
1201
|
+
for (const [oid, { indexed, offset, crc32 }] of byPlace(yield* found(oids, "all", skip))) {
|
|
805
1202
|
const { pack } = indexed;
|
|
806
1203
|
const end = entryEnd(indexed, offset);
|
|
807
1204
|
if (end === void 0 || end <= offset) return yield* Effect.fail(lost(`Pack ${pack.id}'s reverse index has no entry at ${offset}`));
|
|
@@ -824,10 +1221,12 @@ const packReader = (input) => {
|
|
|
824
1221
|
return Effect.map(blocks.block(entry.pack, start), (block) => block.subarray(from - start, Math.min(block.byteLength, from - start + entry.bytes - at)));
|
|
825
1222
|
};
|
|
826
1223
|
const stored = {
|
|
827
|
-
find: storedOf,
|
|
1224
|
+
find: (oids) => storedOf(oids),
|
|
828
1225
|
read,
|
|
829
1226
|
gets: (entries) => blocks.gets(entries),
|
|
830
|
-
|
|
1227
|
+
run: (pack, from, to) => packRun(bucket, pack, from, to),
|
|
1228
|
+
kept: (pack, offset) => blocks.keeps(pack, offset),
|
|
1229
|
+
packed: (oids) => Effect.map(found(oids, "listed"), (where) => new Set(where.keys()))
|
|
831
1230
|
};
|
|
832
1231
|
/**
|
|
833
1232
|
* The object `oid` as `ObjectReader.read` hands it on, rows first: a whole entry past
|
|
@@ -885,7 +1284,7 @@ const packReader = (input) => {
|
|
|
885
1284
|
}
|
|
886
1285
|
const bytes = new Uint8Array(resolved.object.bytes);
|
|
887
1286
|
const checked = checkedNow(indexed.pack, oid, resolved.object.kind, bytes);
|
|
888
|
-
if (
|
|
1287
|
+
if (isGitError(checked)) return yield* Effect.fail(checked);
|
|
889
1288
|
answer.keep(checked);
|
|
890
1289
|
run.at += size;
|
|
891
1290
|
if (run.at >= 1048576) {
|
|
@@ -926,7 +1325,7 @@ const packReader = (input) => {
|
|
|
926
1325
|
* offset, from their `.idx` alone with no header read, then the rest as they came (#662).
|
|
927
1326
|
*/
|
|
928
1327
|
const inPackOrder = Effect.fnUntraced(function* (oids) {
|
|
929
|
-
const where = yield* found(oids,
|
|
1328
|
+
const where = yield* found(oids, "listed");
|
|
930
1329
|
return [...byPlace(where).map(([oid]) => oid), ...oids.filter((oid) => !where.has(oid))];
|
|
931
1330
|
});
|
|
932
1331
|
/**
|
|
@@ -939,24 +1338,87 @@ const packReader = (input) => {
|
|
|
939
1338
|
wholeAt.clear();
|
|
940
1339
|
kept.clear();
|
|
941
1340
|
};
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1341
|
+
/**
|
|
1342
|
+
* A listed pack's `.idx` and `.rev` as this reader holds them: loaded and charged as its own
|
|
1343
|
+
* lookups load them, once a pack, through the server's cache, so a fetch's index path and its
|
|
1344
|
+
* walk read them once between them, and none when the cache holds them.
|
|
1345
|
+
*/
|
|
1346
|
+
const indexed = Effect.fnUntraced(function* (pack) {
|
|
1347
|
+
const known = kept.get(pack.id);
|
|
1348
|
+
if (known !== void 0) return known;
|
|
1349
|
+
yield* charge(pack);
|
|
1350
|
+
const loaded = yield* indexes.load(bucket, pack);
|
|
1351
|
+
kept.set(pack.id, loaded);
|
|
1352
|
+
return loaded;
|
|
1353
|
+
});
|
|
1354
|
+
/**
|
|
1355
|
+
* `ObjectReader.startingWith`: the IDs that start with `prefix` in the listed packs and the rows;
|
|
1356
|
+
* then, unless the rows were read at the listing's own version, in the packs listed since and
|
|
1357
|
+
* those leaving, where a merge that folded rows after this read's listing put them. Each pack is
|
|
1358
|
+
* opened by range, as `openRanges` opens it, and only its IDs under the prefix's first byte read,
|
|
1359
|
+
* never loaded whole; each place gives at most `most + 1`, so `more` holds past `most`.
|
|
1360
|
+
*/
|
|
1361
|
+
const startingWith = Effect.fnUntraced(function* (prefix, most) {
|
|
1362
|
+
const found = [];
|
|
1363
|
+
const look = Effect.fnUntraced(function* (packs, going) {
|
|
1364
|
+
for (const { id, bytes, objects } of packs) {
|
|
1365
|
+
if (!isPackId(id)) return yield* Effect.fail(lost(`The pack row '${id}' doesn't name a pack`));
|
|
1366
|
+
const ids = yield* Effect.flatMap(openRanges(bucket, {
|
|
1367
|
+
id,
|
|
1368
|
+
bytes
|
|
1369
|
+
}, objects, 0), (ranges) => idsStartingWith(ranges, prefix, most)).pipe(Effect.catch((error) => going && error.code === "DATA_LOSS" ? Effect.succeed([]) : Effect.fail(error)));
|
|
1370
|
+
found.push(ids);
|
|
949
1371
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
1372
|
+
});
|
|
1373
|
+
yield* look(listed.packs, false);
|
|
1374
|
+
if (listedOnly === true) return startingOf(found, most);
|
|
1375
|
+
const inRows = yield* rowsStartingWith(store, listed.repo, prefix, most + 1);
|
|
1376
|
+
found.push(inRows.oids);
|
|
1377
|
+
if (inRows.version === listed.version) return startingOf(found, most);
|
|
1378
|
+
yield* look(yield* listedSince(), false);
|
|
1379
|
+
let after;
|
|
1380
|
+
do {
|
|
1381
|
+
const page = yield* leavingPage(after);
|
|
1382
|
+
yield* look(page.packs, true);
|
|
1383
|
+
after = page.next;
|
|
1384
|
+
} while (after !== void 0);
|
|
1385
|
+
return startingOf(found, most);
|
|
1386
|
+
});
|
|
1387
|
+
/**
|
|
1388
|
+
* Reads of IDs a reachability index proves none of `covered`'s packs holds, as `UnplacedReads`
|
|
1389
|
+
* says: the rows and the other packs, never a covered pack's `.idx` and `.rev` (#522).
|
|
1390
|
+
*/
|
|
1391
|
+
const unplaced = (covered) => {
|
|
1392
|
+
const take = eachOf(covered);
|
|
1393
|
+
return {
|
|
1394
|
+
each: take,
|
|
1395
|
+
held: heldOf(take),
|
|
1396
|
+
sizes: sizesOf(covered),
|
|
1397
|
+
find: (oids) => storedOf(oids, covered),
|
|
1398
|
+
packed: (oids) => Effect.map(found(oids, "listed", covered), (where) => new Set(where.keys()))
|
|
1399
|
+
};
|
|
1400
|
+
};
|
|
1401
|
+
const reads = {
|
|
1402
|
+
indexed,
|
|
1403
|
+
loadedOf: (pack) => kept.get(pack.id),
|
|
1404
|
+
onLoading: (told) => {
|
|
1405
|
+
loadings.add(told);
|
|
1406
|
+
return () => {
|
|
1407
|
+
loadings.delete(told);
|
|
1408
|
+
};
|
|
1409
|
+
},
|
|
954
1410
|
held,
|
|
1411
|
+
unplaced,
|
|
1412
|
+
heldAt,
|
|
955
1413
|
each,
|
|
956
1414
|
has,
|
|
1415
|
+
seenHeld: has,
|
|
1416
|
+
startingWith,
|
|
957
1417
|
heldIn,
|
|
1418
|
+
beyond,
|
|
958
1419
|
headers,
|
|
959
1420
|
sizes,
|
|
1421
|
+
sizesAt,
|
|
960
1422
|
stored,
|
|
961
1423
|
blocks,
|
|
962
1424
|
object,
|
|
@@ -967,24 +1429,51 @@ const packReader = (input) => {
|
|
|
967
1429
|
};
|
|
968
1430
|
return input.visible === void 0 ? reads : narrowedTo(reads, input.visible);
|
|
969
1431
|
};
|
|
1432
|
+
/**
|
|
1433
|
+
* The IDs a narrowed short-ID read asks its view about: `found`, then IDs that start with
|
|
1434
|
+
* `prefix` past them, up to `most` in all, so the view's reads turn on how many are asked, never
|
|
1435
|
+
* on how many the repo holds. A short ID of 39 digits starts 16, so it asks at most those.
|
|
1436
|
+
*/
|
|
1437
|
+
const askedOf = (found, prefix, most) => {
|
|
1438
|
+
const asked = new Set(found);
|
|
1439
|
+
const free = 40 - prefix.length;
|
|
1440
|
+
for (let at = 0; free > 0 && asked.size < most && at < 16 ** free; at += 1) asked.add(`${prefix}${at.toString(16).padStart(free, "0")}`);
|
|
1441
|
+
return [...asked];
|
|
1442
|
+
};
|
|
970
1443
|
/** `reads`, each lookup by ID answering only what `visible` holds, as `PackReaderInput` says. */
|
|
971
1444
|
const narrowedTo = (reads, visible) => {
|
|
972
|
-
const only = (oids) => Effect.map(
|
|
1445
|
+
const only = (oids, asked = visible) => Effect.map(asked(oids), (kept) => oids.filter((oid) => kept.has(oid)));
|
|
973
1446
|
return {
|
|
974
1447
|
...reads,
|
|
975
1448
|
held: (oids) => Effect.flatMap(only(oids), reads.held),
|
|
976
1449
|
each: (oids, take) => Effect.flatMap(only(oids), (kept) => reads.each(kept, take)),
|
|
977
|
-
|
|
978
|
-
|
|
1450
|
+
unplaced: (covered) => {
|
|
1451
|
+
const outside = reads.unplaced(covered);
|
|
1452
|
+
return {
|
|
1453
|
+
each: (oids, take) => Effect.flatMap(only(oids), (kept) => outside.each(kept, take)),
|
|
1454
|
+
held: (oids) => Effect.flatMap(only(oids), outside.held),
|
|
1455
|
+
sizes: (oids) => Effect.flatMap(only(oids), outside.sizes),
|
|
1456
|
+
find: (oids) => Effect.flatMap(only(oids), outside.find),
|
|
1457
|
+
packed: (oids) => Effect.flatMap(only(oids), outside.packed)
|
|
1458
|
+
};
|
|
1459
|
+
},
|
|
1460
|
+
has: (oids) => Effect.flatMap(only(oids), reads.has),
|
|
1461
|
+
seenHeld: (oids) => Effect.flatMap(only(oids, visible.shown), (kept) => reads.has(kept)),
|
|
1462
|
+
startingWith: (prefix, most) => Effect.flatMap(reads.startingWith(prefix, most), (found) => Effect.map(only(askedOf(found.oids, prefix, most)), (kept) => ({
|
|
1463
|
+
oids: found.oids.filter((oid) => kept.includes(oid)),
|
|
1464
|
+
more: found.more
|
|
1465
|
+
}))),
|
|
1466
|
+
heldIn: (oids) => Effect.flatMap(only(oids), reads.heldIn),
|
|
1467
|
+
beyond: (oids) => Effect.flatMap(only(oids), reads.beyond),
|
|
979
1468
|
headers: (oids) => Effect.flatMap(only(oids), reads.headers),
|
|
980
1469
|
sizes: (oids) => Effect.flatMap(only(oids), reads.sizes),
|
|
981
1470
|
stored: {
|
|
982
1471
|
...reads.stored,
|
|
983
|
-
find: (oids
|
|
1472
|
+
find: (oids) => Effect.flatMap(only(oids), reads.stored.find)
|
|
984
1473
|
},
|
|
985
1474
|
object: (oid, signal) => Effect.flatMap(only([oid]), (kept) => kept.length === 0 ? Effect.succeed(void 0) : reads.object(oid, signal)),
|
|
986
1475
|
objects: (oids, allotment) => Effect.flatMap(only(oids), (kept) => reads.objects(kept, allotment)),
|
|
987
1476
|
wholeBlobs: (oids) => Effect.flatMap(only(oids), reads.wholeBlobs)
|
|
988
1477
|
};
|
|
989
1478
|
};
|
|
990
|
-
export { PackBlocks, PackIndexes, blockBytes, blockHeld,
|
|
1479
|
+
export { PackBlocks, PackIndexes, blockBytes, blockHeld, blocksHeld, entryEnd, hashedNowMost, hashedRunMost, headerLimits, indexBytes, indexSeedShare, loadedLookup, packFileBytes, packIndexerLimits, packObjectBytes, packObjects, packReader, rangedLookup, readCacheBytes, seedBytes };
|