@ref0/git 0.12.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access/private-refs.mjs +3 -3
- package/dist/auth/access-jwt.mjs +2 -2
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +4 -20
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.mjs +4 -4
- package/dist/auth/helpers.mjs +3 -11
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- package/dist/auth/token-cleanup.mjs +67 -0
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/token-text.mjs +9 -1
- package/dist/auth/tokens-base.d.mts +35 -0
- package/dist/auth/tokens-base.mjs +13 -0
- package/dist/auth/tokens-layer.d.mts +2 -28
- package/dist/auth/tokens-layer.mjs +6 -12
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -17
- package/dist/auth/tokens.mjs +9 -87
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +35 -11
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +39 -12
- package/dist/client/remote.mjs +95 -31
- package/dist/client/run-remote-helper.d.mts +1 -0
- package/dist/client/run-remote-helper.mjs +58 -24
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +105 -46
- package/dist/contracts/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +57 -10
- package/dist/contracts/blobs.mjs +16 -2
- package/dist/contracts/call-allowance.d.mts +13 -0
- package/dist/contracts/call-allowance.mjs +44 -0
- package/dist/contracts/calls-spent.mjs +8 -3
- package/dist/contracts/client.d.mts +23 -19
- package/dist/contracts/commits.d.mts +34 -26
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +12 -12
- package/dist/contracts/forks.d.mts +27 -17
- package/dist/contracts/git-events.d.mts +29 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +39 -7
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -9
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +103 -35
- package/dist/contracts/operations.d.mts +3 -0
- package/dist/contracts/operations.mjs +12 -2
- package/dist/contracts/push-uploads.d.mts +44 -5
- package/dist/contracts/push-uploads.mjs +7 -3
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +50 -25
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +5 -4
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +106 -127
- package/dist/contracts/repos.mjs +33 -4
- package/dist/contracts/result.d.mts +49 -25
- package/dist/contracts/result.mjs +52 -11
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +37 -111
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +90 -26
- package/dist/contracts/sync.mjs +45 -11
- package/dist/contracts/tags.d.mts +10 -10
- package/dist/contracts/time.d.mts +3 -0
- package/dist/contracts/{promises.mjs → time.mjs} +1 -1
- package/dist/contracts/tokens.d.mts +15 -22
- package/dist/contracts/tokens.mjs +3 -3
- package/dist/contracts/topics.d.mts +1 -6
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +87 -12
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +46 -13
- package/dist/core/ancestry.d.mts +10 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +43 -5
- package/dist/core/call-names.mjs +7 -1
- package/dist/core/call-services.mjs +13 -4
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +48 -33
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +931 -435
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +159 -15
- package/dist/core/index-job.mjs +128 -37
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/commits.mjs +16 -6
- package/dist/core/objects/lines.mjs +2 -2
- package/dist/core/objects/merges.mjs +4 -1
- package/dist/core/objects/objects-layer.d.mts +1 -1
- package/dist/core/objects/objects-layer.mjs +3 -3
- package/dist/core/objects/reading.mjs +24 -13
- package/dist/core/objects/tags.mjs +4 -1
- package/dist/core/objects/trees.mjs +2 -2
- package/dist/core/objects/writing.mjs +2 -2
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +10 -6
- package/dist/core/parts.mjs +3 -11
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +316 -42
- package/dist/core/push-decide.mjs +3 -1
- package/dist/core/push-files.d.mts +12 -0
- package/dist/core/push-files.mjs +225 -0
- package/dist/core/push-repo.d.mts +8 -0
- package/dist/core/push-repo.mjs +56 -0
- package/dist/core/push.d.mts +17 -0
- package/dist/core/push.mjs +153 -70
- package/dist/core/receipts.mjs +34 -13
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +61 -7
- package/dist/core/refs.mjs +18 -13
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +46 -28
- package/dist/core/repo-info.mjs +19 -12
- package/dist/core/repos.mjs +50 -22
- package/dist/core/rules/commit-changes.d.mts +0 -1
- package/dist/core/saved-caller-views.d.mts +7 -2
- package/dist/core/saved-caller-views.mjs +2 -2
- package/dist/core/saved-callers.d.mts +19 -2
- package/dist/core/seam.d.mts +16 -26
- package/dist/core/seam.mjs +7 -28
- package/dist/core/tokens.mjs +1 -1
- package/dist/core/view.d.mts +6 -0
- package/dist/core/view.mjs +51 -26
- package/dist/core/work.mjs +105 -35
- package/dist/effect.d.mts +5 -12
- package/dist/effect.mjs +3 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +17 -10
- package/dist/engine/walk.mjs +4 -4
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +3 -3
- package/dist/event-streams/stream.mjs +38 -15
- package/dist/extend.d.mts +4 -5
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +12 -7
- package/dist/http/core-parts.mjs +129 -64
- package/dist/http/handler.mjs +36 -9
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +61 -31
- package/dist/http/parts.d.mts +2 -0
- package/dist/http/push-upload-job.mjs +507 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +142 -69
- package/dist/http/upload-pack.mjs +10 -9
- package/dist/index.d.mts +27 -28
- package/dist/index.mjs +5 -8
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +9 -3
- package/dist/lfs/base.mjs +27 -2
- package/dist/lfs/copy.d.mts +60 -0
- package/dist/lfs/copy.mjs +109 -0
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +28 -13
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +7 -0
- package/dist/lfs/objects.mjs +152 -55
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +3 -3
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
- package/dist/protocol/bytes/sha256.d.mts +32 -0
- package/dist/protocol/bytes/sha256.mjs +105 -49
- package/dist/protocol/bytes/streams.mjs +27 -1
- package/dist/protocol/diff/read.d.mts +4 -3
- package/dist/protocol/diff/read.mjs +8 -3
- package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
- package/dist/protocol/objects/lfs-pointer.mjs +1 -3
- package/dist/protocol/objects/links-raw.mjs +24 -10
- package/dist/protocol/objects/tag.d.mts +1 -1
- package/dist/protocol/objects/tree.mjs +23 -6
- package/dist/protocol/packs/delta.d.mts +6 -3
- package/dist/protocol/packs/delta.mjs +96 -32
- package/dist/protocol/packs/idx.d.mts +2 -1
- package/dist/protocol/packs/idx.mjs +22 -3
- package/dist/protocol/packs/parts.d.mts +4 -1
- package/dist/protocol/packs/parts.mjs +10 -7
- package/dist/protocol/packs/reader.d.mts +5 -0
- package/dist/protocol/packs/reader.mjs +3 -2
- package/dist/protocol/packs/writer.mjs +26 -8
- package/dist/protocol/wire/advertisement.mjs +9 -4
- package/dist/protocol/wire/lines.d.mts +4 -2
- package/dist/protocol/wire/lines.mjs +11 -5
- package/dist/protocol/wire/push-uploads.mjs +13 -1
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/protocol.d.mts +3 -1
- package/dist/protocol.mjs +3 -1
- package/dist/queue/advance.mjs +22 -25
- package/dist/queue/base.d.mts +55 -0
- package/dist/queue/base.mjs +44 -0
- package/dist/queue/calls.mjs +51 -54
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +2 -22
- package/dist/queue/host.mjs +2 -13
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +11 -4
- package/dist/queue/limits.mjs +2 -0
- package/dist/queue/push-option.mjs +9 -24
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/state.mjs +2 -10
- package/dist/queue/trim.mjs +6 -4
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4231
- package/dist/rest/caller.mjs +5 -1
- package/dist/rest/client.d.mts +15 -5
- package/dist/rest/client.mjs +23 -2
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.mjs +68 -9
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +7 -13
- package/dist/rest/me.d.mts +3 -428
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/work.mjs +8 -0
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +14 -15
- package/dist/server/edge-node.mjs +12 -12
- package/dist/server/edge.d.mts +21 -7
- package/dist/server/edge.mjs +32 -11
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +6 -11
- package/dist/server/git-layer.mjs +29 -23
- package/dist/server/git-namespace.d.mts +5 -4
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +21 -40
- package/dist/server/joined.mjs +11 -62
- package/dist/server/lifecycle.mjs +65 -69
- package/dist/server/registry.mjs +28 -3
- package/dist/server/server.mjs +245 -465
- package/dist/signin/context.d.mts +1 -2
- package/dist/signin/layer.d.mts +1 -1
- package/dist/signin/layer.mjs +1 -1
- package/dist/storage/allotted.mjs +18 -3
- package/dist/storage/batch-upkeep.mjs +274 -0
- package/dist/{core/purge.d.mts → storage/batches.d.mts} +4 -4
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/budget.mjs +2 -2
- package/dist/storage/calls.d.mts +1 -2
- package/dist/storage/calls.mjs +144 -158
- package/dist/storage/chunks.d.mts +9 -0
- package/dist/storage/chunks.mjs +297 -0
- package/dist/storage/clean-up.mjs +85 -19
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +298 -216
- package/dist/storage/file-limits.mjs +24 -0
- package/dist/storage/host-bucket.mjs +1 -2
- package/dist/storage/id-mix.mjs +19 -5
- package/dist/storage/index-bitmaps.mjs +9 -2
- package/dist/storage/index-build.d.mts +1 -1
- package/dist/storage/index-build.mjs +185 -84
- package/dist/storage/index-fetch.mjs +128 -74
- package/dist/storage/index-files.d.mts +3 -0
- package/dist/storage/index-files.mjs +10 -5
- package/dist/storage/index-graph.mjs +72 -22
- package/dist/storage/index-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +208 -65
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +214 -67
- package/dist/storage/memory-budget.mjs +44 -8
- package/dist/storage/merge-plan.mjs +3 -2
- package/dist/storage/merge-row.mjs +7 -1
- package/dist/storage/merge-stream.mjs +164 -25
- package/dist/storage/merge-walk.mjs +8 -4
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +1 -0
- package/dist/storage/object-rows.mjs +385 -65
- package/dist/storage/oid-table.mjs +171 -0
- package/dist/storage/pack-order.mjs +8 -4
- package/dist/storage/pack-ranges.d.mts +1 -2
- package/dist/storage/pack-ranges.mjs +4 -5
- package/dist/storage/pack-reads.d.mts +2 -1
- package/dist/storage/pack-reads.mjs +165 -49
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +85 -27
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +172 -86
- package/dist/storage/placed-reads.mjs +1 -1
- package/dist/storage/plan-columns.d.mts +4 -0
- package/dist/storage/plan-columns.mjs +238 -0
- package/dist/storage/prune-keep.mjs +299 -37
- package/dist/storage/prune-walk.mjs +240 -62
- package/dist/storage/prune.mjs +749 -213
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +40 -16
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/quarantine.mjs +9 -9
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +55 -25
- package/dist/storage/receive-bounds.mjs +51 -15
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +2 -2
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +13 -2
- package/dist/storage/runs.mjs +195 -43
- package/dist/storage/send-list.d.mts +1 -0
- package/dist/storage/send-list.mjs +54 -10
- package/dist/storage/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +132 -28
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +31 -3
- package/dist/storage/walk.mjs +194 -39
- package/dist/storage/wants.mjs +5 -5
- package/dist/store/bodies.mjs +38 -0
- package/dist/store/call-count.d.mts +8 -12
- package/dist/store/call-count.mjs +34 -46
- package/dist/store/catalogue.d.mts +2 -2
- package/dist/store/catalogue.mjs +146 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal-namespace.d.mts +2 -0
- package/dist/store/cursor-seal-public.d.mts +5 -0
- package/dist/store/cursor-seal-public.mjs +5 -0
- package/dist/store/cursor-seal.d.mts +16 -3
- package/dist/store/cursor-seal.mjs +40 -18
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +24 -34
- package/dist/store/git-store.mjs +25 -7
- package/dist/store/job-try.mjs +9 -32
- package/dist/store/list-job.mjs +44 -8
- package/dist/store/records.d.mts +5 -0
- package/dist/store/records.mjs +12 -6
- package/dist/store/repo-record.d.mts +10 -9
- package/dist/store/repo-record.mjs +123 -28
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +21 -2
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/bound.d.mts +2 -0
- package/dist/sync/bound.mjs +11 -2
- package/dist/sync/github.d.mts +6 -1
- package/dist/sync/github.mjs +56 -44
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +32 -18
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +118 -0
- package/dist/sync/lfs-copy.mjs +262 -0
- package/dist/sync/mirror.mjs +227 -151
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +58 -30
- package/dist/sync/tries.mjs +52 -21
- package/dist/sync.d.mts +2 -2
- package/dist/topics/advance.mjs +10 -11
- package/dist/topics/base.d.mts +15 -0
- package/dist/topics/base.mjs +8 -0
- package/dist/topics/host.mjs +2 -20
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +3 -4
- package/dist/topics/members.mjs +4 -4
- package/dist/topics/public.d.mts +2 -1
- package/dist/topics/topic.mjs +2 -2
- package/package.json +5 -9
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- package/dist/contracts/promises.d.mts +0 -39
- package/dist/core/call-names.d.mts +0 -3
- package/dist/core/clock.mjs +0 -18
- package/dist/core/registered-rows.d.mts +0 -5
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -825
- package/dist/rest/commits.d.mts +0 -3510
- package/dist/rest/errors.d.mts +0 -2104
- package/dist/rest/events.d.mts +0 -423
- package/dist/rest/files.d.mts +0 -1330
- package/dist/rest/forks.d.mts +0 -2136
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -473
- package/dist/rest/queue.d.mts +0 -5861
- package/dist/rest/refs.d.mts +0 -2959
- package/dist/rest/repos.d.mts +0 -2539
- package/dist/rest/tags.d.mts +0 -1304
- package/dist/rest/tokens.d.mts +0 -2590
- package/dist/rest/topics.d.mts +0 -2204
- package/dist/rest/trees.d.mts +0 -1693
- package/dist/rest/work.d.mts +0 -1248
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/server/registry.d.mts +0 -16
- package/dist/server/server.d.mts +0 -36
- package/dist/storage/repack-job.d.mts +0 -3
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
- package/dist/topics/host.d.mts +0 -7
|
@@ -6,17 +6,20 @@ import { repoScope } from "../store/scopes.mjs";
|
|
|
6
6
|
import { anySet, bitCount, clearBit, isSet, nextSet, setBit } from "./bits.mjs";
|
|
7
7
|
import { bitmapWords } from "./ewah.mjs";
|
|
8
8
|
import { ewahMostWords } from "./index-bitmaps.mjs";
|
|
9
|
-
import { builtIndexOf, coveredPacks, coversAll, decodeIndexValue } from "./index-build.mjs";
|
|
10
|
-
import { openTypes, typeOfCode } from "./index-files.mjs";
|
|
9
|
+
import { builtIndexOf, builtOver, coveredPacks, coversAll, decodeIndexValue } from "./index-build.mjs";
|
|
10
|
+
import { openBases, openTypes, typeOfCode } from "./index-files.mjs";
|
|
11
11
|
import { indexShallow, numberIn, numbersIn } from "./index-shallow.mjs";
|
|
12
|
+
import { oidTable } from "./oid-table.mjs";
|
|
12
13
|
import { listOf } from "./send-list.mjs";
|
|
13
|
-
import { ByGeneration, graphChunk, graphRows, openGraphLayers, openIndexGraph } from "./index-graph.mjs";
|
|
14
|
+
import { ByGeneration, graphChunk, graphRows, keptIdsBytes, openGraphLayers, openIndexGraph } from "./index-graph.mjs";
|
|
14
15
|
import { openLayerBitmaps, openLayout, orWords } from "./index-layers.mjs";
|
|
15
16
|
import { indexFiles, indexRowKey, isPackId, packFiles } from "./layout.mjs";
|
|
17
|
+
import { heldFiles, indexFilesOf, wholeFiles } from "./index-whole.mjs";
|
|
16
18
|
import { rangeCached, rangeEntriesBytes } from "./range-cache.mjs";
|
|
17
19
|
import { joinBytes, missing } from "./link-join.mjs";
|
|
18
20
|
import { placedReads } from "./placed-reads.mjs";
|
|
19
|
-
import {
|
|
21
|
+
import { withRootsSent } from "./shallow.mjs";
|
|
22
|
+
import { idsIn, lost, notHeld } from "./walk.mjs";
|
|
20
23
|
import * as Effect from "effect/Effect";
|
|
21
24
|
import * as Data from "effect/Data";
|
|
22
25
|
// src/storage/index-fetch.ts
|
|
@@ -47,6 +50,16 @@ const rangeCacheMost = 16777216;
|
|
|
47
50
|
*/
|
|
48
51
|
const rankBytes = 8;
|
|
49
52
|
/**
|
|
53
|
+
* The largest `.idx` ID window a pack adds to the walk's range allowance, 1 MiB: a pack of 52,428
|
|
54
|
+
* objects or fewer, whose joins then read the window once, not once a level (#2523). Past it, #522
|
|
55
|
+
* stands: a larger pack adds no ID window, as holding its IDs would hold most of what loading its
|
|
56
|
+
* `.idx` holds. It sizes the fetch's one allowance, which every pack's ranges share: it doesn't
|
|
57
|
+
* choose whose windows stay, so a larger pack's may stay in a smaller one's share.
|
|
58
|
+
*/
|
|
59
|
+
const keptIdWindowMost = 1048576;
|
|
60
|
+
/** What a pack of `objects` adds to the walk's range allowance: its `.pos` places, and its ID window under the bound. */
|
|
61
|
+
const keptRangeBytes = (objects) => objects * rankBytes + (objects * 20 <= keptIdWindowMost ? objects * 20 : 0) + rangeEntriesBytes;
|
|
62
|
+
/**
|
|
50
63
|
* What one stored bitmap holds once its layer's bitmaps are open: its table row as read and its
|
|
51
64
|
* words copied, its entry, and its places in `openLayerBitmaps`' maps and `numberAt`. Measured on
|
|
52
65
|
* Node 26 at 268–282 B a bitmap over 1,000 to 100,000 of them; 320 leaves room.
|
|
@@ -90,12 +103,13 @@ const rowsOf = (layer) => layer.groups.reduce((sum, group) => sum + group.rows,
|
|
|
90
103
|
/**
|
|
91
104
|
* The most bucket calls opening an index's layers for a fetch makes: each layer's `.graph`'s two
|
|
92
105
|
* (head and fanout, tail), its `.bitmaps`' three when it has any (head, table, tail), its
|
|
93
|
-
* `.types` header's one, its region's one when it has rows,
|
|
94
|
-
*
|
|
95
|
-
*
|
|
106
|
+
* `.types` header's one, its region's one when it has rows, its `.bases`' two when it has deltas
|
|
107
|
+
* (head, block index, #2523), and each of its packs' `.idx` head and fanout and `.pos` header. No
|
|
108
|
+
* covered pack's `.idx` and `.rev` are loaded whole: the layout and the send list read them by
|
|
109
|
+
* range. The row's own read is the one store call before it (#522).
|
|
96
110
|
*/
|
|
97
111
|
const fetchOpenCalls = (layers) => ({
|
|
98
|
-
bucket: layers.reduce((sum, layer) => sum + 2 + (layer.bitmaps > 0 ? 3 : 0) + 1 + (rowsOf(layer) > 0 ? 1 : 0) + 2 * packsOf(layer), 0),
|
|
112
|
+
bucket: layers.reduce((sum, layer) => sum + 2 + (layer.bitmaps > 0 ? 3 : 0) + 1 + (rowsOf(layer) > 0 ? 1 : 0) + (layer.deltas > 0 ? 2 : 0) + 2 * packsOf(layer), 0),
|
|
99
113
|
store: 0
|
|
100
114
|
});
|
|
101
115
|
/**
|
|
@@ -108,6 +122,27 @@ const regionBytes = (layers) => {
|
|
|
108
122
|
return rows * 24 + (runs > 1 ? rows * 84 : 0);
|
|
109
123
|
};
|
|
110
124
|
/**
|
|
125
|
+
* `source`'s bucket with the index's files held, when they're small: each read whole, at once, one
|
|
126
|
+
* call each, so the walk and the send list wait on one round, not one a range (#2523). The least
|
|
127
|
+
* they can be, from the row and the listing, is checked first. Then `wholeMost` is charged before
|
|
128
|
+
* any read, the reads stop there, and what the files don't hold goes back. `undefined` when they'd
|
|
129
|
+
* pass it, or did, so the index is read by range as before.
|
|
130
|
+
*/
|
|
131
|
+
const heldIndex = /* @__PURE__ */ Effect.fnUntraced(function* (source, row, covered, ahead, read) {
|
|
132
|
+
const most = source.wholeMost ?? 1048576;
|
|
133
|
+
const packs = source.listed.packs.filter(({ id }) => covered.has(id));
|
|
134
|
+
const files = indexFilesOf(source.listed.repo, row.layers, packs);
|
|
135
|
+
if (files === void 0 || files.reduce((sum, file) => sum + file.least, 0) > most) return void 0;
|
|
136
|
+
yield* ahead({
|
|
137
|
+
bucket: files.length,
|
|
138
|
+
store: 0
|
|
139
|
+
});
|
|
140
|
+
yield* read.hold(most);
|
|
141
|
+
const whole = yield* wholeFiles(source.bucket, files, most);
|
|
142
|
+
yield* read.release(most - (whole?.bytes ?? 0));
|
|
143
|
+
return whole === void 0 ? void 0 : heldFiles(source.bucket, whole.files);
|
|
144
|
+
});
|
|
145
|
+
/**
|
|
111
146
|
* The repo's index, opened: its row read through the request's store, 1 call, then its layers'
|
|
112
147
|
* files, `fetchOpenCalls` gets, forecast before any is made. `undefined` when there's no row, a
|
|
113
148
|
* refused one, or one whose layers don't cover `listed`, as when a row newer than it names a
|
|
@@ -115,7 +150,7 @@ const regionBytes = (layers) => {
|
|
|
115
150
|
*/
|
|
116
151
|
const openFetchIndex = /* @__PURE__ */ Effect.fnUntraced(function* (source, ahead, read) {
|
|
117
152
|
const { hold } = read;
|
|
118
|
-
const { store,
|
|
153
|
+
const { store, listed } = source;
|
|
119
154
|
yield* ahead({
|
|
120
155
|
bucket: 0,
|
|
121
156
|
store: 1
|
|
@@ -125,34 +160,41 @@ const openFetchIndex = /* @__PURE__ */ Effect.fnUntraced(function* (source, ahea
|
|
|
125
160
|
reads: [indexRowKey]
|
|
126
161
|
});
|
|
127
162
|
const row = builtIndexOf(decodeIndexValue(snapshot.results[0]?.[0]?.value));
|
|
128
|
-
if (row === void 0 || !coversAll(row.layers, listed)) return void 0;
|
|
163
|
+
if (row === void 0 || !builtOver(row, read.roots) || !coversAll(row.layers, listed)) return void 0;
|
|
129
164
|
if (source.opened !== void 0) source.opened.opened = true;
|
|
130
|
-
yield* ahead(fetchOpenCalls(row.layers));
|
|
131
|
-
yield* hold(regionBytes(row.layers));
|
|
132
|
-
const graphs = [];
|
|
133
|
-
let first = 0;
|
|
134
|
-
for (const layer of row.layers) {
|
|
135
|
-
const key = indexFiles(listed.repo, layer.build).graph;
|
|
136
|
-
const graph = yield* openIndexGraph(bucket, key, layer.graphFirst);
|
|
137
|
-
if (layer.graphFirst !== first || graph.commits !== layer.commits) return yield* Effect.fail(loss(`${key} holds ${graph.commits} from ${layer.graphFirst}, its row ${layer.commits}, where the layers below end at ${first}`));
|
|
138
|
-
graphs.push(graph);
|
|
139
|
-
first += graph.commits;
|
|
140
|
-
}
|
|
141
165
|
const covered = coveredPacks(row.layers);
|
|
166
|
+
const held = yield* heldIndex(source, row, covered, ahead, read);
|
|
167
|
+
const bucket = held ?? source.bucket;
|
|
168
|
+
yield* ahead(held === void 0 ? fetchOpenCalls(row.layers) : noCalls);
|
|
169
|
+
yield* hold(regionBytes(row.layers));
|
|
142
170
|
yield* hold(openedBitmapBytes * row.layers.reduce((sum, layer) => sum + layer.bitmaps, 0));
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
const rangeBytes = Math.min(rangeCacheMost, listed.packs.filter(({ id }) => covered.has(id)).reduce((sum, pack) => sum + pack.objects
|
|
171
|
+
const keepIds = held === void 0;
|
|
172
|
+
if (keepIds) yield* hold(row.layers.reduce((sum, layer) => sum + keptIdsBytes(layer.commits), 0));
|
|
173
|
+
const rangeBytes = held !== void 0 ? 0 : Math.min(rangeCacheMost, listed.packs.filter(({ id }) => covered.has(id)).reduce((sum, pack) => sum + keptRangeBytes(pack.objects), 0));
|
|
146
174
|
yield* hold(rangeBytes);
|
|
147
175
|
const ranges = rangeCached(bucket, rangeBytes, { evict: false });
|
|
148
176
|
const told = read.onLoading?.((id) => {
|
|
149
177
|
if (isPackId(id)) ranges.forget(packFiles(id).idx);
|
|
150
178
|
});
|
|
151
179
|
const { loadedOf } = read;
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
180
|
+
const deltaLayers = row.layers.filter((layer) => layer.deltas > 0);
|
|
181
|
+
const [graphs, bitmaps, types, layout, opened] = yield* Effect.all([
|
|
182
|
+
Effect.forEach(row.layers, (layer) => openIndexGraph(bucket, indexFiles(listed.repo, layer.build).graph, layer.graphFirst, { keepIds }), { concurrency: "unbounded" }),
|
|
183
|
+
openLayerBitmaps(bucket, listed.repo, row.layers),
|
|
184
|
+
Effect.forEach(row.layers, (layer) => openTypes(bucket, indexFiles(listed.repo, layer.build).types, layer.positions), { concurrency: "unbounded" }),
|
|
185
|
+
openLayout(ranges.bucket, listed, row.layers, void 0, loadedOf === void 0 ? { cached: true } : {
|
|
186
|
+
cached: true,
|
|
187
|
+
loadedOf
|
|
188
|
+
}),
|
|
189
|
+
Effect.forEach(deltaLayers, (layer) => openBases(bucket, indexFiles(listed.repo, layer.build).bases, layer.first + layer.positions, layer.deltas), { concurrency: "unbounded" })
|
|
190
|
+
], { concurrency: "unbounded" });
|
|
191
|
+
const bases = new Map(deltaLayers.map((layer, at) => [layer, opened[at]]));
|
|
192
|
+
let first = 0;
|
|
193
|
+
for (const [at, layer] of row.layers.entries()) {
|
|
194
|
+
const graph = graphs[at];
|
|
195
|
+
if (graph === void 0 || layer.graphFirst !== first || graph.commits !== layer.commits) return yield* Effect.fail(loss(`${indexFiles(listed.repo, layer.build).graph} holds ${graph?.commits} from ${layer.graphFirst}, its row ${layer.commits}, where the layers below end at ${first}`));
|
|
196
|
+
first += graph.commits;
|
|
197
|
+
}
|
|
156
198
|
const letRangesGo = Effect.andThen(Effect.sync(() => {
|
|
157
199
|
told?.();
|
|
158
200
|
ranges.clear();
|
|
@@ -171,50 +213,41 @@ const openFetchIndex = /* @__PURE__ */ Effect.fnUntraced(function* (source, ahea
|
|
|
171
213
|
types,
|
|
172
214
|
layout,
|
|
173
215
|
numberAt,
|
|
174
|
-
letRangesGo
|
|
216
|
+
letRangesGo,
|
|
217
|
+
bucket,
|
|
218
|
+
bases,
|
|
219
|
+
held: held !== void 0
|
|
175
220
|
};
|
|
176
221
|
});
|
|
177
222
|
/**
|
|
178
|
-
* IDs,
|
|
179
|
-
*
|
|
180
|
-
*
|
|
223
|
+
* A level's IDs, each kept once in an ID table, and a kind for each by its ordinal, grown as the
|
|
224
|
+
* level's trees name them: so a level holds what's distinct in it, not every snapshot's entries
|
|
225
|
+
* (#1702). Both double together when the table is full, its slots twice its capacity.
|
|
181
226
|
*/
|
|
182
227
|
var Frontier = class {
|
|
183
|
-
|
|
228
|
+
table = oidTable(64);
|
|
184
229
|
kinds = /* @__PURE__ */ new Uint8Array(64);
|
|
185
|
-
|
|
186
|
-
|
|
230
|
+
get count() {
|
|
231
|
+
return this.table.size;
|
|
232
|
+
}
|
|
233
|
+
/** Its IDs end to end, as a pack index's join reads them. */
|
|
234
|
+
get ids() {
|
|
235
|
+
return this.table.ids;
|
|
236
|
+
}
|
|
187
237
|
add(id, kind) {
|
|
188
|
-
if (this.
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const kinds = new Uint8Array(this.kinds.length * 2);
|
|
238
|
+
if (this.table.size === this.table.capacity) {
|
|
239
|
+
const capacity = this.table.capacity * 2;
|
|
240
|
+
this.table.grow(capacity);
|
|
241
|
+
const kinds = new Uint8Array(capacity);
|
|
193
242
|
kinds.set(this.kinds);
|
|
194
243
|
this.kinds = kinds;
|
|
195
|
-
this.slots = new Uint32Array(this.slots.length * 2);
|
|
196
|
-
for (let at = 0; at < this.count; at += 1) this.slots[this.free(this.ids, at * 20)] = at + 1;
|
|
197
244
|
}
|
|
198
|
-
const
|
|
199
|
-
if (this.
|
|
200
|
-
this.ids.set(id, this.count * 20);
|
|
201
|
-
this.kinds[this.count] = kind;
|
|
202
|
-
this.count += 1;
|
|
203
|
-
this.slots[slot] = this.count;
|
|
245
|
+
const next = this.table.size;
|
|
246
|
+
if (this.table.addBytes(id) === next) this.kinds[next] = kind;
|
|
204
247
|
}
|
|
205
|
-
/** The
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
let slot = ((bytes[from] ?? 0) | (bytes[from + 1] ?? 0) << 8 | (bytes[from + 2] ?? 0) << 16 | (bytes[from + 3] ?? 0) << 24) & mask;
|
|
209
|
-
for (;;) {
|
|
210
|
-
const held = this.slots[slot] ?? 0;
|
|
211
|
-
if (held === 0 || this.same(held - 1, bytes, from)) return slot;
|
|
212
|
-
slot = slot + 1 & mask;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
same(at, bytes, from) {
|
|
216
|
-
for (let byte = 0; byte < 20; byte += 1) if (this.ids[at * 20 + byte] !== bytes[from + byte]) return false;
|
|
217
|
-
return true;
|
|
248
|
+
/** The ID at `at`, in hex. */
|
|
249
|
+
oidAt(at) {
|
|
250
|
+
return this.table.oidAt(at);
|
|
218
251
|
}
|
|
219
252
|
/** What it holds at most, grown twice over: `fetchRootFrontierBytes` an ID. */
|
|
220
253
|
static bytes(count) {
|
|
@@ -228,6 +261,11 @@ const blobKind = 2;
|
|
|
228
261
|
* today's walk does. See the file's comment for how; the bounds are `shape-2.md`'s §6.
|
|
229
262
|
*/
|
|
230
263
|
const indexSendSet = (input) => indexSendSetOrNot(input).pipe(Effect.catchTag("Unindexed", () => Effect.succeed(void 0)));
|
|
264
|
+
/** The index path over `source`. */
|
|
265
|
+
const indexPath = (source) => ({
|
|
266
|
+
source,
|
|
267
|
+
send: indexSendSet
|
|
268
|
+
});
|
|
231
269
|
const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
232
270
|
const { source, read, request, ahead } = input;
|
|
233
271
|
const { indexed, sizesAt, heldAt, unplaced: unplacedOf } = read;
|
|
@@ -241,12 +279,13 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
241
279
|
ranges: layout.ranges,
|
|
242
280
|
layers: row.layers,
|
|
243
281
|
listed: source.listed,
|
|
244
|
-
bucket:
|
|
282
|
+
bucket: index.bucket,
|
|
245
283
|
read,
|
|
246
284
|
indexed,
|
|
247
285
|
heldAt,
|
|
248
286
|
outside,
|
|
249
|
-
ahead
|
|
287
|
+
ahead,
|
|
288
|
+
bases: index.bases
|
|
250
289
|
});
|
|
251
290
|
/** `placed`'s objects read at their positions, and `beside`'s, which the index doesn't place, past it. */
|
|
252
291
|
const readSplit = Effect.fnUntraced(function* (placed, beside, newLevel = true) {
|
|
@@ -343,13 +382,13 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
343
382
|
const position = positions[at] ?? 4294967295;
|
|
344
383
|
if (level < 0) {
|
|
345
384
|
if (reads) {
|
|
346
|
-
reading.push(
|
|
385
|
+
reading.push(frontier.oidAt(at));
|
|
347
386
|
placed.push(position);
|
|
348
387
|
}
|
|
349
388
|
continue;
|
|
350
389
|
}
|
|
351
390
|
if (position === 4294967295) {
|
|
352
|
-
const oid =
|
|
391
|
+
const oid = frontier.oidAt(at);
|
|
353
392
|
if (heldExtras.has(oid) || side === "wanted" && sentExtras.has(oid)) continue;
|
|
354
393
|
if (side === "held") {
|
|
355
394
|
yield* read.hold(heldExtraBytes);
|
|
@@ -367,7 +406,7 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
367
406
|
if (blocked(side, position)) continue;
|
|
368
407
|
setBit(bits, position);
|
|
369
408
|
if (kind === "tree" && reads) {
|
|
370
|
-
reading.push(
|
|
409
|
+
reading.push(frontier.oidAt(at));
|
|
371
410
|
placed.push(position);
|
|
372
411
|
}
|
|
373
412
|
}
|
|
@@ -400,10 +439,11 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
400
439
|
if (tree.type !== "tree" || tree.entries === void 0) return yield* Effect.fail(loss(`${oid}, named as a tree, is a ${tree.type}`));
|
|
401
440
|
const extra = side === "wanted" && position === 4294967295 ? sentExtras.get(oid) : void 0;
|
|
402
441
|
if (extra !== void 0) extra.size = tree.size;
|
|
403
|
-
const
|
|
442
|
+
const { trees, blobs } = tree.entries;
|
|
443
|
+
const growing = next.count + idsIn(trees) + idsIn(blobs);
|
|
404
444
|
yield* holdStep(Frontier.bytes(frontier.count) + frontier.count * 4 + Frontier.bytes(growing));
|
|
405
|
-
for (
|
|
406
|
-
for (
|
|
445
|
+
for (let at = 0; at < trees.length; at += 20) next.add(trees.subarray(at, at + 20), treeKind);
|
|
446
|
+
for (let at = 0; at < blobs.length; at += 20) next.add(blobs.subarray(at, at + 20), blobKind);
|
|
407
447
|
read.letGo(tree);
|
|
408
448
|
}
|
|
409
449
|
yield* read.letGoReads(asked.length);
|
|
@@ -668,6 +708,18 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
668
708
|
if (position === 4294967295 ? heldExtras.has(tag) : isSet(held, position)) had.add(tag);
|
|
669
709
|
}
|
|
670
710
|
}
|
|
711
|
+
const rootsSent = /* @__PURE__ */ new Set();
|
|
712
|
+
const rootsAt = row.layers.flatMap((layer) => (layer.roots ?? []).filter((position) => isSet(send, position)));
|
|
713
|
+
const packed = rootsAt.filter((position) => layout.ranges.some((pack) => position >= pack.base && position < pack.base + pack.count));
|
|
714
|
+
if (packed.length > 0) yield* ahead({
|
|
715
|
+
bucket: index.held ? packed.length : 2 * packed.length,
|
|
716
|
+
store: 0
|
|
717
|
+
});
|
|
718
|
+
for (const position of rootsAt) {
|
|
719
|
+
const root = hexOf(yield* layout.idAt(position));
|
|
720
|
+
if (read.roots.has(root)) rootsSent.add(root);
|
|
721
|
+
}
|
|
722
|
+
for (const root of read.roots) if (sentExtras.get(root)?.kind === "commit") rootsSent.add(root);
|
|
671
723
|
yield* index.letRangesGo;
|
|
672
724
|
const windows = [];
|
|
673
725
|
for (const [at, layer] of row.layers.entries()) {
|
|
@@ -685,7 +737,7 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
685
737
|
}
|
|
686
738
|
}
|
|
687
739
|
yield* ahead({
|
|
688
|
-
bucket: windows.length,
|
|
740
|
+
bucket: index.held ? 0 : windows.length,
|
|
689
741
|
store: 0
|
|
690
742
|
});
|
|
691
743
|
let sending = 0;
|
|
@@ -723,9 +775,11 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
723
775
|
ranges,
|
|
724
776
|
layers: row.layers,
|
|
725
777
|
listed: source.listed,
|
|
726
|
-
bucket:
|
|
778
|
+
bucket: index.bucket,
|
|
727
779
|
read,
|
|
728
|
-
ahead
|
|
780
|
+
ahead,
|
|
781
|
+
bases: index.bases,
|
|
782
|
+
indexHeld: index.held
|
|
729
783
|
};
|
|
730
784
|
if (filter?.kind === "blob:limit") {
|
|
731
785
|
listInput.blobsUnder = filter.bytes;
|
|
@@ -777,7 +831,7 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
777
831
|
return restIds.has(oid) || position !== 4294967295 && isSet(send, position);
|
|
778
832
|
}));
|
|
779
833
|
}),
|
|
780
|
-
deepened
|
|
834
|
+
deepened: withRootsSent(deepened, rootsSent)
|
|
781
835
|
};
|
|
782
836
|
});
|
|
783
|
-
export { fetchOpenCalls, indexEligible, indexSendSet };
|
|
837
|
+
export { fetchOpenCalls, indexEligible, indexPath, indexSendSet, keptRangeBytes };
|
|
@@ -201,12 +201,17 @@ const codes = (bytes, skip, count) => {
|
|
|
201
201
|
}
|
|
202
202
|
return codes;
|
|
203
203
|
};
|
|
204
|
-
/**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
/**
|
|
205
|
+
* The `.bases` at `key` opened: its header, then its block index. Given the `deltas` its index row
|
|
206
|
+
* lists, it reads both at once (#2523), and fails as lost when the header lists other.
|
|
207
|
+
*/
|
|
208
|
+
const openBases = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, positions, listed) {
|
|
208
209
|
const count = Math.ceil(positions / basesBlock);
|
|
209
|
-
const
|
|
210
|
+
const blockIndex = (deltas) => readExactly(bucket, key, 16 + deltas * 8, count * 4);
|
|
211
|
+
const [head, early] = listed === void 0 ? [yield* readExactly(bucket, key, 0, 16), void 0] : yield* Effect.all([readExactly(bucket, key, 0, 16), blockIndex(listed)], { concurrency: "unbounded" });
|
|
212
|
+
const deltas = (yield* checkHeader(key, head, basesMagic, positions)).getUint32(12);
|
|
213
|
+
if (listed !== void 0 && deltas !== listed) return yield* Effect.fail(lost(`${key} holds ${deltas} deltas, its index row ${listed}`));
|
|
214
|
+
const indexed = early ?? (yield* blockIndex(deltas));
|
|
210
215
|
const blocks = new DataView(indexed.buffer, indexed.byteOffset, indexed.byteLength);
|
|
211
216
|
const firstOf = (block) => block >= count ? deltas : blocks.getUint32(block * 4);
|
|
212
217
|
return {
|
|
@@ -8,6 +8,7 @@ import { graphMagic } from "../protocol/packs/graph.mjs";
|
|
|
8
8
|
import { PackTransportError, boundedSource, packReadBytes } from "../protocol/packs/reader.mjs";
|
|
9
9
|
import { bucketStream } from "./calls.mjs";
|
|
10
10
|
import { startPut } from "./merge.mjs";
|
|
11
|
+
import { keepUnclosed } from "./index-bitmaps.mjs";
|
|
11
12
|
import { readExactly } from "./pack-ranges.mjs";
|
|
12
13
|
import { compareIds, idsBytes, orderById } from "./raw-ids.mjs";
|
|
13
14
|
import * as Effect from "effect/Effect";
|
|
@@ -126,7 +127,7 @@ const same = (a, b) => a.length === b.length && a.every((byte, at) => byte === b
|
|
|
126
127
|
* as the file passes it, and a file that ends short of it is refused once its trailer is read.
|
|
127
128
|
*/
|
|
128
129
|
const openPackGraph = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, size) {
|
|
129
|
-
const source = yield* Effect.
|
|
130
|
+
const source = yield* Effect.uninterruptible(Effect.flatMap(bucketStream(bucket, key), (body) => {
|
|
130
131
|
if (body === void 0) return Effect.fail(lost(`${key} is missing`));
|
|
131
132
|
const opened = boundedSource(body, /* @__PURE__ */ new Uint8Array(0), new BufferMeter(graphPieceBytes));
|
|
132
133
|
return Effect.as(Effect.addFinalizer(() => opened.cancel), opened);
|
|
@@ -656,8 +657,36 @@ const generationsBelow = /* @__PURE__ */ Effect.fnUntraced(function* (below, ref
|
|
|
656
657
|
});
|
|
657
658
|
/** Commits a chunked read of the graph takes at a time: 640 KiB of IDs. */
|
|
658
659
|
const graphChunk = 32768;
|
|
659
|
-
/**
|
|
660
|
-
|
|
660
|
+
/**
|
|
661
|
+
* What a graph of `commits` keeps of its IDs with `keepIds`: one chunk, its last read, 20 B a
|
|
662
|
+
* commit. The caller charges it before the open.
|
|
663
|
+
*/
|
|
664
|
+
const keptIdsBytes = (commits) => Math.min(commits, graphChunk) * 20;
|
|
665
|
+
/** A `KeptIds` that holds nothing yet: `keptIdsBytes` at most, its maker's to charge. */
|
|
666
|
+
const keptIdsOf = () => {
|
|
667
|
+
let kept;
|
|
668
|
+
let dropped = false;
|
|
669
|
+
return {
|
|
670
|
+
at: (from) => kept?.from === from ? kept.bytes : void 0,
|
|
671
|
+
keep: (from, bytes) => {
|
|
672
|
+
if (!dropped) kept = {
|
|
673
|
+
from,
|
|
674
|
+
bytes
|
|
675
|
+
};
|
|
676
|
+
},
|
|
677
|
+
drop: () => {
|
|
678
|
+
kept = void 0;
|
|
679
|
+
dropped = true;
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
};
|
|
683
|
+
/**
|
|
684
|
+
* The index graph at `key`, opened: its header and fanout. A layer's commits start at `first`.
|
|
685
|
+
* With `keepIds`, the last chunk of IDs a lookup read is kept, so the next lookup in it reads none
|
|
686
|
+
* (#2523): `keptIdsBytes` at most, the caller's to charge. With `kept`, it's kept there, for a
|
|
687
|
+
* caller that lets it go before the graph's end.
|
|
688
|
+
*/
|
|
689
|
+
const openIndexGraph = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, first = 0, { keepIds = false, kept } = {}) {
|
|
661
690
|
const head = yield* readExactly(bucket, key, 0, 1040);
|
|
662
691
|
if (magic.some((byte, at) => head[at] !== byte) || word(head, 4) !== 1) return yield* Effect.fail(lost(`${key} isn't a version 1 graph`));
|
|
663
692
|
const commits = word(head, 8);
|
|
@@ -741,13 +770,22 @@ const openIndexGraph = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key,
|
|
|
741
770
|
rows: yield* rowsAt(from, count)
|
|
742
771
|
};
|
|
743
772
|
});
|
|
773
|
+
const keptIds = kept ?? (keepIds ? keptIdsOf() : void 0);
|
|
774
|
+
const idsChunk = (from, length) => {
|
|
775
|
+
const found = keptIds?.at(from);
|
|
776
|
+
if (found !== void 0) return Effect.succeed(found);
|
|
777
|
+
return Effect.map(readExactly(bucket, key, ids + from * 20, length * 20), (bytes) => {
|
|
778
|
+
keptIds?.keep(from, bytes);
|
|
779
|
+
return bytes;
|
|
780
|
+
});
|
|
781
|
+
};
|
|
744
782
|
const numbersOf = Effect.fnUntraced(function* (wanted, count) {
|
|
745
783
|
const order = orderById(wanted, count);
|
|
746
784
|
const out = new Uint32Array(count).fill(absent);
|
|
747
785
|
let next = 0;
|
|
748
786
|
for (let from = 0; from < commits && next < count; from += graphChunk) {
|
|
749
787
|
const length = Math.min(graphChunk, commits - from);
|
|
750
|
-
const chunk = yield*
|
|
788
|
+
const chunk = yield* idsChunk(from, length);
|
|
751
789
|
let at = 0;
|
|
752
790
|
while (next < count && at < length) {
|
|
753
791
|
const each = order[next] ?? 0;
|
|
@@ -775,7 +813,7 @@ const openIndexGraph = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key,
|
|
|
775
813
|
const local = number - first;
|
|
776
814
|
const from = local - local % graphChunk;
|
|
777
815
|
const length = Math.min(graphChunk, commits - from);
|
|
778
|
-
const chunk = yield* readExactly(bucket, key, start + from * width, length * width);
|
|
816
|
+
const chunk = start === ids && width === 20 ? yield* idsChunk(from, length) : yield* readExactly(bucket, key, start + from * width, length * width);
|
|
779
817
|
for (; next < order.length; next += 1) {
|
|
780
818
|
const place = order[next] ?? 0;
|
|
781
819
|
const at = (numbers[place] ?? 0) - first - from;
|
|
@@ -921,11 +959,12 @@ const layerCursor = (graph) => {
|
|
|
921
959
|
};
|
|
922
960
|
/**
|
|
923
961
|
* Each commit of `graphs` in ID order, each ID once, to `each`: its merged number, the oldest
|
|
924
|
-
* layer's copy of it, and every layer's
|
|
962
|
+
* layer's copy of it, and every layer's; but an ID `drops` names, which takes no number. It
|
|
963
|
+
* answers how many it gave.
|
|
925
964
|
*/
|
|
926
|
-
const eachMerged = /* @__PURE__ */ Effect.fnUntraced(function* (graphs, each) {
|
|
965
|
+
const eachMerged = /* @__PURE__ */ Effect.fnUntraced(function* (graphs, each, drops) {
|
|
927
966
|
const cursors = graphs.map(layerCursor);
|
|
928
|
-
for (let number = 0;;
|
|
967
|
+
for (let number = 0;;) {
|
|
929
968
|
const heads = [];
|
|
930
969
|
for (const cursor of cursors) {
|
|
931
970
|
const head = yield* cursor.head;
|
|
@@ -939,8 +978,10 @@ const eachMerged = /* @__PURE__ */ Effect.fnUntraced(function* (graphs, each) {
|
|
|
939
978
|
if (least === void 0) return number;
|
|
940
979
|
const taken = least;
|
|
941
980
|
const holding = heads.filter(({ head }) => compareIds(head.ids, head.offset, taken.ids, taken.offset) === 0);
|
|
942
|
-
const
|
|
981
|
+
const given = drops?.(taken.ids, taken.offset) !== true;
|
|
982
|
+
const step = given ? each(number, taken, holding.map(({ head }) => head)) : void 0;
|
|
943
983
|
if (step !== void 0) yield* step;
|
|
984
|
+
if (given) number += 1;
|
|
944
985
|
for (const { advance } of holding) advance();
|
|
945
986
|
}
|
|
946
987
|
});
|
|
@@ -958,13 +999,14 @@ const mergeHeldBytes = (layers) => layers * graphChunk * 44 + mostParents * 8 +
|
|
|
958
999
|
/**
|
|
959
1000
|
* `input.graphs`, layers of one index, merged into one index graph at `input.key`, numbered from 0
|
|
960
1001
|
* as `writeIndexGraph` numbers a whole one: every commit once in ID order, an ID two layers hold
|
|
961
|
-
* taken from the oldest, its parents renumbered, its octopus list carried and its generation kept
|
|
962
|
-
*
|
|
1002
|
+
* taken from the oldest, its parents renumbered, its octopus list carried and its generation kept;
|
|
1003
|
+
* but a commit `input.drops` names, left out, which keeps every kept commit's generation, since a
|
|
1004
|
+
* commit's ancestors are kept with it. The first pass numbers the commits and counts them, the next three write the IDs, the rows and
|
|
963
1005
|
* the octopus table. It holds each layer commit's merged number, 4 bytes each, and
|
|
964
1006
|
* `mergeHeldBytes`, charged to `input.allotment`, and never a layer whole.
|
|
965
1007
|
*/
|
|
966
1008
|
const mergeIndexGraphs = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
967
|
-
const { bucket, graphs, key, allotment } = input;
|
|
1009
|
+
const { bucket, graphs, key, allotment, drops } = input;
|
|
968
1010
|
let total = 0;
|
|
969
1011
|
for (const graph of graphs) {
|
|
970
1012
|
if (graph.first !== total) return yield* Effect.die(/* @__PURE__ */ new Error(`a layer starts at ${graph.first}, not ${total}`));
|
|
@@ -972,7 +1014,7 @@ const mergeIndexGraphs = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
972
1014
|
}
|
|
973
1015
|
const bytes = total * 4 + mergeHeldBytes(graphs.length);
|
|
974
1016
|
yield* allotment.grow(bytes);
|
|
975
|
-
const merged = new Uint32Array(total);
|
|
1017
|
+
const merged = new Uint32Array(total).fill(none);
|
|
976
1018
|
const counts = /* @__PURE__ */ new Uint32Array(256);
|
|
977
1019
|
let octopus = 0;
|
|
978
1020
|
const commits = yield* eachMerged(graphs, (number, taken, holders) => {
|
|
@@ -983,28 +1025,36 @@ const mergeIndexGraphs = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
983
1025
|
return list === void 0 ? void 0 : Effect.map(list, (parents) => {
|
|
984
1026
|
octopus += parents.length;
|
|
985
1027
|
});
|
|
986
|
-
});
|
|
1028
|
+
}, drops);
|
|
987
1029
|
if (commits >= mostCommits) return yield* Effect.fail(gitError("RESOURCE_EXHAUSTED", `The index layers' ${commits} commits are past the ${mostCommits} a graph numbers`));
|
|
988
1030
|
const started = yield* startGraph(bucket, key, commits, octopus, counts);
|
|
989
|
-
if ((yield* eachMerged(graphs, (_, taken) => started.out.push(taken.ids.subarray(taken.offset, taken.offset + 20)))) !== commits) return yield* Effect.fail(lost("The index layers changed while they were merged"));
|
|
1031
|
+
if ((yield* eachMerged(graphs, (_, taken) => started.out.push(taken.ids.subarray(taken.offset, taken.offset + 20)), drops)) !== commits) return yield* Effect.fail(lost("The index layers changed while they were merged"));
|
|
990
1032
|
const renumbered = (parent) => parent === 2147483647 ? none : merged[parent] ?? 2147483647;
|
|
1033
|
+
const unclosed = (taken, parents) => Array.from(parents).some((parent) => parent !== 2147483647 && renumbered(parent) === 2147483647) ? Effect.fail(keepUnclosed(`The commit ${hexOf(taken.ids.subarray(taken.offset, taken.offset + 20))} keeps a parent the merge dropped`)) : Effect.void;
|
|
991
1034
|
const row = /* @__PURE__ */ new Uint32Array(3);
|
|
992
1035
|
let tableAt = 0;
|
|
993
1036
|
yield* eachMerged(graphs, (_, taken) => Effect.gen(function* () {
|
|
994
1037
|
const list = octopusOf(taken);
|
|
995
|
-
|
|
1038
|
+
const first = taken.rows[taken.row] ?? 2147483647;
|
|
1039
|
+
row[0] = renumbered(first);
|
|
996
1040
|
row[2] = taken.rows[taken.row + 2] ?? 0;
|
|
997
|
-
if (list === void 0)
|
|
998
|
-
|
|
1041
|
+
if (list === void 0) {
|
|
1042
|
+
const second = taken.rows[taken.row + 1] ?? 2147483647;
|
|
1043
|
+
row[1] = renumbered(second);
|
|
1044
|
+
yield* unclosed(taken, [first, second]);
|
|
1045
|
+
} else {
|
|
1046
|
+
const parents = yield* list;
|
|
999
1047
|
row[1] = octopusTarget(tableAt);
|
|
1000
|
-
tableAt +=
|
|
1048
|
+
tableAt += parents.length;
|
|
1049
|
+
yield* unclosed(taken, [first, ...parents]);
|
|
1001
1050
|
}
|
|
1002
1051
|
yield* started.out.words(row);
|
|
1003
|
-
}));
|
|
1052
|
+
}), drops);
|
|
1004
1053
|
if (octopus > 0) yield* eachMerged(graphs, (_, taken) => {
|
|
1005
1054
|
const list = octopusOf(taken);
|
|
1006
1055
|
return list === void 0 ? void 0 : Effect.flatMap(list, (parents) => started.out.words(parents, (parent, at) => at === parents.length - 1 ? (renumbered(parent) | lastFlag) >>> 0 : renumbered(parent)));
|
|
1007
|
-
});
|
|
1056
|
+
}, drops);
|
|
1057
|
+
if (input.beforeFinish !== void 0) yield* input.beforeFinish(renumbered);
|
|
1008
1058
|
yield* started.finish;
|
|
1009
1059
|
allotment.shrink(bytes);
|
|
1010
1060
|
return { commits };
|
|
@@ -1106,4 +1156,4 @@ var ByGeneration = class {
|
|
|
1106
1156
|
return top;
|
|
1107
1157
|
}
|
|
1108
1158
|
};
|
|
1109
|
-
export { ByGeneration, absent, gathered, graphChunk, graphRefs, graphRows, graphSourceBytes, graphTooLarge, graphTooWide, graphsTooMany, indexGraphBytes, lastFlag, mergeHeldBytes, mergeIndexGraphs, none, octopusFlag, openGraphLayers, openIndexGraph, openPackGraph, writeIndexGraph };
|
|
1159
|
+
export { ByGeneration, absent, gathered, graphChunk, graphRefs, graphRows, graphSourceBytes, graphTooLarge, graphTooWide, graphsTooMany, indexGraphBytes, keptIdsBytes, keptIdsOf, lastFlag, mergeHeldBytes, mergeIndexGraphs, none, octopusFlag, openGraphLayers, openIndexGraph, openPackGraph, writeIndexGraph };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
1
2
|
import { bitmapWords } from "./ewah.mjs";
|
|
2
|
-
import { builtIndexOf, coversAll, decodeIndexValue } from "./index-build.mjs";
|
|
3
|
+
import { builtIndexOf, builtOver, coversAll, decodeIndexValue } from "./index-build.mjs";
|
|
3
4
|
import { hasBit, idsOf, openLayerBitmaps, openLayout, orIntoAtOnce, orIntoBytes, orIntoFiles, orWords, reachOf, whileFollowed } from "./index-layers.mjs";
|
|
4
5
|
import { readReserveBytes } from "./budget.mjs";
|
|
5
6
|
import { missing } from "./link-join.mjs";
|
|
@@ -148,14 +149,18 @@ const outsideOf = /* @__PURE__ */ Effect.fnUntraced(function* (input, tips, most
|
|
|
148
149
|
closed: true
|
|
149
150
|
};
|
|
150
151
|
});
|
|
151
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Whether `row` names a built index that covers `listed`, so a reach of it may answer: `tipsReach`
|
|
154
|
+
* still walks past one built over other roots.
|
|
155
|
+
*/
|
|
152
156
|
const indexCovers = (input, listed) => {
|
|
153
157
|
const built = builtIndexOf(decodeIndexValue(input.row));
|
|
154
158
|
return built !== void 0 && coversAll(built.layers, listed);
|
|
155
159
|
};
|
|
156
160
|
/**
|
|
157
161
|
* What `input.tips` reach, by the index `input.row` names over `listed`, or `undefined` when it
|
|
158
|
-
* doesn't cover `listed`, as after a repack took a covered pack out,
|
|
162
|
+
* doesn't cover `listed`, as after a repack took a covered pack out, or was built over other
|
|
163
|
+
* roots than `input.roots`, for the caller's walk. A tip
|
|
159
164
|
* whose reach won't close within `most` sets `pastLimit`. Where `unclosed`, so does one whose walk
|
|
160
165
|
* meets an object past the bytes it may follow at once, which a fetch's want check refuses as
|
|
161
166
|
* `levelTooLarge`: a visible set still shows its tips, and what their bitmaps reach. Its walks
|
|
@@ -168,7 +173,7 @@ const tipsReach = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
|
|
|
168
173
|
tooLarge = true;
|
|
169
174
|
})) : walk;
|
|
170
175
|
const built = builtIndexOf(decodeIndexValue(input.row));
|
|
171
|
-
if (built === void 0 || !coversAll(built.layers, listed)) return void 0;
|
|
176
|
+
if (built === void 0 || !builtOver(built, input.roots) || !coversAll(built.layers, listed)) return void 0;
|
|
172
177
|
const last = built.layers[built.layers.length - 1];
|
|
173
178
|
const words = bitmapWords(last === void 0 ? 0 : last.first + last.positions);
|
|
174
179
|
const files = orIntoFiles(built.layers);
|
|
@@ -284,6 +289,29 @@ const reachAnswers = /* @__PURE__ */ Effect.fnUntraced(function* (reach, wants,
|
|
|
284
289
|
return answers;
|
|
285
290
|
});
|
|
286
291
|
/**
|
|
292
|
+
* Which of `input.roots` the tips reach, by the index `input.row` names over `listed`: each root
|
|
293
|
+
* whose position a layer keeps that the tips' union holds, and each the walk outside the index
|
|
294
|
+
* met. A root's ID is read only where the union holds it, so one the tips don't reach, as one only
|
|
295
|
+
* a hidden ref reaches, costs no call, as a fetch's `rootsSent` reads them (#2462). `undefined`
|
|
296
|
+
* where the index can't give the walk's answer: none covers `listed`, it's over other roots, or
|
|
297
|
+
* a tip's reach won't close.
|
|
298
|
+
*/
|
|
299
|
+
const reachedRoots = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, input) {
|
|
300
|
+
const built = builtIndexOf(decodeIndexValue(input.row));
|
|
301
|
+
if (built === void 0) return void 0;
|
|
302
|
+
const reach = yield* tipsReach(parts, listed, input);
|
|
303
|
+
if (reach === void 0 || reach.pastLimit !== void 0) return void 0;
|
|
304
|
+
const roots = input.roots ?? /* @__PURE__ */ new Set();
|
|
305
|
+
const reached = /* @__PURE__ */ new Set();
|
|
306
|
+
for (const layer of built.layers) for (const position of layer.roots ?? []) {
|
|
307
|
+
if (!hasBit(reach.union, position)) continue;
|
|
308
|
+
const root = hexOf(yield* reach.layout.idAt(position));
|
|
309
|
+
if (roots.has(root)) reached.add(root);
|
|
310
|
+
}
|
|
311
|
+
for (const root of roots) if (reach.outside?.has(root) === true) reached.add(root);
|
|
312
|
+
return reached;
|
|
313
|
+
}, Effect.scoped);
|
|
314
|
+
/**
|
|
287
315
|
* Which of `input.wants` the tips reach, by the index `input.row` names over `listed`, as
|
|
288
316
|
* `reachAnswers` says. A tip whose reach won't close within `most` leaves the wants it doesn't
|
|
289
317
|
* show reached unanswered and sets `pastLimit`, and its caller refuses them alike. An index that
|
|
@@ -321,4 +349,4 @@ const wantsBy = /* @__PURE__ */ Effect.fnUntraced(function* (reach, wants) {
|
|
|
321
349
|
updatesRefused
|
|
322
350
|
};
|
|
323
351
|
});
|
|
324
|
-
export { ReachCache, indexCovers, indexReach, reachAnswers, reachCacheBytes, tipsReach, wantsBy };
|
|
352
|
+
export { ReachCache, indexCovers, indexReach, reachAnswers, reachCacheBytes, reachedRoots, tipsReach, wantsBy };
|