@ref0/git 0.3.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 +22 -2
- 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 +35 -8
- package/dist/auth/identify.d.mts +3 -0
- 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 +3 -0
- 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 +3 -3
- 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 +94 -99
- 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 +58 -18
- 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/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 +323 -87
- package/dist/contracts/operations.d.mts +24 -16
- package/dist/contracts/promises.d.mts +13 -2
- package/dist/contracts/push-uploads.d.mts +39 -24
- package/dist/contracts/push-uploads.mjs +54 -0
- package/dist/contracts/queue.d.mts +444 -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 +335 -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 +113 -47
- 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 +81 -46
- 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 +123 -67
- 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 +25 -14
- package/dist/core/access.mjs +77 -108
- package/dist/core/ancestry.mjs +86 -18
- package/dist/core/call-names.mjs +1 -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 +119 -33
- 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 +13 -12
- 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 +13 -9
- 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 +300 -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 +8 -5
- package/dist/core/seam.mjs +19 -15
- 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 +106 -49
- package/dist/extend.d.mts +4 -2
- 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 +31 -26
- 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 +8 -8
- 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 +189 -120
- 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 +39 -12
- package/dist/queue/host.mjs +36 -38
- 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 +22 -22
- 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 +790 -23
- 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 +80 -70
- package/dist/rest/commits.d.mts +3315 -244
- 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 +1265 -114
- 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 +3 -0
- package/dist/rest/handler.mjs +22 -14
- package/dist/rest/handlers.mjs +53 -60
- 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 +2421 -93
- package/dist/rest/repos.mjs +10 -33
- package/dist/rest/tags.d.mts +1205 -54
- package/dist/rest/tags.mjs +6 -34
- package/dist/rest/tokens.d.mts +2369 -66
- 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 +1204 -63
- package/dist/rest/work.mjs +7 -51
- package/dist/rest.d.mts +3 -3
- package/dist/server/extension.d.mts +6 -2
- package/dist/server/extension.mjs +54 -30
- 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 +1 -2
- package/dist/server/lifecycle.mjs +8 -15
- 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 +12 -8
- package/dist/server/routes.mjs +27 -18
- package/dist/server/server.d.mts +19 -0
- package/dist/server/server.mjs +281 -198
- package/dist/signin/codes.mjs +9 -6
- package/dist/signin/context.d.mts +1 -0
- 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 +4 -2
- 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/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 +2 -0
- package/dist/storage/fetch.mjs +243 -100
- 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 +650 -164
- package/dist/storage/index-fetch.d.mts +3 -1
- package/dist/storage/index-fetch.mjs +297 -195
- 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 +102 -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 +69 -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 +598 -126
- package/dist/storage/pack-receive.d.mts +5 -0
- 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 +7 -5
- package/dist/storage/packs.mjs +554 -213
- 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 +22 -13
- 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 +4 -2
- 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 +4 -4
- package/dist/storage/repack.mjs +156 -77
- package/dist/storage/roots.mjs +23 -7
- package/dist/storage/rows.d.mts +4 -2
- package/dist/storage/rows.mjs +40 -7
- package/dist/storage/runs.d.mts +8 -0
- package/dist/storage/runs.mjs +731 -0
- package/dist/storage/send-list.d.mts +2 -1
- package/dist/storage/send-list.mjs +261 -76
- package/dist/storage/shallow.d.mts +3 -2
- 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 +52 -23
- package/dist/storage/visible.mjs +58 -39
- package/dist/storage/walk.d.mts +2 -0
- package/dist/storage/walk.mjs +20 -7
- 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 +17 -3
- package/dist/store/catalogue.mjs +135 -48
- package/dist/store/crossing.mjs +2 -4
- package/dist/store/cursor-seal.d.mts +12 -1
- package/dist/store/cursor-seal.mjs +7 -6
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +112 -24
- 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 +106 -28
- package/dist/store/promises.d.mts +3 -2
- package/dist/store/promises.mjs +94 -35
- 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 +32 -3
- 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.mjs +15 -23
- 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 +50 -32
- package/dist/sync.d.mts +3 -3
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +103 -86
- package/dist/topics/calls.mjs +97 -67
- package/dist/topics/directory.mjs +31 -11
- package/dist/topics/host.d.mts +0 -1
- package/dist/topics/host.mjs +2 -12
- package/dist/topics/members.mjs +30 -24
- package/dist/topics/rows.mjs +10 -9
- package/dist/topics/topic.mjs +20 -9
- 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,32 +1,36 @@
|
|
|
1
|
+
import { spentIn } from "../contracts/calls-spent.mjs";
|
|
2
|
+
import { gitError } from "../contracts/result.mjs";
|
|
1
3
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
2
4
|
import { Sha1 } from "../protocol/bytes/sha1.mjs";
|
|
3
5
|
import { writeCommitGraph } from "../protocol/packs/graph.mjs";
|
|
4
6
|
import { IndexerCache } from "../protocol/packs/indexer.mjs";
|
|
5
7
|
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
6
8
|
import { rawLinks } from "../protocol/objects/links-raw.mjs";
|
|
7
|
-
import { gitError } from "../store/errors.mjs";
|
|
8
9
|
import { randomText } from "../store/random.mjs";
|
|
9
|
-
import { allottableOf } from "./budget.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import { EdgeFiles, copyBitmaps, copyHeldBytes, copyRunBytes, edgesBytesOf, edgesFileOf, ewahMostWords, noNumber, runsMost, storedBitmaps, storedSize, writeBitmaps } from "./index-bitmaps.mjs";
|
|
10
|
+
import { allottableOf, uploadPartBytes } from "./budget.mjs";
|
|
11
|
+
import { bucketDo, bucketPut, joined, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
|
|
12
|
+
import { BitmapsPart, EdgeFiles, bitmapOrder, bitmapsMostBytes, bitmapsPut, copyBitmaps, copyHeldBytes, copyRunBytes, edgesBytesOf, edgesFileOf, ewahMostWords, noNumber, orderKey, partBitmaps, partBytesMost, runsMost, storedBitmaps, storedSize, writeBitmaps } from "./index-bitmaps.mjs";
|
|
12
13
|
import { BasesWriter, TypesWriter, indexBasesBytes, indexTypesBytes, openBases, openTypes, typeCodes } from "./index-files.mjs";
|
|
13
|
-
import { bitmapWords } from "./ewah.mjs";
|
|
14
|
-
import { graphChunk, mergeHeldBytes, mergeIndexGraphs, openGraphLayers, openIndexGraph, writeIndexGraph } from "./index-graph.mjs";
|
|
14
|
+
import { bitmapOf, bitmapWords, ewahOf, orEwah } from "./ewah.mjs";
|
|
15
|
+
import { graphChunk, indexGraphBytes, mergeHeldBytes, mergeIndexGraphs, openGraphLayers, openIndexGraph, writeIndexGraph } from "./index-graph.mjs";
|
|
15
16
|
import { hasBit, idsOf, lookupCalls, openLayerBitmaps, openLayout, orIntoBytes, reachOf } from "./index-layers.mjs";
|
|
16
17
|
import { indexFiles, indexPrefix, indexRowKey, isPackId, packFiles } from "./layout.mjs";
|
|
18
|
+
import { listedIds } from "./listed-ids.mjs";
|
|
17
19
|
import { joinBytes, joinLinks } from "./link-join.mjs";
|
|
18
20
|
import { outsideOn, readBusy } from "./memory-budget.mjs";
|
|
19
21
|
import { startPut } from "./merge.mjs";
|
|
20
22
|
import { eachPageAt, objectOfRow } from "./object-rows.mjs";
|
|
21
|
-
import { SliceLinks, SliceRefused, cutAtSpent, isSliceRefused, linksPastMemory, nothingSettled, readSlice, sliceRefusal, spentOf } from "./pack-order.mjs";
|
|
22
|
-
import { PackBlocks,
|
|
23
|
+
import { SliceLinks, SliceRefused, cutAtSpent, isSliceRefused, linksPastMemory, nothingSettled, readSlice, slicePackOf, sliceRefusal, spentOf } from "./pack-order.mjs";
|
|
24
|
+
import { PackBlocks, blocksHeld, packIndexerLimits } from "./pack-reads.mjs";
|
|
23
25
|
import { rangeRanks, readExactly } from "./pack-ranges.mjs";
|
|
26
|
+
import { rangeCached } from "./range-cache.mjs";
|
|
24
27
|
import { compareIds } from "./raw-ids.mjs";
|
|
28
|
+
import * as Schema from "effect/Schema";
|
|
25
29
|
import * as Effect from "effect/Effect";
|
|
26
30
|
import * as Result from "effect/Result";
|
|
27
|
-
import * as
|
|
31
|
+
import * as Cause from "effect/Cause";
|
|
28
32
|
import * as Option from "effect/Option";
|
|
29
|
-
import * as
|
|
33
|
+
import * as Stream from "effect/Stream";
|
|
30
34
|
// src/storage/index-build.ts
|
|
31
35
|
/**
|
|
32
36
|
* The reachability index's first build, `git.index`'s steps, one a try: the region's rows read,
|
|
@@ -43,9 +47,9 @@ import * as Exit from "effect/Exit";
|
|
|
43
47
|
const lost = (message) => gitError("DATA_LOSS", message);
|
|
44
48
|
/** A build's ID, new for each: `i_` and 12 random bytes. */
|
|
45
49
|
const newBuildId = () => `i_${randomText(12)}`;
|
|
46
|
-
const Count = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
50
|
+
const Count = /* @__PURE__ */ Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
47
51
|
/** One read slice, by the order it was read: what its edges, types and bases parts cover. */
|
|
48
|
-
const IndexSlice = Schema.Struct({
|
|
52
|
+
const IndexSlice = /* @__PURE__ */ Schema.Struct({
|
|
49
53
|
first: Count,
|
|
50
54
|
positions: Count,
|
|
51
55
|
sources: Count,
|
|
@@ -62,7 +66,7 @@ const indexSteps = [
|
|
|
62
66
|
"commit"
|
|
63
67
|
];
|
|
64
68
|
/** One run of a layer's positions: its packs, in position order, then the rows it read. */
|
|
65
|
-
const IndexGroup = Schema.Struct({
|
|
69
|
+
const IndexGroup = /* @__PURE__ */ Schema.Struct({
|
|
66
70
|
packs: Schema.Array(Schema.String),
|
|
67
71
|
rows: Count
|
|
68
72
|
});
|
|
@@ -73,7 +77,7 @@ const IndexGroup = Schema.Struct({
|
|
|
73
77
|
* over the packs and rows listed since, numbered after the layers below, so no position or
|
|
74
78
|
* bitmap below it changes; a merge makes the layers one, their positions as they were.
|
|
75
79
|
*/
|
|
76
|
-
const IndexLayer = Schema.Struct({
|
|
80
|
+
const IndexLayer = /* @__PURE__ */ Schema.Struct({
|
|
77
81
|
build: Schema.String,
|
|
78
82
|
groups: Schema.Array(IndexGroup),
|
|
79
83
|
region: Schema.String,
|
|
@@ -91,7 +95,7 @@ const IndexLayer = Schema.Struct({
|
|
|
91
95
|
* `below` is the row's layers an update builds on, none for a whole build; a merge's are the
|
|
92
96
|
* layers it makes one of, and it covers no pack of its own.
|
|
93
97
|
*/
|
|
94
|
-
const IndexData = Schema.Struct({
|
|
98
|
+
const IndexData = /* @__PURE__ */ Schema.Struct({
|
|
95
99
|
below: Schema.Array(IndexLayer),
|
|
96
100
|
merge: Schema.Boolean,
|
|
97
101
|
build: Schema.String,
|
|
@@ -107,10 +111,23 @@ const IndexData = Schema.Struct({
|
|
|
107
111
|
bitmaps: Count,
|
|
108
112
|
table: Count,
|
|
109
113
|
/** The read step's slices narrowed, as `narrowedAfter` moves them: none, in full slices. */
|
|
110
|
-
narrowed: Schema.optionalKey(Schema.suspend(() => Narrowed))
|
|
114
|
+
narrowed: Schema.optionalKey(Schema.suspend(() => Narrowed)),
|
|
115
|
+
/** The parts of the bitmaps step's walks below that earlier tries closed: none, no part. */
|
|
116
|
+
reaches: Schema.optionalKey(Count),
|
|
117
|
+
/** A whole build's bitmaps written so far, a part a try: none before its first part. */
|
|
118
|
+
bitmapsCut: Schema.optionalKey(Schema.suspend(() => BitmapsCut))
|
|
119
|
+
});
|
|
120
|
+
/**
|
|
121
|
+
* A whole build's bitmaps under way (#1068): the key of the order they're made in, how many of
|
|
122
|
+
* it the parts hold, and each part's count. A try whose order has another key starts again.
|
|
123
|
+
*/
|
|
124
|
+
const BitmapsCut = /* @__PURE__ */ Schema.Struct({
|
|
125
|
+
order: Schema.String,
|
|
126
|
+
done: Count,
|
|
127
|
+
parts: Schema.Array(Count)
|
|
111
128
|
});
|
|
112
129
|
/** A build its row no longer names, kept readable until `at` and prune's grace pass. */
|
|
113
|
-
const ReplacedBuild = Schema.Struct({
|
|
130
|
+
const ReplacedBuild = /* @__PURE__ */ Schema.Struct({
|
|
114
131
|
build: Schema.String,
|
|
115
132
|
at: Count
|
|
116
133
|
});
|
|
@@ -118,19 +135,33 @@ const ReplacedBuild = Schema.Struct({
|
|
|
118
135
|
* A refusal for spent tries: when it was made, how many there have been in a row, and when a push
|
|
119
136
|
* may save the next round of tries.
|
|
120
137
|
*/
|
|
121
|
-
const IndexTries = Schema.Struct({
|
|
138
|
+
const IndexTries = /* @__PURE__ */ Schema.Struct({
|
|
122
139
|
at: Count,
|
|
123
140
|
refusals: Count,
|
|
124
141
|
next: Count
|
|
125
142
|
});
|
|
126
143
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* refusal,
|
|
144
|
+
* The host's bounds a step was refused at for good: the memory `packs()` allots, and the store
|
|
145
|
+
* calls a try may make, where the adapter bounds them. Only a host that changes one mends the
|
|
146
|
+
* refusal, so `status` says `retry` once they differ (Q886).
|
|
130
147
|
*/
|
|
131
|
-
const
|
|
148
|
+
const IndexBounds = /* @__PURE__ */ Schema.Struct({
|
|
149
|
+
memory: Count,
|
|
150
|
+
bucket: Schema.optionalKey(Count),
|
|
151
|
+
subrequests: Schema.optionalKey(Count)
|
|
152
|
+
});
|
|
153
|
+
/**
|
|
154
|
+
* An update refused, on the row it would have added a layer to: its reason, and either the tries
|
|
155
|
+
* spent, as a refused row's, or the host's `bounds` a step of it can't be made within. The layers
|
|
156
|
+
* stand, and reads answer from them; `status` says the refusal, and no push saves the job until
|
|
157
|
+
* its wait has passed or the bounds have changed. The next build's row has none.
|
|
158
|
+
*/
|
|
159
|
+
const IndexRefusal = /* @__PURE__ */ Schema.Struct({
|
|
132
160
|
reason: Schema.String,
|
|
133
|
-
tries: IndexTries
|
|
161
|
+
tries: Schema.optionalKey(IndexTries),
|
|
162
|
+
bounds: Schema.optionalKey(IndexBounds),
|
|
163
|
+
/** The pack a refused slice cuts: the refusal stands while it's listed (Q886). */
|
|
164
|
+
pack: Schema.optionalKey(Schema.String)
|
|
134
165
|
});
|
|
135
166
|
/**
|
|
136
167
|
* The repo's index, `index`/`current`: its layers, oldest first, at most `layersMost`, and the
|
|
@@ -139,7 +170,7 @@ const IndexRefusal = Schema.Struct({
|
|
|
139
170
|
* row that leaves after the build changes nothing. `rounds` is how many rounds of tries the repo
|
|
140
171
|
* had used once it was built, or once its update's were spent, as a refused row's.
|
|
141
172
|
*/
|
|
142
|
-
const BuiltIndex = Schema.Struct({
|
|
173
|
+
const BuiltIndex = /* @__PURE__ */ Schema.Struct({
|
|
143
174
|
rounds: Count,
|
|
144
175
|
layers: Schema.Array(IndexLayer),
|
|
145
176
|
replaced: Schema.Array(ReplacedBuild),
|
|
@@ -160,18 +191,39 @@ const triesWaitOf = (refusals) => Math.min(triesWait * 2 ** Math.max(0, refusals
|
|
|
160
191
|
* one, up to `triesWaitMost` (the coordinator, 22 Nov). `rounds` is how many rounds of tries the
|
|
161
192
|
* repo has used, either refusal's: the next round a push saves is that one, a job key never used.
|
|
162
193
|
*/
|
|
163
|
-
const RefusedIndex = Schema.Struct({
|
|
194
|
+
const RefusedIndex = /* @__PURE__ */ Schema.Struct({
|
|
164
195
|
refused: Schema.Struct({
|
|
165
196
|
commits: Count,
|
|
166
197
|
most: Count,
|
|
167
198
|
reason: Schema.String,
|
|
168
199
|
rounds: Count,
|
|
169
|
-
tries: Schema.optionalKey(IndexTries)
|
|
200
|
+
tries: Schema.optionalKey(IndexTries),
|
|
201
|
+
bounds: Schema.optionalKey(IndexBounds),
|
|
202
|
+
pack: Schema.optionalKey(Schema.String)
|
|
170
203
|
}),
|
|
171
204
|
replaced: Schema.Array(ReplacedBuild)
|
|
172
205
|
});
|
|
173
|
-
|
|
174
|
-
const
|
|
206
|
+
/** A try's bounds, from its parts: the graph's, its budget's memory and its counted calls. */
|
|
207
|
+
const limitsOf = (parts) => ({
|
|
208
|
+
graphMost: parts.graphMost,
|
|
209
|
+
memory: parts.budget.total,
|
|
210
|
+
calls: parts.counted?.most
|
|
211
|
+
});
|
|
212
|
+
/** The host's bounds in `limits`, as a refused row keeps them: an unbounded kind left out. */
|
|
213
|
+
const boundsOf = (limits) => {
|
|
214
|
+
const bounds = { memory: limits.memory };
|
|
215
|
+
const { calls } = limits;
|
|
216
|
+
if (calls !== void 0 && Number.isFinite(calls.bucket)) bounds.bucket = calls.bucket;
|
|
217
|
+
if (calls !== void 0 && Number.isFinite(calls.subrequests)) bounds.subrequests = calls.subrequests;
|
|
218
|
+
return bounds;
|
|
219
|
+
};
|
|
220
|
+
/** Whether `kept`, the bounds a refusal was made at, are the host's in `limits` now. */
|
|
221
|
+
const boundsHold = (kept, limits) => {
|
|
222
|
+
const now = boundsOf(limits);
|
|
223
|
+
return kept.memory === now.memory && kept.bucket === now.bucket && kept.subrequests === now.subrequests;
|
|
224
|
+
};
|
|
225
|
+
const IndexRow = /* @__PURE__ */ Schema.Union([BuiltIndex, RefusedIndex]);
|
|
226
|
+
const decodeRowOption = /* @__PURE__ */ Schema.decodeUnknownOption(IndexRow);
|
|
175
227
|
/** `row`'s layers, when it has some: a row of none is as no row. */
|
|
176
228
|
const builtOf = (row) => row === void 0 || "refused" in row || row.layers.length === 0 ? void 0 : row;
|
|
177
229
|
/** An `index` row's value decoded, at the read's boundary: none for one unreadable. */
|
|
@@ -191,11 +243,11 @@ const sliceBounds = {
|
|
|
191
243
|
/** The memory one try takes: its base cache and blocks' floors, then what they may grow to. */
|
|
192
244
|
const floors = {
|
|
193
245
|
cache: 8388608,
|
|
194
|
-
blocks:
|
|
246
|
+
blocks: blocksHeld(2)
|
|
195
247
|
};
|
|
196
248
|
const most = {
|
|
197
249
|
cache: packIndexerLimits.cacheBytes,
|
|
198
|
-
blocks:
|
|
250
|
+
blocks: blocksHeld(8)
|
|
199
251
|
};
|
|
200
252
|
/**
|
|
201
253
|
* The most the bitmaps step keeps of edges files and of bitmaps made, past what a repo fills. At
|
|
@@ -205,18 +257,10 @@ const edgesMost = 12582912;
|
|
|
205
257
|
const madeMost = 8388608;
|
|
206
258
|
/** The listing's packs in position order: biggest first, ties by ID. */
|
|
207
259
|
const positionOrder = (packs) => [...packs].sort((a, b) => b.bytes - a.bytes || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
208
|
-
/** A put of `bytes` at `key`, done again when a try that died had put it already. */
|
|
209
260
|
/** A put that found its key there: a try that died after its put landed, done again. */
|
|
210
261
|
const alreadyThere = (error) => error.code === "ALREADY_EXISTS";
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
retrying
|
|
214
|
-
})).pipe(Effect.catchIf(alreadyThere, () => Effect.void));
|
|
215
|
-
/** `bytes` as a stream of one chunk, so a put holds no copy of them. */
|
|
216
|
-
const streamOf = (bytes) => new ReadableStream({ start: (controller) => {
|
|
217
|
-
controller.enqueue(bytes);
|
|
218
|
-
controller.close();
|
|
219
|
-
} });
|
|
262
|
+
/** A put of `bytes` at `key`, done again when a try that died had put it already. */
|
|
263
|
+
const putOnce = (bucket, key, bytes) => bucketPut(bucket, key, bytes).pipe(Effect.catchIf(alreadyThere, () => Effect.void));
|
|
220
264
|
/** The most an edges file of `links` takes, each link kept. */
|
|
221
265
|
const edgesMostOf = (links) => edgesBytesOf({
|
|
222
266
|
sources: links.sources,
|
|
@@ -235,6 +279,25 @@ const wordsOf = (bytes) => {
|
|
|
235
279
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
236
280
|
return Uint32Array.from({ length: bytes.byteLength / 4 }, (_, at) => view.getUint32(at * 4));
|
|
237
281
|
};
|
|
282
|
+
/**
|
|
283
|
+
* A reach part at `key`, read and decoded into `allotment`: each chunk charged as it comes, the
|
|
284
|
+
* part beside its walks while both are held, then the walks alone (#1132).
|
|
285
|
+
*/
|
|
286
|
+
const keptReaches = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, words, allotment) {
|
|
287
|
+
const chunks = [];
|
|
288
|
+
yield* bucketDo(Stream.runForEach(bucket.read(key), (chunk) => {
|
|
289
|
+
chunks.push(chunk);
|
|
290
|
+
return allotment.grow(chunk.byteLength);
|
|
291
|
+
}));
|
|
292
|
+
const read = chunks.reduce((sum, chunk) => sum + chunk.byteLength, 0);
|
|
293
|
+
yield* allotment.grow(2 * read + words * 4);
|
|
294
|
+
const bytes = joined(chunks.splice(0));
|
|
295
|
+
const kept = reachesOf(bytes, words);
|
|
296
|
+
allotment.shrink(2 * read + (kept?.open === void 0 ? words * 4 : 0));
|
|
297
|
+
if (kept === void 0) return yield* Effect.fail(lost(`${key}'s cut walk is unreadable`));
|
|
298
|
+
yield* allotment.grow(kept.closed.size * 8);
|
|
299
|
+
return kept;
|
|
300
|
+
});
|
|
238
301
|
const readScratch = (bucket, key) => Effect.flatMap(readWhole(bucket, key), (bytes) => bytes === void 0 ? Effect.fail(lost(`${key} is missing`)) : Effect.succeed(bytes));
|
|
239
302
|
/** The packs every layer of `built` covers. */
|
|
240
303
|
const coveredPacks = (layers) => new Set(layers.flatMap((layer) => layer.groups.flatMap((group) => group.packs)));
|
|
@@ -305,8 +368,8 @@ const spanOf = (data) => ({
|
|
|
305
368
|
* Every layer's positions, `data`'s own last: the layout across them, this layer's own packs'
|
|
306
369
|
* ranges, its first position, and where its rows start, after its packs.
|
|
307
370
|
*/
|
|
308
|
-
const layoutOf =
|
|
309
|
-
const layout = yield* openLayout(bucket, listed, [...data.below, spanOf(data)]);
|
|
371
|
+
const layoutOf = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, listed, data, options) {
|
|
372
|
+
const layout = yield* openLayout(bucket, listed, [...data.below, spanOf(data)], void 0, options);
|
|
310
373
|
const own = layout.ranges.slice(layout.ranges.length - data.packs.length);
|
|
311
374
|
const first = firstOf(data.below);
|
|
312
375
|
return {
|
|
@@ -342,12 +405,15 @@ const withRows = (region, first, ids) => {
|
|
|
342
405
|
/**
|
|
343
406
|
* The most calls a read step makes after its slice, over packs of `counts` objects: its join's,
|
|
344
407
|
* each pack's `.idx` IDs read a chunk of `rangeRanks` at a time, and a chunk's positions when it
|
|
345
|
-
* holds a link, then the slice's three puts
|
|
346
|
-
*
|
|
347
|
-
*
|
|
408
|
+
* holds a link, then the slice's three puts, each charged as `multipart` charges its file at its
|
|
409
|
+
* most: its edges, made in the try's memory of `held` bytes, since a slice ends past the entry
|
|
410
|
+
* whose links reach the bound; then of a slice of `entries`, a type byte an entry and two words of
|
|
411
|
+
* `.bases` an entry. No store call: the join reads the packs' files alone, and the job's own
|
|
412
|
+
* reads and settle aren't `packs()`'s to count. A slice's own calls leave this many of the try's
|
|
413
|
+
* bounds for them (#681).
|
|
348
414
|
*/
|
|
349
|
-
const indexReadCallsAfter = (counts) => ({
|
|
350
|
-
bucket: counts.reduce((sum, count) => sum + 2 * Math.ceil(count / rangeRanks), 0) +
|
|
415
|
+
const indexReadCallsAfter = (counts, multipart, { entries, held }) => ({
|
|
416
|
+
bucket: counts.reduce((sum, count) => sum + 2 * Math.ceil(count / rangeRanks), 0) + sizedPutCalls(multipart, held) + sizedPutCalls(multipart, entries) + sizedPutCalls(multipart, entries * 8),
|
|
351
417
|
store: 0
|
|
352
418
|
});
|
|
353
419
|
/**
|
|
@@ -375,10 +441,121 @@ const reservePast = (kind, needs, most) => {
|
|
|
375
441
|
const reserveShort = (pack, position, most) => {
|
|
376
442
|
const message = `Pack ${pack}'s slice at ${position} left its join and writes short of ${most} bucket calls: indexReadCallsAfter is too small`;
|
|
377
443
|
return gitError("RESOURCE_EXHAUSTED", message, {
|
|
378
|
-
cause: new SliceRefused(message),
|
|
444
|
+
cause: new SliceRefused(message, pack),
|
|
379
445
|
context: { reason: "too-many-store-calls" }
|
|
380
446
|
});
|
|
381
447
|
};
|
|
448
|
+
/**
|
|
449
|
+
* The most calls the bitmaps step makes once its walks below have spent their bound: the put of
|
|
450
|
+
* the part that keeps the walks the try closed, or a whole build's bitmaps part, charged as
|
|
451
|
+
* `multipart` charges a file of the try's memory, `held` bytes, since each is made in it whole.
|
|
452
|
+
* The step's other calls, and the walks', leave it this many of the try's bounds (#1068).
|
|
453
|
+
*/
|
|
454
|
+
const indexBitmapsCallsAfter = (multipart, held) => ({
|
|
455
|
+
bucket: sizedPutCalls(multipart, held),
|
|
456
|
+
store: 0
|
|
457
|
+
});
|
|
458
|
+
/**
|
|
459
|
+
* The refusal of an update whose bitmaps step closed no walk below its layer, and read no object
|
|
460
|
+
* past where its reach part left the walk, within its try's `most` calls of `kind`: the next try
|
|
461
|
+
* would spend them at the same place, so its refusal stands until the host's bounds change (#1068,
|
|
462
|
+
* Q854, Q886).
|
|
463
|
+
*/
|
|
464
|
+
/** A whole build's bitmap that no try's calls can make, by the commit or tip it's for. */
|
|
465
|
+
const bitmapUnwritten = (kind, most, position) => {
|
|
466
|
+
const what = kind === "bucket" ? "bucket calls" : "subrequests";
|
|
467
|
+
const message = `${position === void 0 ? "The index's bitmaps" : `The index's bitmap for position ${position}`} can't be made within ${most} ${what}.`;
|
|
468
|
+
return refusedRow(message, raiseCalls(kind), "too-many-store-calls");
|
|
469
|
+
};
|
|
470
|
+
/** A whole build whose bitmaps' parts can't be joined within one try's calls. */
|
|
471
|
+
const bitmapsUnjoined = (needs, most) => {
|
|
472
|
+
const message = `The index's bitmaps need ${needs} bucket calls to join their parts, past the ${most} a try may make.`;
|
|
473
|
+
return refusedRow(message, raiseCalls("bucket"), "too-many-store-calls");
|
|
474
|
+
};
|
|
475
|
+
const reachUnsettled = (kind, most) => {
|
|
476
|
+
const message = `The update's bitmaps can't close one more walk below its layer within ${most} ${kind === "bucket" ? "bucket calls" : "subrequests"}.`;
|
|
477
|
+
return refusedRow(message, raiseCalls(kind), "too-many-store-calls");
|
|
478
|
+
};
|
|
479
|
+
/**
|
|
480
|
+
* A reach part, as big-endian words: the count of walks closed, then each one's position, its
|
|
481
|
+
* EWAH's length and words; then 1 and the cut walk's position, its reads, its set positions' EWAH
|
|
482
|
+
* length and words, its queue's length and how many of the queue's first are commits, or 0 for
|
|
483
|
+
* none; then the queue's IDs, 20 bytes each.
|
|
484
|
+
*/
|
|
485
|
+
const reachesBytes = ({ closed, open }) => {
|
|
486
|
+
const set = open === void 0 ? void 0 : ewahOf(open.walk.bits);
|
|
487
|
+
let length = 2 + (set === void 0 ? 0 : 5 + set.length);
|
|
488
|
+
for (const ewah of closed.values()) length += 2 + ewah.length;
|
|
489
|
+
const bytes = new Uint8Array(length * 4 + (open === void 0 ? 0 : open.walk.queue.length * 20));
|
|
490
|
+
const view = new DataView(bytes.buffer);
|
|
491
|
+
let at = 0;
|
|
492
|
+
const put = (words) => {
|
|
493
|
+
for (let word = 0; word < words.length; word += 1) view.setUint32(at + word * 4, words[word] ?? 0);
|
|
494
|
+
at += words.length * 4;
|
|
495
|
+
};
|
|
496
|
+
put([closed.size]);
|
|
497
|
+
for (const [position, ewah] of closed) {
|
|
498
|
+
put([position, ewah.length]);
|
|
499
|
+
put(ewah);
|
|
500
|
+
}
|
|
501
|
+
if (open === void 0 || set === void 0) return bytes;
|
|
502
|
+
put([
|
|
503
|
+
1,
|
|
504
|
+
open.position,
|
|
505
|
+
open.walk.reads,
|
|
506
|
+
set.length
|
|
507
|
+
]);
|
|
508
|
+
put(set);
|
|
509
|
+
put([open.walk.queue.length, open.walk.commits]);
|
|
510
|
+
for (const [index, id] of open.walk.queue.entries()) bytes.set(id, at + index * 20);
|
|
511
|
+
return bytes;
|
|
512
|
+
};
|
|
513
|
+
/** The most `reachesBytes` holds of `reaches`: its part, and the cut walk's EWAH beside it. */
|
|
514
|
+
const reachesMostBytes = ({ closed, open }) => {
|
|
515
|
+
const set = open === void 0 ? 0 : ewahMostWords(open.walk.bits.length);
|
|
516
|
+
let length = 2 + (open === void 0 ? 0 : 5 + 2 * set);
|
|
517
|
+
for (const ewah of closed.values()) length += 2 + ewah.length;
|
|
518
|
+
return length * 4 + (open === void 0 ? 0 : open.walk.queue.length * 20);
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* What a reach part keeps, each walk's set positions over `positions`'s words, each read straight
|
|
522
|
+
* from the part's words: no copy of them whole beside it (#1132).
|
|
523
|
+
*/
|
|
524
|
+
const reachesOf = (bytes, words) => {
|
|
525
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
526
|
+
const length = Math.floor(bytes.byteLength / 4);
|
|
527
|
+
const word = (at) => at < length ? view.getUint32(at * 4) : 0;
|
|
528
|
+
const wordsAt = (at, count) => Uint32Array.from({ length: Math.max(0, Math.min(count, length - at)) }, (_, from) => view.getUint32((at + from) * 4));
|
|
529
|
+
const closed = /* @__PURE__ */ new Map();
|
|
530
|
+
let at = 1;
|
|
531
|
+
for (let walk = 0; walk < word(0); walk += 1) {
|
|
532
|
+
const count = word(at + 1);
|
|
533
|
+
closed.set(word(at), wordsAt(at + 2, count));
|
|
534
|
+
at += 2 + count;
|
|
535
|
+
}
|
|
536
|
+
if (word(at) !== 1) return { closed };
|
|
537
|
+
const [position, reads, count] = [
|
|
538
|
+
word(at + 1),
|
|
539
|
+
word(at + 2),
|
|
540
|
+
word(at + 3)
|
|
541
|
+
];
|
|
542
|
+
const bits = bitmapOf(wordsAt(at + 4, count), words);
|
|
543
|
+
const [queued, commits] = [word(at + 4 + count), word(at + 5 + count)];
|
|
544
|
+
const idsAt = (at + 6 + count) * 4;
|
|
545
|
+
if (bits === void 0 || commits > queued || idsAt + queued * 20 !== bytes.byteLength) return void 0;
|
|
546
|
+
return {
|
|
547
|
+
closed,
|
|
548
|
+
open: {
|
|
549
|
+
position,
|
|
550
|
+
walk: {
|
|
551
|
+
bits,
|
|
552
|
+
queue: Array.from({ length: queued }, (_, index) => bytes.slice(idsAt + index * 20, idsAt + (index + 1) * 20)),
|
|
553
|
+
commits,
|
|
554
|
+
reads
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
};
|
|
382
559
|
/** A try's join of its links, its workspace grown into `allotment` while it runs. */
|
|
383
560
|
const joinCharged = (links, ranges, region, allotment) => {
|
|
384
561
|
const bytes = joinBytes(links.size);
|
|
@@ -389,7 +566,7 @@ const joinCharged = (links, ranges, region, allotment) => {
|
|
|
389
566
|
* their IDs, the SHA-1 of those, and, for the region step, their types, links and commits.
|
|
390
567
|
* `undefined` once the repo moved under the read.
|
|
391
568
|
*/
|
|
392
|
-
const readRegion = (parts, listed, each, skip)
|
|
569
|
+
const readRegion = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, each, skip) {
|
|
393
570
|
let ids = /* @__PURE__ */ new Uint8Array(1280);
|
|
394
571
|
let rows = 0;
|
|
395
572
|
if (!(yield* eachPageAt(parts.store, listed.repo, listed.version, (page) => Effect.gen(function* () {
|
|
@@ -419,7 +596,7 @@ const readRegion = (parts, listed, each, skip) => Effect.gen(function* () {
|
|
|
419
596
|
* charged to `allotment`: its links as they grow, and each row's ID, type and commit entry and
|
|
420
597
|
* the row's own bytes while it's parsed.
|
|
421
598
|
*/
|
|
422
|
-
const regionStep = (parts, listed, data, allotment)
|
|
599
|
+
const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
|
|
423
600
|
const { bucket } = parts;
|
|
424
601
|
const files = indexFiles(listed.repo, data.build);
|
|
425
602
|
const { layout, first, packed } = yield* layoutOf(bucket, listed, data);
|
|
@@ -427,7 +604,7 @@ const regionStep = (parts, listed, data, allotment) => Effect.gen(function* () {
|
|
|
427
604
|
const links = new SliceLinks((bytes) => allotment.tryGrow(bytes));
|
|
428
605
|
const types = [];
|
|
429
606
|
const commits = [];
|
|
430
|
-
const parsed =
|
|
607
|
+
const parsed = Effect.fnUntraced(function* (object, at) {
|
|
431
608
|
types.push(typeCodes[object.type]);
|
|
432
609
|
if (object.type === "blob") return;
|
|
433
610
|
links.begin(packed + at, object.type);
|
|
@@ -462,10 +639,10 @@ const regionStep = (parts, listed, data, allotment) => Effect.gen(function* () {
|
|
|
462
639
|
const targets = yield* joinCharged(links, layout.ranges, region, allotment);
|
|
463
640
|
const slice = data.slices.length;
|
|
464
641
|
yield* allotment.grow(edgesMostOf(links) + read.rows + graphFileBytes(commits));
|
|
465
|
-
const edges = edgesFileOf(files.edges(slice), packed, read.rows, links, targets);
|
|
642
|
+
const edges = edgesFileOf(files.edges(slice, read.rows), packed, read.rows, links, targets);
|
|
466
643
|
yield* putOnce(bucket, edges.slice.key, edges.bytes);
|
|
467
|
-
yield* putOnce(bucket, files.typesPart(slice), Uint8Array.from(types));
|
|
468
|
-
yield* putOnce(bucket, files.basesPart(slice), /* @__PURE__ */ new Uint8Array(0));
|
|
644
|
+
yield* putOnce(bucket, files.typesPart(slice, read.rows), Uint8Array.from(types));
|
|
645
|
+
yield* putOnce(bucket, files.basesPart(slice, read.rows), /* @__PURE__ */ new Uint8Array(0));
|
|
469
646
|
yield* putOnce(bucket, files.region, read.ids);
|
|
470
647
|
yield* putOnce(bucket, files.regionGraph, writeCommitGraph(commits));
|
|
471
648
|
return {
|
|
@@ -480,7 +657,7 @@ const regionStep = (parts, listed, data, allotment) => Effect.gen(function* () {
|
|
|
480
657
|
* The rows the layers below hold, which an update's region leaves at their positions there: the
|
|
481
658
|
* repo's rows at `listed`'s version, each found among the layers, and kept by ID.
|
|
482
659
|
*/
|
|
483
|
-
const heldBelow = (parts, listed, layout, first)
|
|
660
|
+
const heldBelow = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, layout, first) {
|
|
484
661
|
const read = yield* readRegion(parts, listed);
|
|
485
662
|
const held = /* @__PURE__ */ new Set();
|
|
486
663
|
if (read === void 0 || read.rows === 0) return held;
|
|
@@ -496,7 +673,7 @@ const regionRowBytes = 256;
|
|
|
496
673
|
/** Each of `layers`' graphs, opened at its first graph number. */
|
|
497
674
|
const belowGraphs = (bucket, repo, layers) => Effect.forEach(layers, (layer) => openIndexGraph(bucket, indexFiles(repo, layer.build).graph, layer.graphFirst));
|
|
498
675
|
/** The graph step: every pack's `.graph` and the region's, merged. */
|
|
499
|
-
const graphStep = (parts, listed, data, allotment)
|
|
676
|
+
const graphStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
|
|
500
677
|
const files = indexFiles(listed.repo, data.build);
|
|
501
678
|
const graphs = data.packs.map((id) => isPackId(id) ? packFiles(id).graph : id);
|
|
502
679
|
if (data.rows > 0) graphs.push(files.regionGraph);
|
|
@@ -528,14 +705,14 @@ const graphStep = (parts, listed, data, allotment) => Effect.gen(function* () {
|
|
|
528
705
|
* holds to the last, `headReads` at once. A slice holds at most `sliceEntriesMost` positions, so each
|
|
529
706
|
* read is inside the room `headsBytes` charges for the header reads it stands in for.
|
|
530
707
|
*/
|
|
531
|
-
const storedTypesOf = (bucket, files, slices, base) =>
|
|
708
|
+
const storedTypesOf = (bucket, files, slices, base) => Effect.fnUntraced(function* (positions) {
|
|
532
709
|
const codes = /* @__PURE__ */ new Map();
|
|
533
710
|
const reads = slices.flatMap((slice, number) => {
|
|
534
711
|
const held = positions.filter((position) => base + position >= slice.first && base + position < slice.first + slice.positions);
|
|
535
712
|
if (held.length === 0) return [];
|
|
536
713
|
const from = Math.min(...held) + base - slice.first;
|
|
537
714
|
const length = Math.max(...held) + base - slice.first - from + 1;
|
|
538
|
-
return [Effect.map(readExactly(bucket, files.typesPart(number), from, length), (types) => {
|
|
715
|
+
return [Effect.map(readExactly(bucket, files.typesPart(number, slice.positions), from, length), (types) => {
|
|
539
716
|
for (const position of held) {
|
|
540
717
|
const code = types[position + base - slice.first - from];
|
|
541
718
|
if (code !== void 0) codes.set(position, code);
|
|
@@ -554,10 +731,15 @@ const storedTypesOf = (bucket, files, slices, base) => (positions) => Effect.gen
|
|
|
554
731
|
* the try's bound less `indexReadCallsAfter`, then its join and puts over the whole bound; a slice
|
|
555
732
|
* that settles nothing is read again alone, and one alone that can't is refused (#681).
|
|
556
733
|
*/
|
|
557
|
-
const readStep = (parts, listed, data, allotment)
|
|
734
|
+
const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
|
|
558
735
|
const { counted } = parts;
|
|
559
736
|
const counts = data.packs.map((id) => listed.packs.find((each) => each.id === id)?.objects ?? 0);
|
|
560
|
-
const
|
|
737
|
+
const bounds = parts.bounds ?? sliceBounds;
|
|
738
|
+
const entries = data.narrowed?.entries ?? bounds.entries ?? 65536;
|
|
739
|
+
const reserve = indexReadCallsAfter(counts, parts.bucket.multipart, {
|
|
740
|
+
entries,
|
|
741
|
+
held: allotment.bytes + allotment.growable
|
|
742
|
+
});
|
|
561
743
|
const subrequestsAfter = reserve.bucket + reserve.store;
|
|
562
744
|
if (counted !== void 0 && reserve.bucket >= counted.most.bucket) return yield* Effect.fail(reservePast("bucket", reserve.bucket, counted.most.bucket));
|
|
563
745
|
if (counted !== void 0 && subrequestsAfter >= counted.most.subrequests) return yield* Effect.fail(reservePast("subrequests", subrequestsAfter, counted.most.subrequests));
|
|
@@ -567,11 +749,12 @@ const readStep = (parts, listed, data, allotment) => Effect.gen(function* () {
|
|
|
567
749
|
}).bucket;
|
|
568
750
|
let through = lower;
|
|
569
751
|
const bucket = {
|
|
570
|
-
|
|
752
|
+
...lower,
|
|
571
753
|
put: (key, body, options) => through.put(key, body, options),
|
|
572
|
-
read: (key, range
|
|
573
|
-
|
|
574
|
-
|
|
754
|
+
read: (key, range) => through.read(key, range),
|
|
755
|
+
remove: (key) => through.remove(key),
|
|
756
|
+
removeMany: (keys, options) => through.removeMany(keys, options),
|
|
757
|
+
list: (prefix, page) => through.list(prefix, page)
|
|
575
758
|
};
|
|
576
759
|
const whole = counted?.most.bucket ?? Number.POSITIVE_INFINITY;
|
|
577
760
|
const files = indexFiles(listed.repo, data.build);
|
|
@@ -580,8 +763,6 @@ const readStep = (parts, listed, data, allotment) => Effect.gen(function* () {
|
|
|
580
763
|
position: data.position
|
|
581
764
|
};
|
|
582
765
|
const opened = yield* Effect.result(cutAtSpent(layoutOf(bucket, listed, data)));
|
|
583
|
-
const bounds = parts.bounds ?? sliceBounds;
|
|
584
|
-
const entries = data.narrowed?.entries ?? bounds.entries ?? 65536;
|
|
585
766
|
if (Result.isFailure(opened)) {
|
|
586
767
|
const spent = spentOf(opened.failure);
|
|
587
768
|
if (spent === void 0) return yield* Effect.fail(opened.failure);
|
|
@@ -604,10 +785,10 @@ const readStep = (parts, listed, data, allotment) => Effect.gen(function* () {
|
|
|
604
785
|
...bounds,
|
|
605
786
|
entries
|
|
606
787
|
},
|
|
607
|
-
blocks: new PackBlocks(bucket, allotment.room(floors.blocks, most.blocks)),
|
|
788
|
+
blocks: new PackBlocks(bucket, allotment.room(floors.blocks, most.blocks, true)),
|
|
608
789
|
cache: new IndexerCache(allotment.room(floors.cache, most.cache)),
|
|
609
790
|
links,
|
|
610
|
-
allot: outsideOn(allotment),
|
|
791
|
+
allot: outsideOn((bytes) => allotment.grow(bytes)),
|
|
611
792
|
storedTypes: storedTypesOf(bucket, files, data.slices, pack.base),
|
|
612
793
|
calls: counted === void 0 ? void 0 : {
|
|
613
794
|
made: () => counted.made().bucket,
|
|
@@ -624,10 +805,11 @@ const readStep = (parts, listed, data, allotment) => Effect.gen(function* () {
|
|
|
624
805
|
const edges = yield* Effect.gen(function* () {
|
|
625
806
|
const targets = yield* joinCharged(links, ranges, region, allotment);
|
|
626
807
|
yield* allotment.grow(edgesMostOf(links) + slice.bases.length * 4);
|
|
627
|
-
const
|
|
808
|
+
const positions = slice.types.length;
|
|
809
|
+
const made = edgesFileOf(files.edges(number, positions), first, positions, links, targets);
|
|
628
810
|
yield* putOnce(bucket, made.slice.key, made.bytes);
|
|
629
|
-
yield* putOnce(bucket, files.typesPart(number), slice.types);
|
|
630
|
-
yield* putOnce(bucket, files.basesPart(number), wordsBytes(slice.bases));
|
|
811
|
+
yield* putOnce(bucket, files.typesPart(number, positions), slice.types);
|
|
812
|
+
yield* putOnce(bucket, files.basesPart(number, positions), wordsBytes(slice.bases));
|
|
631
813
|
return made;
|
|
632
814
|
}).pipe(cutAtSpent, Effect.catchIf((error) => spentOf(error) !== void 0, () => Effect.fail(reserveShort(data.packs[data.pack] ?? "", at.position, whole))));
|
|
633
815
|
const slices = [...data.slices, {
|
|
@@ -663,7 +845,7 @@ const readStep = (parts, listed, data, allotment) => Effect.gen(function* () {
|
|
|
663
845
|
* twice log2 of the span in tries, and the entries past its span are read in full slices (the
|
|
664
846
|
* coordinator, 22 Nov). Only a slice of one that settles nothing is refused (#681).
|
|
665
847
|
*/
|
|
666
|
-
const Narrowed = Schema.Struct({
|
|
848
|
+
const Narrowed = /* @__PURE__ */ Schema.Struct({
|
|
667
849
|
entries: Count,
|
|
668
850
|
to: Count
|
|
669
851
|
});
|
|
@@ -695,6 +877,26 @@ const byPosition = (data) => [...data.slices.entries()].sort(([, a], [, b]) => a
|
|
|
695
877
|
* ask one question (#814).
|
|
696
878
|
*/
|
|
697
879
|
const wantsBitmap = (position, bitmaps) => position !== 4294967295 && !bitmaps.has(position);
|
|
880
|
+
/** What an update holds for each of its entries: its number, position and ID. */
|
|
881
|
+
const entriesHeld = (count) => count * 32;
|
|
882
|
+
/**
|
|
883
|
+
* The positions of the commits below a layer that its own commits, `rows` from graph number
|
|
884
|
+
* `first`, name as a first or second parent: an update walks below from these before any other
|
|
885
|
+
* position, since what one reaches needs no walk of its own. Their order among themselves
|
|
886
|
+
* changes no read, as a later walk stops at an earlier one's closed bitmap. An octopus' later
|
|
887
|
+
* parents aren't among them, as one missed costs only its walk.
|
|
888
|
+
*/
|
|
889
|
+
const entriesOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows, first, graph, layout, allotment) {
|
|
890
|
+
const numbers = /* @__PURE__ */ new Set();
|
|
891
|
+
for (let at = 0; at < rows.length; at += 3) for (const parent of [rows[at] ?? 2147483647, rows[at + 1] ?? 2147483647]) if ((parent & 2147483648) === 0 && parent < first) numbers.add(parent);
|
|
892
|
+
if (numbers.size === 0) return [];
|
|
893
|
+
yield* allotment.grow(entriesHeld(numbers.size));
|
|
894
|
+
const below = [...numbers];
|
|
895
|
+
const positions = yield* layout.positionsOf(yield* graph.idsAt(below), below.length);
|
|
896
|
+
const found = [];
|
|
897
|
+
for (const position of positions) if (position !== 4294967295) found.push(position);
|
|
898
|
+
return found;
|
|
899
|
+
});
|
|
698
900
|
const chooseCommits = (rows, tips, first = 0) => {
|
|
699
901
|
const commits = rows.length / 3;
|
|
700
902
|
const walked = new Uint8Array(commits);
|
|
@@ -716,18 +918,107 @@ const chooseCommits = (rows, tips, first = 0) => {
|
|
|
716
918
|
* own commits down their first parents. Its walk ORs a stored bitmap it meets below its layer,
|
|
717
919
|
* and closes any other position there by reading its objects. `undefined` when one won't close
|
|
718
920
|
* within `walkMost`: the update gives way to a whole build.
|
|
921
|
+
*
|
|
922
|
+
* With `parts.counted`, all it reads and writes is through the try's bound less
|
|
923
|
+
* `indexBitmapsCallsAfter`. Where that runs out, the walks below the try closed go in a reach part
|
|
924
|
+
* through the whole bound, each with every earlier try's, and the next try ORs them with no walk.
|
|
925
|
+
* The walk it was in goes there too, cut where the bound ran out, and the next try goes on from
|
|
926
|
+
* it. A try that closed no walk and read no object further refuses, as the next would spend its
|
|
927
|
+
* calls at the same place (#1068).
|
|
928
|
+
* A try that put a part ends as `more`, which counts none of the job's `indexTries` failures, so
|
|
929
|
+
* an update whose walks below take more than that many tries still lands.
|
|
930
|
+
*
|
|
931
|
+
* Each part is the build's scratch, under its ID: once its row lands, prune deletes the build's
|
|
932
|
+
* scratch and keeps its stored files; a build no row names, as when its job is refused, loses all
|
|
933
|
+
* its files to prune after its grace.
|
|
719
934
|
*/
|
|
720
|
-
const bitmapsStep = (parts, listed, data, input, allotment)
|
|
721
|
-
const {
|
|
935
|
+
const bitmapsStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, input, allotment) {
|
|
936
|
+
const { counted } = parts;
|
|
937
|
+
const reserve = indexBitmapsCallsAfter(parts.bucket.multipart, allotment.bytes + allotment.growable);
|
|
938
|
+
const subrequestsAfter = reserve.bucket + reserve.store;
|
|
939
|
+
if (counted !== void 0 && reserve.bucket >= counted.most.bucket) return yield* Effect.fail(reservePast("bucket", reserve.bucket, counted.most.bucket));
|
|
940
|
+
if (counted !== void 0 && subrequestsAfter >= counted.most.subrequests) return yield* Effect.fail(reservePast("subrequests", subrequestsAfter, counted.most.subrequests));
|
|
941
|
+
const lower = counted === void 0 ? void 0 : counted.within({
|
|
942
|
+
bucket: counted.most.bucket - reserve.bucket,
|
|
943
|
+
subrequests: counted.most.subrequests - subrequestsAfter
|
|
944
|
+
});
|
|
945
|
+
const walks = {
|
|
946
|
+
closed: /* @__PURE__ */ new Map(),
|
|
947
|
+
fresh: 0
|
|
948
|
+
};
|
|
949
|
+
const written = yield* Effect.result(cutAtSpent(bitmapsWritten(parts, lower, listed, data, input, allotment, walks)));
|
|
950
|
+
if (Result.isSuccess(written)) return written.success;
|
|
951
|
+
const spent = spentOf(written.failure);
|
|
952
|
+
if (spent === void 0) return yield* Effect.fail(written.failure);
|
|
953
|
+
const most = counted?.most[spent.bound] ?? spent.most;
|
|
954
|
+
if (data.below.length === 0) return yield* Effect.fail(bitmapUnwritten(spent.bound, most));
|
|
955
|
+
if (walks.fresh === 0 && !readFurther(walks)) return yield* Effect.fail(reachUnsettled(spent.bound, most));
|
|
956
|
+
const part = data.reaches ?? 0;
|
|
957
|
+
const reaches = { closed: walks.closed };
|
|
958
|
+
if (walks.cut !== void 0) reaches.open = walks.cut;
|
|
959
|
+
const partBytes = reachesMostBytes(reaches);
|
|
960
|
+
yield* allotment.grow(partBytes);
|
|
961
|
+
yield* putOnce(parts.bucket, indexFiles(listed.repo, data.build).reaches(part), reachesBytes(reaches)).pipe(Effect.ensuring(Effect.sync(() => allotment.shrink(partBytes))));
|
|
962
|
+
yield* Effect.logInfo(`git.index's bitmaps step for repo ${listed.repo} spent its try's calls: ${walks.fresh} walks below closed, ${walks.cut === void 0 ? "none cut" : `one cut at ${walks.cut.walk.reads} reads`}, the next try goes on`);
|
|
963
|
+
return {
|
|
964
|
+
...data,
|
|
965
|
+
reaches: part + 1
|
|
966
|
+
};
|
|
967
|
+
});
|
|
968
|
+
/**
|
|
969
|
+
* Whether a try's cut walk went past where its reach part carried it in: an object read further,
|
|
970
|
+
* or a position set that the carried walk hadn't, as a stored bitmap ORed in a batch the bound
|
|
971
|
+
* cut. A try that did neither would spend its calls at the same place again.
|
|
972
|
+
*/
|
|
973
|
+
const readFurther = ({ carried, cut }) => {
|
|
974
|
+
if (cut === void 0) return false;
|
|
975
|
+
const from = carried?.position === cut.position ? carried.walk : void 0;
|
|
976
|
+
if (cut.walk.reads > (from?.reads ?? 0)) return true;
|
|
977
|
+
return cut.walk.bits.some((word, at) => (word & ~(from?.bits[at] ?? 0)) !== 0);
|
|
978
|
+
};
|
|
979
|
+
/**
|
|
980
|
+
* The most a bitmaps step keeps of its layout's `.idx` and `.pos` ranges for its walks' joins:
|
|
981
|
+
* s1m's whole join, 23,994,800 B at its 1M positions, fits (M5). Past it, the step keeps what it
|
|
982
|
+
* read first and lets the rest through.
|
|
983
|
+
*/
|
|
984
|
+
const bitmapsJoinMost = 25165824;
|
|
985
|
+
/**
|
|
986
|
+
* What a bitmaps step holds for the join ranges it keeps, over packs of `objects`: each pack's
|
|
987
|
+
* `.idx` and `.pos`, 20 B and 4 B a rank, and an entry for each of a chunk's two ranges, at most
|
|
988
|
+
* `bitmapsJoinMost`. It's what a join can read, from the counts alone, never what a try did.
|
|
989
|
+
*/
|
|
990
|
+
const bitmapsJoinHeld = (objects) => Math.min(bitmapsJoinMost, objects.reduce((sum, count) => sum + count * 24 + Math.ceil(count / rangeRanks) * 2 * 320, 0));
|
|
991
|
+
/**
|
|
992
|
+
* The step's kept join ranges over `bucket`, charged at `bitmapsJoinHeld` before any read and let
|
|
993
|
+
* go as its scope ends, however the step ends: each walk below's batch joins every covered pack's
|
|
994
|
+
* ranges, which are read once a step this way, not once a batch.
|
|
995
|
+
*/
|
|
996
|
+
const keptJoins = (bucket, listed, data, allotment) => {
|
|
997
|
+
const covered = new Set([...data.below, spanOf(data)].flatMap((layer) => layer.groups.flatMap((group) => group.packs)));
|
|
998
|
+
const held = bitmapsJoinHeld(listed.packs.filter(({ id }) => covered.has(id)).map((pack) => pack.objects));
|
|
999
|
+
return Effect.acquireRelease(Effect.map(allotment.grow(held), () => rangeCached(bucket, held, { evict: false })), (ranges) => Effect.sync(() => {
|
|
1000
|
+
ranges.clear();
|
|
1001
|
+
allotment.shrink(held);
|
|
1002
|
+
}));
|
|
1003
|
+
};
|
|
1004
|
+
/** `bitmapsStep`'s reads and writes, through `lower` when given, each walk below in `walks`. */
|
|
1005
|
+
const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower, listed, data, input, allotment, walks) {
|
|
1006
|
+
const bucket = lower?.bucket ?? parts.bucket;
|
|
722
1007
|
const files = indexFiles(listed.repo, data.build);
|
|
723
|
-
const
|
|
1008
|
+
const joins = data.below.length === 0 ? void 0 : yield* keptJoins(bucket, listed, data, allotment);
|
|
1009
|
+
const { layout, first } = joins === void 0 ? yield* layoutOf(bucket, listed, data) : yield* layoutOf(joins.bucket, listed, data, { cached: true });
|
|
724
1010
|
const { positions } = layout;
|
|
725
1011
|
const graphFirst = graphFirstOf(data.below);
|
|
726
1012
|
const own = yield* openIndexGraph(bucket, files.graph, graphFirst);
|
|
727
1013
|
const graph = openGraphLayers([...yield* belowGraphs(bucket, listed.repo, data.below), own]);
|
|
728
1014
|
yield* allotment.grow(own.commits * 12);
|
|
729
1015
|
const rows = yield* own.rows;
|
|
730
|
-
|
|
1016
|
+
let entries;
|
|
1017
|
+
const entriesBelow = Effect.gen(function* () {
|
|
1018
|
+
entries ??= yield* entriesOf(rows, graphFirst, graph, layout, allotment);
|
|
1019
|
+
return entries;
|
|
1020
|
+
});
|
|
1021
|
+
const stored = yield* openLayerBitmaps(bucket, listed.repo, data.below, allotment);
|
|
731
1022
|
const tips = [...new Set(input.tips)];
|
|
732
1023
|
const tipIds = idsOf(tips);
|
|
733
1024
|
const tipPositions = yield* layout.positionsOf(tipIds, tips.length);
|
|
@@ -764,22 +1055,61 @@ const bitmapsStep = (parts, listed, data, input, allotment) => Effect.gen(functi
|
|
|
764
1055
|
number: noNumber,
|
|
765
1056
|
generation: latest + 1
|
|
766
1057
|
});
|
|
1058
|
+
const words = bitmapWords(positions);
|
|
1059
|
+
const part = data.reaches ?? 0;
|
|
1060
|
+
const { closed } = walks;
|
|
1061
|
+
if (data.below.length > 0 && part > 0) {
|
|
1062
|
+
const kept = yield* keptReaches(bucket, files.reaches(part - 1), words, allotment);
|
|
1063
|
+
for (const [position, ewah] of kept.closed) closed.set(position, ewah);
|
|
1064
|
+
if (kept.open !== void 0) walks.carried = kept.open;
|
|
1065
|
+
}
|
|
1066
|
+
const buffer = data.below.length === 0 ? 0 : words;
|
|
1067
|
+
const walking = new Uint32Array(buffer);
|
|
1068
|
+
const decoded = new Uint32Array(buffer);
|
|
1069
|
+
if (buffer > 0) yield* allotment.grow(buffer * 8);
|
|
1070
|
+
const readyAt = Effect.fnUntraced(function* (position) {
|
|
1071
|
+
const ewah = closed.get(position);
|
|
1072
|
+
if (ewah === void 0) return yield* stored.bitmapAt(position);
|
|
1073
|
+
if (!orEwah(ewah, decoded.fill(0))) return yield* Effect.fail(lost(`${files.reaches(part - 1)}'s walk from ${position} is unreadable`));
|
|
1074
|
+
return decoded;
|
|
1075
|
+
});
|
|
767
1076
|
const reach = parts.objects === void 0 ? void 0 : {
|
|
768
1077
|
layout,
|
|
769
|
-
bitmaps:
|
|
770
|
-
|
|
771
|
-
|
|
1078
|
+
bitmaps: {
|
|
1079
|
+
...stored,
|
|
1080
|
+
bitmapAt: readyAt
|
|
1081
|
+
},
|
|
1082
|
+
read: yield* parts.objects(listed, allotment, ...lower === void 0 ? [] : [lower]),
|
|
1083
|
+
allotment,
|
|
1084
|
+
bits: walking
|
|
772
1085
|
};
|
|
773
1086
|
const below = data.below.length === 0 ? void 0 : {
|
|
774
1087
|
first,
|
|
775
|
-
|
|
776
|
-
|
|
1088
|
+
entries: entriesBelow,
|
|
1089
|
+
ready: readyAt,
|
|
1090
|
+
reach: Effect.fnUntraced(function* (position) {
|
|
1091
|
+
const bitmap = yield* readyAt(position);
|
|
777
1092
|
if (bitmap !== void 0 || reach === void 0) return bitmap;
|
|
778
|
-
|
|
1093
|
+
const carry = { cut: (walk) => {
|
|
1094
|
+
walks.cut = {
|
|
1095
|
+
position,
|
|
1096
|
+
walk
|
|
1097
|
+
};
|
|
1098
|
+
} };
|
|
1099
|
+
if (walks.carried?.position === position) carry.from = walks.carried.walk;
|
|
1100
|
+
const walked = yield* reachOf(reach, [{ position }], carry);
|
|
1101
|
+
if (walked === void 0) return void 0;
|
|
1102
|
+
const most = ewahMostWords(walked.length) * 4;
|
|
1103
|
+
yield* allotment.grow(8 + most);
|
|
1104
|
+
const ewah = ewahOf(walked);
|
|
1105
|
+
allotment.shrink(most - ewah.byteLength);
|
|
1106
|
+
closed.set(position, ewah);
|
|
1107
|
+
walks.fresh += 1;
|
|
1108
|
+
return walked;
|
|
779
1109
|
})
|
|
780
1110
|
};
|
|
781
1111
|
const slices = byPosition(data).map(([number, slice]) => ({
|
|
782
|
-
key: files.edges(number),
|
|
1112
|
+
key: files.edges(number, slice.positions),
|
|
783
1113
|
first: slice.first,
|
|
784
1114
|
positions: slice.positions,
|
|
785
1115
|
sources: slice.sources,
|
|
@@ -799,6 +1129,7 @@ const bitmapsStep = (parts, listed, data, input, allotment) => Effect.gen(functi
|
|
|
799
1129
|
kept: Math.min(madeMost, madeAll)
|
|
800
1130
|
};
|
|
801
1131
|
if (below !== void 0) bitmapsInput.below = below;
|
|
1132
|
+
if (data.below.length === 0 && lower !== void 0) return yield* bitmapsCutTry(parts, files, data, bitmapsInput, allotment);
|
|
802
1133
|
const already = yield* storedSize(bucket, files.bitmaps);
|
|
803
1134
|
const written = already === void 0 ? yield* writeBitmaps(bitmapsInput) : yield* storedBitmaps(bucket, files.bitmaps, positions, already);
|
|
804
1135
|
if (written === void 0) return void 0;
|
|
@@ -808,13 +1139,113 @@ const bitmapsStep = (parts, listed, data, input, allotment) => Effect.gen(functi
|
|
|
808
1139
|
bitmaps: written.count,
|
|
809
1140
|
table: written.table
|
|
810
1141
|
};
|
|
1142
|
+
}, Effect.scoped);
|
|
1143
|
+
/**
|
|
1144
|
+
* One try of a whole build's bitmaps under its bound (#1068): the next part, those of the order
|
|
1145
|
+
* from where the last part ended, through the try's bound less `indexBitmapsCallsAfter`, then put
|
|
1146
|
+
* through the whole bound. Once the parts hold the order, the try joins them into `.bitmaps`. A
|
|
1147
|
+
* bitmap the bound cuts is left whole for the next try, and a try that makes none refuses, as the
|
|
1148
|
+
* next would spend its calls at the same place.
|
|
1149
|
+
*/
|
|
1150
|
+
const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files, data, input, allotment) {
|
|
1151
|
+
const order = bitmapOrder(input.chosen);
|
|
1152
|
+
const ordered = orderKey(order);
|
|
1153
|
+
const cut = data.bitmapsCut?.order === ordered ? data.bitmapsCut : {
|
|
1154
|
+
order: ordered,
|
|
1155
|
+
done: 0,
|
|
1156
|
+
parts: []
|
|
1157
|
+
};
|
|
1158
|
+
if (cut.done >= order.length) return yield* bitmapsJoined(parts, files, data, cut, input.positions, allotment);
|
|
1159
|
+
yield* allotment.grow(partBytesMost);
|
|
1160
|
+
const key = files.bitmapsPart(cut.order, cut.parts.length);
|
|
1161
|
+
const landed = yield* readWhole(parts.bucket, key);
|
|
1162
|
+
if (landed !== void 0) {
|
|
1163
|
+
const count = yield* partCount(key, landed);
|
|
1164
|
+
return {
|
|
1165
|
+
...data,
|
|
1166
|
+
bitmapsCut: next(cut, count)
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
const into = new BitmapsPart(partBytesMost);
|
|
1170
|
+
const made = yield* Effect.result(cutAtSpent(writeBitmaps({
|
|
1171
|
+
...input,
|
|
1172
|
+
part: {
|
|
1173
|
+
from: cut.done,
|
|
1174
|
+
into
|
|
1175
|
+
}
|
|
1176
|
+
})));
|
|
1177
|
+
if (Result.isFailure(made)) {
|
|
1178
|
+
const spent = spentOf(made.failure);
|
|
1179
|
+
if (spent === void 0) return yield* Effect.fail(made.failure);
|
|
1180
|
+
if (into.count === 0) {
|
|
1181
|
+
const most = parts.counted?.most[spent.bound] ?? spent.most;
|
|
1182
|
+
return yield* Effect.fail(bitmapUnwritten(spent.bound, most, order[cut.done]?.position ?? 0));
|
|
1183
|
+
}
|
|
1184
|
+
} else if (into.count === 0) return yield* Effect.fail(lost(`No bitmap of ${input.positions} positions fits a part`));
|
|
1185
|
+
const count = yield* partPut(parts.bucket, key, into);
|
|
1186
|
+
if (count === void 0) return data;
|
|
1187
|
+
return {
|
|
1188
|
+
...data,
|
|
1189
|
+
bitmapsCut: next(cut, count)
|
|
1190
|
+
};
|
|
1191
|
+
});
|
|
1192
|
+
/** `cut` with its next part, of `count` bitmaps, made. */
|
|
1193
|
+
const next = (cut, count) => ({
|
|
1194
|
+
order: cut.order,
|
|
1195
|
+
done: cut.done + count,
|
|
1196
|
+
parts: [...cut.parts, count]
|
|
1197
|
+
});
|
|
1198
|
+
/** How many bitmaps the part at `key` holds, as `bytes` read. */
|
|
1199
|
+
const partCount = (key, bytes) => {
|
|
1200
|
+
const held = partBitmaps(bytes);
|
|
1201
|
+
return held === void 0 ? Effect.fail(lost(`${key} is unreadable`)) : Effect.succeed(held.length);
|
|
1202
|
+
};
|
|
1203
|
+
/**
|
|
1204
|
+
* A part's put, and how many bitmaps it holds, or `undefined` where another try put one at its key
|
|
1205
|
+
* since this try looked. Reading that one would pass the try's bound, which kept one call for the
|
|
1206
|
+
* put alone.
|
|
1207
|
+
*/
|
|
1208
|
+
const partPut = (bucket, key, part) => {
|
|
1209
|
+
const bytes = part.finish();
|
|
1210
|
+
const count = part.count;
|
|
1211
|
+
return bucketPut(bucket, key, bytes).pipe(Effect.as(count), Effect.catchIf(alreadyThere, () => Effect.succeed(void 0)));
|
|
1212
|
+
};
|
|
1213
|
+
/**
|
|
1214
|
+
* A whole build's `.bitmaps`, its parts joined in order through one put: the same bytes one try's
|
|
1215
|
+
* `writeBitmaps` would put. Its calls are one read a part and the put's own, all known before it
|
|
1216
|
+
* reads, so past the try's bound it refuses before its first call.
|
|
1217
|
+
*/
|
|
1218
|
+
const bitmapsJoined = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files, data, cut, positions, allotment) {
|
|
1219
|
+
const { bucket, counted } = parts;
|
|
1220
|
+
const atMost = bitmapsMostBytes(positions, cut.done);
|
|
1221
|
+
const needs = cut.parts.length + Math.ceil(atMost / uploadPartBytes) + 2;
|
|
1222
|
+
if (counted !== void 0 && needs > counted.most.bucket - counted.made().bucket) return yield* Effect.fail(bitmapsUnjoined(needs, counted.most.bucket));
|
|
1223
|
+
const already = yield* storedSize(bucket, files.bitmaps);
|
|
1224
|
+
const written = already === void 0 ? yield* Effect.scoped(Effect.gen(function* () {
|
|
1225
|
+
yield* allotment.grow(partBytesMost + Math.min(atMost, uploadPartBytes));
|
|
1226
|
+
const put = yield* bitmapsPut(bucket, files.bitmaps, positions, cut.done);
|
|
1227
|
+
for (const [number, held] of cut.parts.entries()) {
|
|
1228
|
+
const key = files.bitmapsPart(cut.order, number);
|
|
1229
|
+
const bitmaps = partBitmaps(yield* readScratch(bucket, key));
|
|
1230
|
+
if (bitmaps?.length !== held) return yield* Effect.fail(lost(`${key} is unreadable`));
|
|
1231
|
+
for (const bitmap of bitmaps) yield* put.addBytes(bitmap.position, bitmap.number, bitmap.bytes);
|
|
1232
|
+
}
|
|
1233
|
+
return yield* put.finish;
|
|
1234
|
+
})) : yield* storedBitmaps(bucket, files.bitmaps, positions, already);
|
|
1235
|
+
const { bitmapsCut: _, ...rest } = data;
|
|
1236
|
+
return {
|
|
1237
|
+
...rest,
|
|
1238
|
+
step: "files",
|
|
1239
|
+
bitmaps: written.count,
|
|
1240
|
+
table: written.table
|
|
1241
|
+
};
|
|
811
1242
|
});
|
|
812
1243
|
/**
|
|
813
1244
|
* The files step: `.types` and `.bases`, each its parts streamed in position order, and each
|
|
814
1245
|
* found there on its own when a try that died after its put landed is done again. It holds a
|
|
815
1246
|
* part as read, its words, and what it writes of it, charged to `allotment` first.
|
|
816
1247
|
*/
|
|
817
|
-
const filesStep = (parts, listed, data, allotment)
|
|
1248
|
+
const filesStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
|
|
818
1249
|
const { bucket } = parts;
|
|
819
1250
|
const files = indexFiles(listed.repo, data.build);
|
|
820
1251
|
const positions = coveredPositions(listed, data);
|
|
@@ -826,18 +1257,16 @@ const filesStep = (parts, listed, data, allotment) => Effect.gen(function* () {
|
|
|
826
1257
|
const types = Effect.gen(function* () {
|
|
827
1258
|
const writer = new TypesWriter(positions);
|
|
828
1259
|
const put = yield* startPut(bucket, files.types, { size: indexTypesBytes(positions) });
|
|
829
|
-
yield* Effect.addFinalizer((exit) => Exit.isFailure(exit) ? put.abort : Effect.void);
|
|
830
1260
|
yield* put.write(writer.head());
|
|
831
|
-
for (const [number] of ordered) yield* put.write(yield* writer.part(yield* readScratch(bucket, files.typesPart(number))));
|
|
1261
|
+
for (const [number, slice] of ordered) yield* put.write(yield* writer.part(yield* readScratch(bucket, files.typesPart(number, slice.positions))));
|
|
832
1262
|
yield* put.write(yield* writer.end());
|
|
833
1263
|
yield* put.finish;
|
|
834
1264
|
});
|
|
835
1265
|
const bases = Effect.gen(function* () {
|
|
836
1266
|
const writer = new BasesWriter(every, deltas);
|
|
837
1267
|
const put = yield* startPut(bucket, files.bases, { size: indexBasesBytes(every, deltas) });
|
|
838
|
-
yield* Effect.addFinalizer((exit) => Exit.isFailure(exit) ? put.abort : Effect.void);
|
|
839
1268
|
yield* put.write(writer.head());
|
|
840
|
-
for (const [number] of ordered) yield* put.write(yield* writer.rows(wordsOf(yield* readScratch(bucket, files.basesPart(number)))));
|
|
1269
|
+
for (const [number, slice] of ordered) yield* put.write(yield* writer.rows(wordsOf(yield* readScratch(bucket, files.basesPart(number, slice.positions)))));
|
|
841
1270
|
yield* put.write(yield* writer.end());
|
|
842
1271
|
yield* put.finish;
|
|
843
1272
|
});
|
|
@@ -856,14 +1285,21 @@ const rowsOfLayer = (layer) => layer.groups.reduce((sum, group) => sum + group.r
|
|
|
856
1285
|
/**
|
|
857
1286
|
* The most bucket calls `mergeStep` makes once its layers' graphs are open, each bound from its
|
|
858
1287
|
* merging layers alone, so a try that can't make them refuses before it reads (the core EM's condition 3
|
|
859
|
-
* on part 2). A file a try that died already put makes fewer.
|
|
1288
|
+
* on part 2). A file a try that died already put makes fewer. Its `.graph`, `.types`, `.bases` and
|
|
1289
|
+
* region are each told their size, so charged as `multipart` charges a put of it; its `.bitmaps`
|
|
1290
|
+
* goes up with no length told, so in `multipart`'s parts, each a call, beside its `begin` and `end`.
|
|
860
1291
|
*/
|
|
861
|
-
const mergeCallsAfterOpen = (merging) => {
|
|
1292
|
+
const mergeCallsAfterOpen = (merging, multipart) => {
|
|
862
1293
|
const { layers, octopus, packs, tips } = merging;
|
|
863
1294
|
const chunks = (count, size) => Math.ceil(count / size);
|
|
864
1295
|
const commits = layers.reduce((sum, layer) => sum + layer.commits, 0);
|
|
1296
|
+
const bitmaps = layers.reduce((sum, layer) => sum + layer.bitmaps, 0);
|
|
865
1297
|
const passes = octopus.some((each) => each > 0) ? 4 : 3;
|
|
866
|
-
|
|
1298
|
+
const positions = merging.positions ?? firstOf(layers);
|
|
1299
|
+
const deltas = merging.deltas ?? layers.reduce((sum, layer) => sum + layer.deltas, 0);
|
|
1300
|
+
const rows = layers.reduce((sum, layer) => sum + rowsOfLayer(layer), 0);
|
|
1301
|
+
const entries = octopus.reduce((sum, each) => sum + each, 0);
|
|
1302
|
+
let calls = 4 + sizedPutCalls(multipart, indexGraphBytes(commits, entries)) + sizedPutCalls(multipart, indexTypesBytes(positions)) + sizedPutCalls(multipart, indexBasesBytes(positions, deltas)) + streamedPutCalls(multipart, bitmapsMostBytes(positions, bitmaps)) + (rows > 0 ? sizedPutCalls(multipart, rows * 20) : 0);
|
|
867
1303
|
for (const [at, layer] of layers.entries()) {
|
|
868
1304
|
const graphed = chunks(layer.commits, graphChunk);
|
|
869
1305
|
if (rowsOfLayer(layer) > 0) calls += 2;
|
|
@@ -907,13 +1343,14 @@ const mergeHeldMost = (merging) => {
|
|
|
907
1343
|
};
|
|
908
1344
|
/**
|
|
909
1345
|
* The refusal of a merge that can't fit a try's bound or its instance's memory: the next try
|
|
910
|
-
* would come to the same, so its
|
|
1346
|
+
* would come to the same, so its refusal stands until the host's bounds change, its layers kept
|
|
1347
|
+
* (Q886).
|
|
911
1348
|
*/
|
|
912
1349
|
const mergePast = (needs, what, most, raise) => {
|
|
913
1350
|
const message = `Merging the index's layers needs ${needs} ${what}, more than the limit of ${most}.`;
|
|
914
1351
|
return refusedRow(message, raise, what === "bytes" ? "too-large" : "too-many-store-calls");
|
|
915
1352
|
};
|
|
916
|
-
const raiseCalls = (kind) => `Raise \`callLimits.${kind}\` in \`
|
|
1353
|
+
const raiseCalls = (kind) => `Raise \`callLimits.${kind}\` in \`Cloudflare.layer\`'s options, up to the platform's cap.`;
|
|
917
1354
|
/** A refusal when `needs` more calls are past what the try has left of its bound. */
|
|
918
1355
|
const callsPast = (parts, needs) => {
|
|
919
1356
|
const { counted } = parts;
|
|
@@ -922,7 +1359,7 @@ const callsPast = (parts, needs) => {
|
|
|
922
1359
|
for (const kind of ["bucket", "subrequests"]) if (made[kind] + needs > counted.most[kind]) return mergePast(made[kind] + needs, `${kind === "bucket" ? "bucket calls" : "subrequests"}`, counted.most[kind], raiseCalls(kind));
|
|
923
1360
|
};
|
|
924
1361
|
/** The merged region's digest, its IDs each layer's in turn, put once. */
|
|
925
|
-
const mergedRegion = (bucket, repo, layers, key)
|
|
1362
|
+
const mergedRegion = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, repo, layers, key) {
|
|
926
1363
|
const regions = yield* Effect.forEach(layers, (layer) => rowsOfLayer(layer) === 0 ? Effect.succeed(/* @__PURE__ */ new Uint8Array(0)) : readScratch(bucket, indexFiles(repo, layer.build).region));
|
|
927
1364
|
const region = new Uint8Array(regions.reduce((sum, ids) => sum + ids.byteLength, 0));
|
|
928
1365
|
let at = 0;
|
|
@@ -940,11 +1377,9 @@ const mergedRegion = (bucket, repo, layers, key) => Effect.gen(function* () {
|
|
|
940
1377
|
* each layer's runs, the union gone once they're chosen. Only a tip with a stored bitmap is
|
|
941
1378
|
* ORed, so its lists are the bitmaps' at most.
|
|
942
1379
|
*/
|
|
943
|
-
const liveBitmaps = (layout, stored, tips, positions)
|
|
1380
|
+
const liveBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (layout, stored, tips, positions) {
|
|
944
1381
|
const live = new Uint32Array(bitmapWords(positions));
|
|
945
|
-
const
|
|
946
|
-
const searchedUpTo = lookups.searched <= lookups.joined ? tips.length : 0;
|
|
947
|
-
const found = yield* layout.positionsOf(idsOf(tips), tips.length, searchedUpTo);
|
|
1382
|
+
const found = yield* layout.positionsOf(idsOf(tips), tips.length);
|
|
948
1383
|
const bitmapped = [];
|
|
949
1384
|
for (const position of found) if (position !== 4294967295 && stored.has(position)) bitmapped.push(position);
|
|
950
1385
|
yield* stored.orInto(bitmapped, live);
|
|
@@ -956,7 +1391,7 @@ const liveBitmaps = (layout, stored, tips, positions) => Effect.gen(function* ()
|
|
|
956
1391
|
* moves them, or where they were. A file a try that died already put is kept. Its caller charges
|
|
957
1392
|
* the bitmaps' entries, `mergeEntryBytes` each; the copy charges its own.
|
|
958
1393
|
*/
|
|
959
|
-
const copyMergedBitmaps =
|
|
1394
|
+
const copyMergedBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
960
1395
|
const { bucket, files, positions, kept } = input;
|
|
961
1396
|
const stored = yield* storedSize(bucket, files.bitmaps);
|
|
962
1397
|
if (stored !== void 0) return yield* storedBitmaps(bucket, files.bitmaps, positions, stored);
|
|
@@ -1005,7 +1440,7 @@ const copyMergedBitmaps = (input) => Effect.gen(function* () {
|
|
|
1005
1440
|
* `mergeHeldMost`: past the try's bound, or past what the instance allots, it refuses before it
|
|
1006
1441
|
* reads, and its row keeps the layers as a refusal for spent tries does (part 2's condition 3).
|
|
1007
1442
|
*/
|
|
1008
|
-
const mergeStep = (parts, listed, data, input, allotment)
|
|
1443
|
+
const mergeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, input, allotment) {
|
|
1009
1444
|
const { bucket } = parts;
|
|
1010
1445
|
const { repo } = listed;
|
|
1011
1446
|
const layers = data.below;
|
|
@@ -1024,10 +1459,11 @@ const mergeStep = (parts, listed, data, input, allotment) => Effect.gen(function
|
|
|
1024
1459
|
packs,
|
|
1025
1460
|
tips: tips.length
|
|
1026
1461
|
};
|
|
1027
|
-
const past = callsPast(parts, mergeCallsAfterOpen(merging));
|
|
1462
|
+
const past = callsPast(parts, mergeCallsAfterOpen(merging, bucket.multipart));
|
|
1028
1463
|
if (past !== void 0) return yield* Effect.fail(past);
|
|
1029
1464
|
const held = mergeHeldMost(merging);
|
|
1030
|
-
const
|
|
1465
|
+
const most = parts.budget.mostOf(true);
|
|
1466
|
+
const tooLarge = mergePast(held, "bytes", most, "Raise `PacksOptions.memory`.");
|
|
1031
1467
|
yield* allotment.grow(held, tooLarge);
|
|
1032
1468
|
allotment.shrink(held);
|
|
1033
1469
|
const rows = layers.reduce((sum, layer) => sum + rowsOfLayer(layer), 0);
|
|
@@ -1061,7 +1497,6 @@ const mergeStep = (parts, listed, data, input, allotment) => Effect.gen(function
|
|
|
1061
1497
|
const types = Effect.gen(function* () {
|
|
1062
1498
|
const writer = new TypesWriter(positions);
|
|
1063
1499
|
const put = yield* startPut(bucket, files.types, { size: indexTypesBytes(positions) });
|
|
1064
|
-
yield* Effect.addFinalizer((exit) => Exit.isFailure(exit) ? put.abort : Effect.void);
|
|
1065
1500
|
yield* put.write(writer.head());
|
|
1066
1501
|
for (const layer of layers) {
|
|
1067
1502
|
const types = yield* openTypes(bucket, indexFiles(repo, layer.build).types, layer.positions);
|
|
@@ -1076,7 +1511,6 @@ const mergeStep = (parts, listed, data, input, allotment) => Effect.gen(function
|
|
|
1076
1511
|
const bases = Effect.gen(function* () {
|
|
1077
1512
|
const writer = new BasesWriter(positions, deltas);
|
|
1078
1513
|
const put = yield* startPut(bucket, files.bases, { size: indexBasesBytes(positions, deltas) });
|
|
1079
|
-
yield* Effect.addFinalizer((exit) => Exit.isFailure(exit) ? put.abort : Effect.void);
|
|
1080
1514
|
yield* put.write(writer.head());
|
|
1081
1515
|
for (const layer of layers) {
|
|
1082
1516
|
const key = indexFiles(repo, layer.build).bases;
|
|
@@ -1107,14 +1541,14 @@ const mergeStep = (parts, listed, data, input, allotment) => Effect.gen(function
|
|
|
1107
1541
|
* before `from`; and the scratch of a build kept for its stored files alone. Answers when the next
|
|
1108
1542
|
* file it kept is due: `at` itself once it has deleted `pruneMost`, with more left to look at.
|
|
1109
1543
|
*/
|
|
1110
|
-
const pruneBuilds = (bucket, repo, keep, replaced, at, grace, from = 0)
|
|
1544
|
+
const pruneBuilds = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, repo, keep, replaced, at, grace, from = 0) {
|
|
1111
1545
|
const prefix = indexPrefix(repo);
|
|
1112
1546
|
const replacedAt = new Map(replaced.map((each) => [each.build, each.at]));
|
|
1113
1547
|
let due;
|
|
1114
1548
|
let after;
|
|
1115
1549
|
let deleted = 0;
|
|
1116
1550
|
for (;;) {
|
|
1117
|
-
const page = yield*
|
|
1551
|
+
const page = yield* bucketDo(bucket.list(prefix, after === void 0 ? {} : { after }));
|
|
1118
1552
|
for (const item of page.items) {
|
|
1119
1553
|
const name = item.key.slice(prefix.length);
|
|
1120
1554
|
const build = name.split(/[./]/)[0] ?? "";
|
|
@@ -1126,7 +1560,7 @@ const pruneBuilds = (bucket, repo, keep, replaced, at, grace, from = 0) => Effec
|
|
|
1126
1560
|
due = Math.min(due ?? Number.POSITIVE_INFINITY, since + grace);
|
|
1127
1561
|
continue;
|
|
1128
1562
|
}
|
|
1129
|
-
yield*
|
|
1563
|
+
yield* bucketDo(bucket.remove(item.key));
|
|
1130
1564
|
deleted += 1;
|
|
1131
1565
|
if (deleted >= 200) return at;
|
|
1132
1566
|
}
|
|
@@ -1226,18 +1660,28 @@ const covers = (data, listed) => coversAll([...data.below, { groups: [{
|
|
|
1226
1660
|
packs: data.packs,
|
|
1227
1661
|
rows: data.rows
|
|
1228
1662
|
}] }], listed);
|
|
1663
|
+
/** Whether `error` is a file's failing its own checks, as a `.bitmaps` lost or cut short. */
|
|
1664
|
+
const isLost = (error) => error.code === "DATA_LOSS";
|
|
1665
|
+
/** A build's meeting with layers whose files fail their own checks: an error in the log. */
|
|
1666
|
+
const layersLost = (listed, error) => Effect.logError(`git.index found repo ${listed.repo}'s index unreadable, so it builds it again whole: ${error.message}`);
|
|
1229
1667
|
/**
|
|
1230
1668
|
* Whether `built` holds all of `listed` and a bitmap for every tip: no pack or row listed since
|
|
1231
1669
|
* its layers, and none of `tips` without a bitmap. A tip whose object no layer holds once every
|
|
1232
1670
|
* pack and row is covered, such as a ref to an object the repo lacks, is left as it is: no update
|
|
1233
|
-
* would give it one. The try that finds it so only prunes.
|
|
1671
|
+
* would give it one. The try that finds it so only prunes. Its joins are charged to an upkeep
|
|
1672
|
+
* allotment of its own, so a try with no room for one fails `readBusy` and the queue tries it
|
|
1673
|
+
* again. A join past all upkeep may hold, the budget less the read reserve, fails `readBusy` too,
|
|
1674
|
+
* retried up to `indexTries`, but no production budget gets there: `allottableOf(defaultMemory)`
|
|
1675
|
+
* less `readReserveBytes`, 99,090,048 B, holds a join of about 12.2M IDs.
|
|
1676
|
+
* `moved` when the repo's rows moved under the read: whether it holds is unknown at `listed`.
|
|
1234
1677
|
*/
|
|
1235
|
-
const upToDate = (parts, listed, built, tips)
|
|
1678
|
+
const upToDate = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, built, tips) {
|
|
1236
1679
|
const covered = coveredPacks(built.layers);
|
|
1237
1680
|
if (listed.packs.some((pack) => !covered.has(pack.id))) return false;
|
|
1238
|
-
const
|
|
1681
|
+
const allotment = yield* parts.budget.upkeep(0, readBusy);
|
|
1682
|
+
const layout = yield* openLayout(parts.bucket, listed, built.layers, void 0, { allotment });
|
|
1239
1683
|
const read = yield* readRegion(parts, listed);
|
|
1240
|
-
if (read === void 0) return
|
|
1684
|
+
if (read === void 0) return "moved";
|
|
1241
1685
|
if ((yield* layout.positionsOf(read.ids, read.rows)).some((position) => position === 4294967295)) return false;
|
|
1242
1686
|
const bitmaps = yield* openLayerBitmaps(parts.bucket, listed.repo, built.layers);
|
|
1243
1687
|
const unique = [...new Set(tips)];
|
|
@@ -1254,12 +1698,41 @@ const ownBuilt = (row, round) => !("refused" in row) && row.refusal === void 0 &
|
|
|
1254
1698
|
/** How many rounds of tries the repo had used when `row` was written. */
|
|
1255
1699
|
const roundsOf = (row) => "refused" in row ? row.refused.rounds : row.rounds;
|
|
1256
1700
|
/**
|
|
1257
|
-
*
|
|
1258
|
-
*
|
|
1259
|
-
*
|
|
1260
|
-
* round, though its layers stand.
|
|
1701
|
+
* What a refusal says at `at` under `limits`, with `packs` listed: `refused` for spent tries until
|
|
1702
|
+
* their wait passes, `too-large` for a step the host's bounds it kept can't make while they stand
|
|
1703
|
+
* and the pack its slice cuts is listed, and `retry` at the next round once either has ended.
|
|
1261
1704
|
*/
|
|
1262
|
-
const
|
|
1705
|
+
const refusalStatus = (refusal, round, limits, at, packs) => {
|
|
1706
|
+
const { reason, tries, bounds, pack } = refusal;
|
|
1707
|
+
if (tries !== void 0) return at >= tries.next ? {
|
|
1708
|
+
state: "retry",
|
|
1709
|
+
reason,
|
|
1710
|
+
round
|
|
1711
|
+
} : {
|
|
1712
|
+
state: "refused",
|
|
1713
|
+
reason,
|
|
1714
|
+
retryAt: tries.next
|
|
1715
|
+
};
|
|
1716
|
+
if (bounds === void 0) return {
|
|
1717
|
+
state: "too-large",
|
|
1718
|
+
reason
|
|
1719
|
+
};
|
|
1720
|
+
return boundsHold(bounds, limits) && (pack === void 0 || packs.includes(pack)) ? {
|
|
1721
|
+
state: "too-large",
|
|
1722
|
+
reason
|
|
1723
|
+
} : {
|
|
1724
|
+
state: "retry",
|
|
1725
|
+
reason,
|
|
1726
|
+
round
|
|
1727
|
+
};
|
|
1728
|
+
};
|
|
1729
|
+
/**
|
|
1730
|
+
* `GitObjects.index.status`: what the repo's `index` row says at `at`, one `IndexStatus`, under
|
|
1731
|
+
* the server's `limits`. A built row's round is the one that built it, whose tries keep it up a
|
|
1732
|
+
* layer at a time. One whose update was refused says so as a refused row does, though its layers
|
|
1733
|
+
* stand. A refusal at the graph's bound stands while the bound is the same (Q735).
|
|
1734
|
+
*/
|
|
1735
|
+
const indexStatus = (row, limits, at, packs) => {
|
|
1263
1736
|
if (row === void 0) return { state: "unbuilt" };
|
|
1264
1737
|
if (!("refused" in row)) {
|
|
1265
1738
|
const { refusal, rounds } = row;
|
|
@@ -1267,31 +1740,15 @@ const indexStatus = (row, graphMost, at) => {
|
|
|
1267
1740
|
state: "built",
|
|
1268
1741
|
round: Math.max(0, rounds - 1)
|
|
1269
1742
|
};
|
|
1270
|
-
|
|
1271
|
-
return at >= tries.next ? {
|
|
1272
|
-
state: "retry",
|
|
1273
|
-
reason,
|
|
1274
|
-
round: rounds
|
|
1275
|
-
} : {
|
|
1276
|
-
state: "refused",
|
|
1277
|
-
reason,
|
|
1278
|
-
retryAt: tries.next
|
|
1279
|
-
};
|
|
1743
|
+
return refusalStatus(refusal, rounds, limits, at, packs);
|
|
1280
1744
|
}
|
|
1281
|
-
const {
|
|
1282
|
-
if (most !== graphMost
|
|
1745
|
+
const { refused } = row;
|
|
1746
|
+
if (refused.most !== limits.graphMost) return {
|
|
1283
1747
|
state: "retry",
|
|
1284
|
-
reason,
|
|
1285
|
-
round: rounds
|
|
1286
|
-
};
|
|
1287
|
-
return tries === void 0 ? {
|
|
1288
|
-
state: "too-large",
|
|
1289
|
-
reason
|
|
1290
|
-
} : {
|
|
1291
|
-
state: "refused",
|
|
1292
|
-
reason,
|
|
1293
|
-
retryAt: tries.next
|
|
1748
|
+
reason: refused.reason,
|
|
1749
|
+
round: refused.rounds
|
|
1294
1750
|
};
|
|
1751
|
+
return refusalStatus(refused, refused.rounds, limits, at, packs);
|
|
1295
1752
|
};
|
|
1296
1753
|
/**
|
|
1297
1754
|
* Whether a ref-moving commit saves `git.index` over `status`: none built, a built index to keep
|
|
@@ -1299,11 +1756,19 @@ const indexStatus = (row, graphMost, at) => {
|
|
|
1299
1756
|
*/
|
|
1300
1757
|
const indexSaves = (status) => status.state === "unbuilt" || status.state === "built" || status.state === "retry";
|
|
1301
1758
|
/**
|
|
1759
|
+
* `step`, with a line in the log naming it where a spent count of its try's calls ends the try,
|
|
1760
|
+
* so a field read of an alarm that spent its bound names the step (#1068).
|
|
1761
|
+
*/
|
|
1762
|
+
const spentNamed = (name, repo) => (step) => Effect.tapCause(step, (cause) => {
|
|
1763
|
+
const spent = spentIn(Cause.squash(cause));
|
|
1764
|
+
return spent === void 0 ? Effect.void : Effect.logWarning(`git.index's ${name} step for repo ${repo} spent its try's calls: ${spent.message}`);
|
|
1765
|
+
});
|
|
1766
|
+
/**
|
|
1302
1767
|
* One try of the build of `listed`: its next step, from `input.data`, or a new build when none
|
|
1303
1768
|
* is under way, or when a pack it covers left the listing. Before its region is read, any change
|
|
1304
1769
|
* to the packs starts it again, since its rows are read at the try's own version.
|
|
1305
1770
|
*/
|
|
1306
|
-
const indexStep =
|
|
1771
|
+
const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, input) {
|
|
1307
1772
|
const { row } = input;
|
|
1308
1773
|
const keptOf = (building) => {
|
|
1309
1774
|
const keep = /* @__PURE__ */ new Map();
|
|
@@ -1317,16 +1782,11 @@ const indexStep = (parts, listed, input) => Effect.gen(function* () {
|
|
|
1317
1782
|
return prunedAt(due);
|
|
1318
1783
|
}
|
|
1319
1784
|
const round = input.round ?? 0;
|
|
1785
|
+
const limits = limitsOf(parts);
|
|
1320
1786
|
if (row !== void 0 && roundsOf(row) > round && !ownBuilt(row, round)) return prunedAt(yield* prune());
|
|
1321
|
-
const
|
|
1787
|
+
const refusing = (reason, held) => {
|
|
1322
1788
|
const rounds = round + 1;
|
|
1323
1789
|
const kept = builtOf(row);
|
|
1324
|
-
const refusals = ((row === void 0 ? void 0 : "refused" in row ? row.refused.tries : row.refusal?.tries)?.refusals ?? 0) + 1;
|
|
1325
|
-
const tries = {
|
|
1326
|
-
at: input.at,
|
|
1327
|
-
refusals,
|
|
1328
|
-
next: input.at + triesWaitOf(refusals)
|
|
1329
|
-
};
|
|
1330
1790
|
if (kept !== void 0) return {
|
|
1331
1791
|
kind: "done",
|
|
1332
1792
|
row: {
|
|
@@ -1335,7 +1795,7 @@ const indexStep = (parts, listed, input) => Effect.gen(function* () {
|
|
|
1335
1795
|
replaced: replacedBy(input, kept.layers),
|
|
1336
1796
|
refusal: {
|
|
1337
1797
|
reason,
|
|
1338
|
-
|
|
1798
|
+
...held
|
|
1339
1799
|
}
|
|
1340
1800
|
}
|
|
1341
1801
|
};
|
|
@@ -1347,17 +1807,36 @@ const indexStep = (parts, listed, input) => Effect.gen(function* () {
|
|
|
1347
1807
|
most: parts.graphMost,
|
|
1348
1808
|
reason,
|
|
1349
1809
|
rounds,
|
|
1350
|
-
|
|
1810
|
+
...held
|
|
1351
1811
|
},
|
|
1352
1812
|
replaced: replacedBy(input)
|
|
1353
1813
|
}
|
|
1354
1814
|
};
|
|
1355
1815
|
};
|
|
1816
|
+
const waiting = (reason) => {
|
|
1817
|
+
const refusals = ((row === void 0 ? void 0 : "refused" in row ? row.refused.tries : row.refusal?.tries)?.refusals ?? 0) + 1;
|
|
1818
|
+
return refusing(reason, { tries: {
|
|
1819
|
+
at: input.at,
|
|
1820
|
+
refusals,
|
|
1821
|
+
next: input.at + triesWaitOf(refusals)
|
|
1822
|
+
} });
|
|
1823
|
+
};
|
|
1824
|
+
const final = (error) => {
|
|
1825
|
+
const reason = sliceRefusal(error);
|
|
1826
|
+
const pack = slicePackOf(error);
|
|
1827
|
+
const bounds = boundsOf(limits);
|
|
1828
|
+
return refusing(reason, pack === void 0 ? { bounds } : {
|
|
1829
|
+
bounds,
|
|
1830
|
+
pack
|
|
1831
|
+
});
|
|
1832
|
+
};
|
|
1356
1833
|
if (input.failed !== void 0) return waiting(input.failed.reason);
|
|
1357
|
-
if (input.data === void 0 && row !== void 0 && !indexSaves(indexStatus(row,
|
|
1834
|
+
if (input.data === void 0 && row !== void 0 && !indexSaves(indexStatus(row, limits, input.at, listedIds(listed)))) return prunedAt(yield* prune());
|
|
1358
1835
|
const built = builtOf(row);
|
|
1359
|
-
|
|
1360
|
-
|
|
1836
|
+
const current = input.data === void 0 && built !== void 0 && coversAll(built.layers, listed) ? yield* upToDate(parts, listed, built, input.tips).pipe(Effect.catchIf(isLost, (error) => Effect.as(layersLost(listed, error), "lost"))) : false;
|
|
1837
|
+
if (current === true) return prunedAt(yield* prune());
|
|
1838
|
+
if (current === "moved" && input.lastCheck !== true) return { kind: "moved" };
|
|
1839
|
+
const fresh = () => built === void 0 || current === "lost" || !coversAll(built.layers, listed) ? started(listed) : built.layers.length < 8 ? startedUpdate(listed, built) : startedMerge(listed, built);
|
|
1361
1840
|
const kept = input.data;
|
|
1362
1841
|
const sameBelow = kept !== void 0 && (kept.below.length === 0 || kept.below.map((layer) => layer.build).join() === (built?.layers ?? []).map((layer) => layer.build).join());
|
|
1363
1842
|
const again = (from) => from.below.length === 0 && from.merge !== true ? started(listed) : fresh();
|
|
@@ -1366,23 +1845,26 @@ const indexStep = (parts, listed, input) => Effect.gen(function* () {
|
|
|
1366
1845
|
kind: "more",
|
|
1367
1846
|
data: next
|
|
1368
1847
|
});
|
|
1848
|
+
const orWhole = (step) => data.below.length === 0 ? step : step.pipe(Effect.catchIf(isLost, (error) => Effect.as(layersLost(listed, error), started(listed))));
|
|
1849
|
+
if (input.lastCheck === true && input.data === void 0) return more(data);
|
|
1369
1850
|
if (data.step === "region") yield* prune(data.build);
|
|
1370
1851
|
if (data.step === "commit" && addsNothing(data)) {
|
|
1371
1852
|
yield* prune();
|
|
1372
1853
|
return prunedAt(input.at);
|
|
1373
1854
|
}
|
|
1374
1855
|
if (data.step === "commit") return yield* commitStep(listed, data, input);
|
|
1375
|
-
const allotment = yield* parts.budget.
|
|
1376
|
-
|
|
1377
|
-
if (data.step === "
|
|
1856
|
+
const allotment = yield* parts.budget.upkeep(floors.cache + floors.blocks, readBusy);
|
|
1857
|
+
const named = spentNamed(data.step, listed.repo);
|
|
1858
|
+
if (data.step === "region") return more(yield* named(orWhole(regionStep(parts, listed, data, allotment))));
|
|
1859
|
+
if (data.step === "files") return more(yield* named(orWhole(filesStep(parts, listed, data, allotment))));
|
|
1378
1860
|
if (data.step === "merge") {
|
|
1379
|
-
const merged = yield* Effect.result(mergeStep(parts, listed, data, input, allotment));
|
|
1861
|
+
const merged = yield* Effect.result(named(orWhole(mergeStep(parts, listed, data, input, allotment))));
|
|
1380
1862
|
if (Result.isSuccess(merged)) return more(merged.success);
|
|
1381
|
-
if (isSliceRefused(merged.failure)) return
|
|
1863
|
+
if (isSliceRefused(merged.failure)) return final(merged.failure);
|
|
1382
1864
|
return yield* Effect.fail(merged.failure);
|
|
1383
1865
|
}
|
|
1384
1866
|
if (data.step === "graph") {
|
|
1385
|
-
const graphed = yield* graphStep(parts, listed, data, allotment);
|
|
1867
|
+
const graphed = yield* named(orWhole(graphStep(parts, listed, data, allotment)));
|
|
1386
1868
|
if ("step" in graphed) return more(graphed);
|
|
1387
1869
|
return {
|
|
1388
1870
|
kind: "done",
|
|
@@ -1398,14 +1880,17 @@ const indexStep = (parts, listed, input) => Effect.gen(function* () {
|
|
|
1398
1880
|
};
|
|
1399
1881
|
}
|
|
1400
1882
|
if (data.step === "read") {
|
|
1401
|
-
const read = yield* Effect.result(readStep(parts, listed, data, allotment));
|
|
1883
|
+
const read = yield* Effect.result(named(orWhole(readStep(parts, listed, data, allotment))));
|
|
1402
1884
|
if (Result.isSuccess(read)) return more(read.success);
|
|
1403
|
-
if (isSliceRefused(read.failure)) return
|
|
1885
|
+
if (isSliceRefused(read.failure)) return final(read.failure);
|
|
1404
1886
|
return yield* Effect.fail(read.failure);
|
|
1405
1887
|
}
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1888
|
+
const bitmaps = yield* Effect.result(named(orWhole(bitmapsStep(parts, listed, data, input, allotment))));
|
|
1889
|
+
if (Result.isSuccess(bitmaps)) return more(bitmaps.success ?? started(listed));
|
|
1890
|
+
if (isSliceRefused(bitmaps.failure)) return final(bitmaps.failure);
|
|
1891
|
+
return yield* Effect.fail(bitmaps.failure);
|
|
1892
|
+
}, Effect.scoped);
|
|
1893
|
+
const decodeDataOption = /* @__PURE__ */ Schema.decodeUnknownOption(IndexData);
|
|
1409
1894
|
/**
|
|
1410
1895
|
* The most the graph step holds in a `packs()` instance of `memory`: half what it allots, about
|
|
1411
1896
|
* 48 MB in a Worker's 128 MB, at 16 bytes a commit about 3 M commits.
|
|
@@ -1417,7 +1902,7 @@ const graphMostOf = (memory) => Math.floor(allottableOf(memory) / 2);
|
|
|
1417
1902
|
* change wrote, is as none, as `indexStatus` reads it: the try starts a new build, and prune
|
|
1418
1903
|
* deletes the old one's files once the grace has passed since they were written.
|
|
1419
1904
|
*/
|
|
1420
|
-
const indexTry = (parts, limits, listed, input)
|
|
1905
|
+
const indexTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, limits, listed, input) {
|
|
1421
1906
|
const step = {
|
|
1422
1907
|
tips: [...new Set(input.tips.map((tip) => tip.oid))],
|
|
1423
1908
|
at: input.at,
|
|
@@ -1430,6 +1915,7 @@ const indexTry = (parts, limits, listed, input) => Effect.gen(function* () {
|
|
|
1430
1915
|
if (row !== void 0) step.row = row;
|
|
1431
1916
|
if (input.deleted !== void 0) step.deleted = input.deleted;
|
|
1432
1917
|
if (input.failed !== void 0) step.failed = input.failed;
|
|
1918
|
+
if (input.lastCheck === true) step.lastCheck = true;
|
|
1433
1919
|
const ended = yield* indexStep({
|
|
1434
1920
|
...parts,
|
|
1435
1921
|
graphMost: limits.graphMost
|
|
@@ -1444,4 +1930,4 @@ const indexTry = (parts, limits, listed, input) => Effect.gen(function* () {
|
|
|
1444
1930
|
data: ended.data
|
|
1445
1931
|
};
|
|
1446
1932
|
});
|
|
1447
|
-
export { BuiltIndex, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, builtIndexOf, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, edgesMost, floors, graphMostOf, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };
|
|
1933
|
+
export { BitmapsCut, BuiltIndex, IndexBounds, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, bitmapsJoinHeld, bitmapsJoinMost, boundsOf, builtIndexOf, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, edgesMost, entriesHeld, floors, graphMostOf, indexBitmapsCallsAfter, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, limitsOf, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, reachesBytes, reachesOf, readFurther, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };
|