@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
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A receive's largest blobs, as they're settled: a blob no larger than the smallest of a full list
|
|
3
|
+
* costs one compare, so a push of many small files keeps nothing.
|
|
4
|
+
*/
|
|
5
|
+
var LargestFiles = class {
|
|
6
|
+
#kept = [];
|
|
7
|
+
#least = 0;
|
|
8
|
+
#partial = false;
|
|
9
|
+
/** A list going on from `from`, what a receive's step before this one kept. */
|
|
10
|
+
constructor(from) {
|
|
11
|
+
if (from === void 0) return;
|
|
12
|
+
this.#kept.push(...from.largest);
|
|
13
|
+
this.#partial = from.largestPartial === true;
|
|
14
|
+
this.#least = this.#kept.at(-1)?.size ?? 0;
|
|
15
|
+
}
|
|
16
|
+
add(oid, size) {
|
|
17
|
+
const kept = this.#kept;
|
|
18
|
+
if (kept.length === 64 && size <= this.#least) {
|
|
19
|
+
this.#partial = true;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
kept.push({
|
|
23
|
+
oid,
|
|
24
|
+
size
|
|
25
|
+
});
|
|
26
|
+
kept.sort((a, b) => b.size - a.size);
|
|
27
|
+
if (kept.length > 64) {
|
|
28
|
+
kept.pop();
|
|
29
|
+
this.#partial = true;
|
|
30
|
+
}
|
|
31
|
+
this.#least = kept.at(-1)?.size ?? 0;
|
|
32
|
+
}
|
|
33
|
+
/** The list, largest first, and `largestPartial` when it left a blob out. */
|
|
34
|
+
finish() {
|
|
35
|
+
const largest = [...this.#kept];
|
|
36
|
+
return this.#partial ? {
|
|
37
|
+
largest,
|
|
38
|
+
largestPartial: true
|
|
39
|
+
} : { largest };
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
/** The largest of `objects`' blobs, as `LargestFiles` keeps them: a receive kept as rows. */
|
|
43
|
+
const largestOf = (objects) => {
|
|
44
|
+
const largest = new LargestFiles();
|
|
45
|
+
for (const object of objects) if (object.type === "blob") largest.add(object.oid, "size" in object ? object.size : object.bytes.byteLength);
|
|
46
|
+
return largest.finish();
|
|
47
|
+
};
|
|
48
|
+
export { LargestFiles, largestOf };
|
package/dist/storage/layout.mjs
CHANGED
|
@@ -15,6 +15,29 @@ const objectCollections = {
|
|
|
15
15
|
cover: "cover",
|
|
16
16
|
/** One object as a row, by its ID: every object `loose()` holds, and a small push's. */
|
|
17
17
|
objects: "objects",
|
|
18
|
+
/**
|
|
19
|
+
* A large push's object rows, staged apart before its commit, by `<batch>/<oid>`: an `ObjectRow`,
|
|
20
|
+
* read beside `objects` once its batch is published, until upkeep promotes it there.
|
|
21
|
+
*/
|
|
22
|
+
stagedObjects: "stagedObjects",
|
|
23
|
+
/**
|
|
24
|
+
* The value size in bytes of each staged object row, by `<batch>/<oid>`: `{ bytes }`, written in
|
|
25
|
+
* the same staging add as its row and deleted with it by promotion or sweep, so readers pack body
|
|
26
|
+
* reads by size without reading duplicate copies (#2521).
|
|
27
|
+
*/
|
|
28
|
+
stagedSizes: "stagedSizes",
|
|
29
|
+
/**
|
|
30
|
+
* A chunked object's bytes, by `<batch>/<part>/<nnnn>`: `{ data }`, `chunkRawBytes` of them as
|
|
31
|
+
* base64, named by the object's `ChunkedRow`. They stay under the batch that staged them.
|
|
32
|
+
*/
|
|
33
|
+
objectChunks: "objectChunks",
|
|
34
|
+
/** A published staged batch, by its ID: `BatchRow`, deleted once upkeep has promoted its rows. */
|
|
35
|
+
batches: "batches",
|
|
36
|
+
/**
|
|
37
|
+
* A staged batch being received, by its ID, added before its first row: a `QuarantineRow`, ended
|
|
38
|
+
* by the commit that publishes the batch, or abandoned and, once its rows are swept, deleted.
|
|
39
|
+
*/
|
|
40
|
+
batchQuarantine: "batchQuarantine",
|
|
18
41
|
/** A cruft pack, by its ID: when a prune pass found its objects unreached, `CruftRow`. */
|
|
19
42
|
cruft: "cruft",
|
|
20
43
|
/** The last prune pass, `pass`: when it ran, `PrunePass`. */
|
|
@@ -209,9 +209,18 @@ var ReceivedPointers = class {
|
|
|
209
209
|
};
|
|
210
210
|
/** At a step's end, the pointers `found` as their table holds them, for the next step's `carried`. */
|
|
211
211
|
const pointersRecords = (found) => LfsPointers.pagesOf(found).map((page, at) => page.subarray(0, Math.min(pageEntries, found.count - at * pageEntries) * 57));
|
|
212
|
+
/**
|
|
213
|
+
* One page `pointersRecords` gave, read as pointers again, as import keeps them between its
|
|
214
|
+
* segments and its copy: `undefined` for bytes that aren't whole entries, or more than a page.
|
|
215
|
+
*/
|
|
216
|
+
const pointersOfRecord = (record) => {
|
|
217
|
+
const count = record.byteLength / 57;
|
|
218
|
+
if (!Number.isInteger(count) || count > 1024) return void 0;
|
|
219
|
+
return LfsPointers.made(count, [record]);
|
|
220
|
+
};
|
|
212
221
|
/** The pointers among a receive's whole objects, found by `pointers`. */
|
|
213
222
|
const pointersOfObjects = /* @__PURE__ */ Effect.fnUntraced(function* (objects, pointers = new ReceivedPointers()) {
|
|
214
223
|
for (const object of objects) if (object.type === "blob") yield* pointers.add(object.oid, object.bytes);
|
|
215
224
|
return pointers.finish();
|
|
216
225
|
});
|
|
217
|
-
export { ReceivedPointers, lfsOidAt, lfsPointers, lfsPointersMost, lfsSizeAt, noLfsPointers, pageEntries, pointerSizeMost, pointersOfBlob, pointersOfObjects, pointersRecords };
|
|
226
|
+
export { ReceivedPointers, lfsOidAt, lfsPointers, lfsPointersMost, lfsSizeAt, noLfsPointers, pageEntries, pointerSizeMost, pointersOfBlob, pointersOfObjects, pointersOfRecord, pointersRecords };
|
package/dist/storage/loose.d.mts
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import { ObjectsFactory } from "../contracts/objects.mjs";
|
|
2
2
|
/**
|
|
3
|
-
* What one push may carry into `loose()` storage: its `objects`,
|
|
4
|
-
*
|
|
3
|
+
* What one push may carry into `loose()` storage: its `objects`, the `bytes` of its rows as JSON,
|
|
4
|
+
* which its commit holds, and the bytes of each object, `fileBytes`, one past a row kept as chunks.
|
|
5
5
|
*/
|
|
6
6
|
export declare const looseLimits: {
|
|
7
7
|
readonly objects: 10000;
|
|
8
8
|
readonly bytes: number;
|
|
9
|
+
readonly fileBytes: number;
|
|
9
10
|
};
|
|
10
11
|
/** What one push may carry into `loose()` storage, each at most `looseLimits`' own. */
|
|
11
12
|
export interface LooseLimits {
|
|
12
13
|
readonly objects?: number;
|
|
13
14
|
readonly bytes?: number;
|
|
15
|
+
readonly fileBytes?: number;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* `loose()`: each object a row of the repo's scope, with no bucket. A push of more than
|
|
17
19
|
* `options.objects` objects, 10,000 by default, is refused whole, and so is one whose rows pass
|
|
18
|
-
* `options.bytes`, one commit's 8 MiB by default,
|
|
19
|
-
*
|
|
20
|
+
* `options.bytes`, one commit's 8 MiB by default, of rows within one row's 1 MiB. An object past
|
|
21
|
+
* one row is kept as chunk rows, to `options.fileBytes`, 32 MiB by default, and one past that is
|
|
22
|
+
* refused as `object-too-large`. A whole push names its roots and the rows it links to, so it can
|
|
20
23
|
* keep a repo's whole-clone mark. The client's default.
|
|
21
24
|
*/
|
|
22
25
|
export declare const loose: (options?: LooseLimits) => ObjectsFactory<false>;
|
package/dist/storage/loose.mjs
CHANGED
|
@@ -1,28 +1,51 @@
|
|
|
1
|
+
import { streamThen } from "../protocol/bytes/streams.mjs";
|
|
1
2
|
import { handingOn } from "../protocol/packs/writer.mjs";
|
|
2
3
|
import { newChangeId } from "../store/scopes.mjs";
|
|
3
4
|
import { callScope } from "../store/call-count.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { cancelsBody, objectReader } from "./calls.mjs";
|
|
5
6
|
import { fetchPack } from "./fetch.mjs";
|
|
6
7
|
import { pushedCommitsPage } from "./pushed-commits.mjs";
|
|
7
|
-
import { copyRowsPage, eachHeldRow, gitObjectOf, heldRows, rowHeaders, rowSizes, rowsStartingWith, startingOf } from "./object-rows.mjs";
|
|
8
|
+
import { copyRowsPage, eachHeldRow, gitObjectOf, heldRows, readsOwnChunks, rowHeaders, rowSizes, rowsStartingWith, startingOf } from "./object-rows.mjs";
|
|
8
9
|
import { allotmentWithin } from "../contracts/object-values.mjs";
|
|
9
10
|
import { allottedRows } from "./allotted.mjs";
|
|
11
|
+
import { looseUpkeep } from "./batch-upkeep.mjs";
|
|
12
|
+
import { abandonBatch, openBatch, rowsChange } from "./batches.mjs";
|
|
13
|
+
import { allottableOf, defaultMemory, readReserveBytes } from "./budget.mjs";
|
|
14
|
+
import { ChunkReader, chunkRawBytes, chunkedReadBytes, chunkedRow, fitsRow, stageChunk } from "./chunks.mjs";
|
|
15
|
+
import { MemoryBudget } from "./memory-budget.mjs";
|
|
10
16
|
import { pointersOfObjects } from "./lfs-pointers.mjs";
|
|
17
|
+
import { largestOf } from "./largest-files.mjs";
|
|
11
18
|
import { wholeRoots } from "./roots.mjs";
|
|
12
19
|
import { commitBytes, unpackObjects } from "./unpack.mjs";
|
|
13
20
|
import { gitError } from "../contracts/result.mjs";
|
|
21
|
+
import * as Clock from "effect/Clock";
|
|
14
22
|
import * as Effect from "effect/Effect";
|
|
23
|
+
import * as Exit from "effect/Exit";
|
|
24
|
+
import * as Scope from "effect/Scope";
|
|
15
25
|
// src/storage/loose.ts
|
|
16
26
|
/** The most objects one push may carry into `loose()` storage, each a row of its commit. */
|
|
17
27
|
const looseObjectsMost = 1e4;
|
|
28
|
+
/** The bytes one object takes in `loose()` storage at most, as Cloudflare Artifacts takes a file. */
|
|
29
|
+
const looseFileBytesMost = 33554432;
|
|
18
30
|
/**
|
|
19
|
-
* What one push may carry into `loose()` storage: its `objects`,
|
|
20
|
-
*
|
|
31
|
+
* What one push may carry into `loose()` storage: its `objects`, the `bytes` of its rows as JSON,
|
|
32
|
+
* which its commit holds, and the bytes of each object, `fileBytes`, one past a row kept as chunks.
|
|
21
33
|
*/
|
|
22
34
|
const looseLimits = {
|
|
23
35
|
objects: looseObjectsMost,
|
|
24
|
-
bytes: commitBytes
|
|
36
|
+
bytes: commitBytes,
|
|
37
|
+
fileBytes: looseFileBytesMost
|
|
25
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* The bytes a push's objects past one row take in all, a delta's results among them: eight of the
|
|
41
|
+
* largest. Without it, a pack of small deltas, each making a large object, could make gigabytes.
|
|
42
|
+
*/
|
|
43
|
+
const largeBytesMost = 8 * looseFileBytesMost;
|
|
44
|
+
/**
|
|
45
|
+
* What a receive holds before any object past a row: its entries, their objects read whole and
|
|
46
|
+
* their rows, each within `bytes`, its reader's buffers, and a chunk filling, waiting and encoded.
|
|
47
|
+
*/
|
|
48
|
+
const receiveFloorOf = (bytes) => 3 * bytes + 1048576 + 3 * chunkRawBytes;
|
|
26
49
|
/** `limits` checked, each a whole number from 1 to `looseLimits`' own, or a `RangeError`. */
|
|
27
50
|
const checkedLoose = (limits) => {
|
|
28
51
|
const each = (kind) => {
|
|
@@ -32,7 +55,8 @@ const checkedLoose = (limits) => {
|
|
|
32
55
|
};
|
|
33
56
|
return {
|
|
34
57
|
objects: each("objects"),
|
|
35
|
-
bytes: each("bytes")
|
|
58
|
+
bytes: each("bytes"),
|
|
59
|
+
fileBytes: each("fileBytes")
|
|
36
60
|
};
|
|
37
61
|
};
|
|
38
62
|
const tooMany = (most) => (count) => gitError("RESOURCE_EXHAUSTED", `push has ${count.toLocaleString("en-US")} objects; this server takes ${most.toLocaleString("en-US")} per push`, {
|
|
@@ -51,28 +75,63 @@ const received = /* @__PURE__ */ new WeakSet();
|
|
|
51
75
|
* as Git's HTTP does; `packs()`'s, whose small pushes are rows too, isn't one.
|
|
52
76
|
*/
|
|
53
77
|
const isLoose = (quarantine) => received.has(quarantine);
|
|
54
|
-
/**
|
|
55
|
-
|
|
78
|
+
/**
|
|
79
|
+
* A push's pack as rows for its commit, its objects past one row as chunks, in its memory's
|
|
80
|
+
* allotment of `budget`: no quarantine row within one commit's rows, and a batch's past them, or
|
|
81
|
+
* once its first chunk opens one. A receive that fails after it opened one abandons it.
|
|
82
|
+
*/
|
|
83
|
+
const receiveRows = (store, listed, receive, limits, budget) => Effect.scoped(Effect.gen(function* () {
|
|
84
|
+
const allotment = yield* budget.admit(receiveFloorOf(limits.bytes));
|
|
85
|
+
const { repo } = listed;
|
|
86
|
+
let opened;
|
|
87
|
+
const large = {
|
|
88
|
+
fileBytes: limits.fileBytes,
|
|
89
|
+
totalBytes: largeBytesMost,
|
|
90
|
+
stage: Effect.fnUntraced(function* (part, index, bytes) {
|
|
91
|
+
opened ??= yield* openBatch({
|
|
92
|
+
store,
|
|
93
|
+
repo,
|
|
94
|
+
at: yield* Clock.currentTimeMillis
|
|
95
|
+
});
|
|
96
|
+
yield* stageChunk(store, repo, opened, part, index, bytes);
|
|
97
|
+
}),
|
|
98
|
+
hold: (bytes) => allotment.grow(bytes),
|
|
99
|
+
staged: (object) => Effect.map(new ChunkReader(store, repo, object.oid, rowOf(object).value, () => Effect.succeed(void 0)).whole(), ({ bytes }) => bytes),
|
|
100
|
+
row: (object) => rowOf(object)
|
|
101
|
+
};
|
|
102
|
+
const rowOf = (object) => chunkedRow(object.oid, object.type, object.size, opened.batch, object.part);
|
|
103
|
+
return yield* receivedRows(store, listed, receive, limits, large, () => opened).pipe(Effect.onError(() => opened === void 0 ? Effect.void : abandonBatch(store, repo, opened.batch)));
|
|
104
|
+
}));
|
|
105
|
+
/** `receiveRows`' receive, its batch `opened()` once its first chunk is staged. */
|
|
106
|
+
const receivedRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed, receive, limits, large, opened) {
|
|
107
|
+
const heldWhole = heldRows(store, listed);
|
|
56
108
|
const unpacked = yield* unpackObjects({
|
|
57
109
|
receive,
|
|
58
110
|
limits,
|
|
59
111
|
tooMany: tooMany(limits.objects),
|
|
60
|
-
held:
|
|
61
|
-
|
|
112
|
+
held: Effect.fnUntraced(function* (oids) {
|
|
113
|
+
const chunked = [...(yield* rowHeaders(store, listed)(oids)).values()].filter(({ type, size }) => !fitsRow(type, size));
|
|
114
|
+
yield* large.hold(chunked.reduce((sum, { size }) => sum + size, 0));
|
|
115
|
+
return yield* heldWhole(oids);
|
|
116
|
+
}),
|
|
117
|
+
headers: rowHeaders(store, listed),
|
|
118
|
+
offsetDeltas: "resolve",
|
|
119
|
+
large
|
|
62
120
|
});
|
|
121
|
+
const staged = yield* rowsChange(store, listed.repo, unpacked.rows, unpacked.moved, opened());
|
|
122
|
+
readsOwnChunks(staged.change, (oid, chunked) => new ChunkReader(store, listed.repo, oid, chunked, () => Effect.succeed(void 0)));
|
|
63
123
|
const quarantine = {
|
|
64
124
|
id: newChangeId(),
|
|
65
|
-
change:
|
|
66
|
-
put: unpacked.rows,
|
|
67
|
-
rows: unpacked.moved
|
|
68
|
-
},
|
|
125
|
+
change: staged.change,
|
|
69
126
|
bytes: unpacked.bytes,
|
|
70
|
-
objects: unpacked.
|
|
71
|
-
lfsPointers: yield* pointersOfObjects(unpacked.objects)
|
|
127
|
+
objects: unpacked.count,
|
|
128
|
+
lfsPointers: yield* pointersOfObjects(unpacked.objects),
|
|
129
|
+
...largestOf([...unpacked.objects, ...unpacked.chunked])
|
|
72
130
|
};
|
|
73
131
|
if (unpacked.cut.length > 0) quarantine.cut = unpacked.cut;
|
|
132
|
+
if (staged.quarantine !== void 0) quarantine.quarantine = staged.quarantine;
|
|
74
133
|
received.add(quarantine);
|
|
75
|
-
const whole = receive.partial === true || receive.boundary !== void 0 ? void 0 : wholeRoots(unpacked.objects);
|
|
134
|
+
const whole = receive.partial === true || receive.boundary !== void 0 || unpacked.chunked.length > 0 ? void 0 : wholeRoots(unpacked.objects);
|
|
76
135
|
if (whole === void 0) return quarantine;
|
|
77
136
|
quarantine.roots = whole.roots;
|
|
78
137
|
if (whole.outside.length > 64) return quarantine;
|
|
@@ -83,15 +142,112 @@ const receiveRows = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed,
|
|
|
83
142
|
};
|
|
84
143
|
return quarantine;
|
|
85
144
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
145
|
+
/**
|
|
146
|
+
* What reading a chunked object of `size` bytes whole holds, allotted from `budget` before its
|
|
147
|
+
* first chunk, and handed to `own` in the step the allot ends in: held until its allotment's
|
|
148
|
+
* `release`, which no scope makes for it. The allot's scope is closed by its failure, so an
|
|
149
|
+
* interrupt or a refusal leaves nothing allotted that no one owns.
|
|
150
|
+
*/
|
|
151
|
+
const chunkedCharge = (budget, size, own) => Effect.uninterruptibleMask((restore) => Effect.flatMap(Scope.make(), (scope) => restore(Scope.provide(scope)(budget.allot(chunkedReadBytes(size)))).pipe(Effect.onError(() => Scope.close(scope, Exit.void)), Effect.map((allotment) => {
|
|
152
|
+
own(allotment);
|
|
153
|
+
return allotment;
|
|
154
|
+
}))));
|
|
155
|
+
/**
|
|
156
|
+
* A reader's charges for the chunked objects `objects` reads whole, each a `chunkedCharge`, held
|
|
157
|
+
* until `give` gives it back, or the reader's `release`.
|
|
158
|
+
*/
|
|
159
|
+
const readerCharges = (budget) => {
|
|
160
|
+
const held = /* @__PURE__ */ new Set();
|
|
161
|
+
const charge = (size) => chunkedCharge(budget, size, (allotment) => void held.add(allotment));
|
|
162
|
+
const give = (allotment) => {
|
|
163
|
+
held.delete(allotment);
|
|
164
|
+
allotment.release();
|
|
165
|
+
};
|
|
166
|
+
const release = () => {
|
|
167
|
+
for (const allotment of held) allotment.release();
|
|
168
|
+
held.clear();
|
|
169
|
+
};
|
|
170
|
+
return {
|
|
171
|
+
charge,
|
|
172
|
+
give,
|
|
173
|
+
release
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* `oid`'s object, or `undefined`. One kept as chunks is read whole once `budget` allots what that
|
|
178
|
+
* holds, and handed on as its body, uncopied, its charge given back once the body is read to its
|
|
179
|
+
* end or cancelled, as every caller does with a body it leaves: not at the reader's release, which
|
|
180
|
+
* comes before a caller streams the body on.
|
|
181
|
+
*/
|
|
182
|
+
const readObject = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed, oid, budget) {
|
|
183
|
+
const read = {};
|
|
184
|
+
const before = (_, size) => Effect.as(chunkedCharge(budget, size, (allotment) => void (read.charged = allotment)), true);
|
|
185
|
+
yield* eachHeldRow(store, listed, before)([oid], (object) => Effect.sync(() => void (read.object = object))).pipe(Effect.onError(() => Effect.sync(() => read.charged?.release())));
|
|
186
|
+
const { object, charged } = read;
|
|
187
|
+
if (object === void 0) return void 0;
|
|
188
|
+
if (charged === void 0) return gitObjectOf(object);
|
|
189
|
+
return {
|
|
190
|
+
oid: object.oid,
|
|
191
|
+
type: object.type,
|
|
192
|
+
size: object.bytes.byteLength,
|
|
193
|
+
bytes: streamThen(object.bytes, () => charged.release())
|
|
194
|
+
};
|
|
89
195
|
});
|
|
90
196
|
/**
|
|
197
|
+
* `before`, with each chunked object's bytes charged to `charges` first: given back if `before`
|
|
198
|
+
* leaves it, and held, if it keeps it, until the reader's release.
|
|
199
|
+
*/
|
|
200
|
+
const chargedFirst = (charges, before) => (oid, size) => Effect.flatMap(charges.charge(size), (allotment) => before(oid, size).pipe(Effect.tap((kept) => kept ? Effect.void : Effect.sync(() => charges.give(allotment))), Effect.onError(() => Effect.sync(() => charges.give(allotment)))));
|
|
201
|
+
/**
|
|
202
|
+
* A fetch's reads of `listed`'s rows. A chunked object is read whole, what that holds allotted
|
|
203
|
+
* from `budget` before its first chunk: for a window, until the writer's next window or the fetch's
|
|
204
|
+
* end, which `ended` gives back; for `each`, until its callback ends, so a walk past several holds
|
|
205
|
+
* one at a time.
|
|
206
|
+
*/
|
|
207
|
+
const fetchReads = (calls, listed, budget) => {
|
|
208
|
+
let window;
|
|
209
|
+
const ended = Effect.suspend(() => {
|
|
210
|
+
const open = window;
|
|
211
|
+
window = void 0;
|
|
212
|
+
return open === void 0 ? Effect.void : Scope.close(open, Exit.void);
|
|
213
|
+
});
|
|
214
|
+
const allotted = (scope) => (_, size) => Effect.as(Scope.provide(scope)(budget.allot(chunkedReadBytes(size))), true);
|
|
215
|
+
const held = Effect.fnUntraced(function* (oids) {
|
|
216
|
+
yield* ended;
|
|
217
|
+
const scope = yield* Scope.make();
|
|
218
|
+
window = scope;
|
|
219
|
+
const objects = /* @__PURE__ */ new Map();
|
|
220
|
+
yield* eachHeldRow(calls, listed, allotted(scope))(oids, (object) => Effect.sync(() => void objects.set(object.oid, object)));
|
|
221
|
+
return objects;
|
|
222
|
+
});
|
|
223
|
+
const each = (oids, take) => {
|
|
224
|
+
let open;
|
|
225
|
+
const closed = Effect.suspend(() => {
|
|
226
|
+
const scope = open;
|
|
227
|
+
open = void 0;
|
|
228
|
+
return scope === void 0 ? Effect.void : Scope.close(scope, Exit.void);
|
|
229
|
+
});
|
|
230
|
+
const before = (oid, size) => Effect.flatMap(closed, () => Effect.flatMap(Scope.make(), (scope) => {
|
|
231
|
+
open = scope;
|
|
232
|
+
return allotted(scope)(oid, size);
|
|
233
|
+
}));
|
|
234
|
+
return Effect.ensuring(eachHeldRow(calls, listed, before)(oids, (object) => Effect.ensuring(take(object), closed)), closed);
|
|
235
|
+
};
|
|
236
|
+
return {
|
|
237
|
+
reads: {
|
|
238
|
+
held,
|
|
239
|
+
each,
|
|
240
|
+
sizes: rowSizes(calls, listed)
|
|
241
|
+
},
|
|
242
|
+
ended
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
91
246
|
* `loose()`: each object a row of the repo's scope, with no bucket. A push of more than
|
|
92
247
|
* `options.objects` objects, 10,000 by default, is refused whole, and so is one whose rows pass
|
|
93
|
-
* `options.bytes`, one commit's 8 MiB by default,
|
|
94
|
-
*
|
|
248
|
+
* `options.bytes`, one commit's 8 MiB by default, of rows within one row's 1 MiB. An object past
|
|
249
|
+
* one row is kept as chunk rows, to `options.fileBytes`, 32 MiB by default, and one past that is
|
|
250
|
+
* refused as `object-too-large`. A whole push names its roots and the rows it links to, so it can
|
|
95
251
|
* keep a repo's whole-clone mark. The client's default.
|
|
96
252
|
*/
|
|
97
253
|
const loose = (options = {}) => {
|
|
@@ -99,59 +255,50 @@ const loose = (options = {}) => {
|
|
|
99
255
|
return {
|
|
100
256
|
needsBucket: false,
|
|
101
257
|
open: ({ store: calls, fetchLimits }) => {
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
258
|
+
const budget = new MemoryBudget(allottableOf(defaultMemory), readReserveBytes);
|
|
259
|
+
const openReader = (listed, scope, listedOnly) => {
|
|
260
|
+
const charges = readerCharges(budget);
|
|
261
|
+
return objectReader(listedOnly === true ? {
|
|
262
|
+
object: () => Effect.succeed(void 0),
|
|
263
|
+
sizes: () => Effect.succeed(/* @__PURE__ */ new Map()),
|
|
264
|
+
headers: () => Effect.succeed(/* @__PURE__ */ new Map()),
|
|
265
|
+
has: () => Effect.succeed(/* @__PURE__ */ new Set()),
|
|
266
|
+
startingWith: () => Effect.succeed({
|
|
267
|
+
oids: [],
|
|
268
|
+
more: false
|
|
269
|
+
}),
|
|
270
|
+
objects: () => Effect.succeed({
|
|
271
|
+
objects: /* @__PURE__ */ new Map(),
|
|
272
|
+
left: []
|
|
273
|
+
}),
|
|
274
|
+
allotment: allotmentWithin,
|
|
275
|
+
release: () => {}
|
|
276
|
+
} : {
|
|
277
|
+
object: (oid) => readObject(calls, listed, oid, budget),
|
|
278
|
+
sizes: rowSizes(calls, listed),
|
|
279
|
+
headers: rowHeaders(calls, listed),
|
|
280
|
+
has: (oids) => Effect.map(rowHeaders(calls, listed)(oids), (headers) => new Set(headers.keys())),
|
|
281
|
+
startingWith: (prefix, most) => Effect.map(rowsStartingWith(calls, listed.repo, prefix, most + 1), ({ oids }) => startingOf([oids], most)),
|
|
282
|
+
objects: (oids, bytes) => allottedRows((before) => eachHeldRow(calls, listed, chargedFirst(charges, before)), oids, bytes),
|
|
283
|
+
allotment: allotmentWithin,
|
|
284
|
+
release: charges.release
|
|
285
|
+
}, scope);
|
|
286
|
+
};
|
|
287
|
+
return {
|
|
128
288
|
reader: (listed, input) => Effect.map(callScope, (scope) => openReader(listed, scope, input?.listedOnly)),
|
|
129
289
|
pushedCommits: (_, input) => pushedCommitsPage(void 0, input),
|
|
130
|
-
receive: (listed, input) => cancelsBody(input.pack, receiveRows(calls, listed, input, limits)),
|
|
290
|
+
receive: (listed, input) => cancelsBody(input.pack, receiveRows(calls, listed, input, limits, budget)),
|
|
131
291
|
fetch: (listed, input) => {
|
|
132
|
-
const reads =
|
|
133
|
-
|
|
134
|
-
each: eachHeldRow(calls, listed),
|
|
135
|
-
sizes: rowSizes(calls, listed)
|
|
136
|
-
};
|
|
137
|
-
return handingOn(fetchPack(reads, input, fetchLimits));
|
|
292
|
+
const { reads, ended } = fetchReads(calls, listed, budget);
|
|
293
|
+
return handingOn(Effect.onError(fetchPack(reads, input, fetchLimits, { ended }), () => ended));
|
|
138
294
|
},
|
|
139
|
-
maintain: () =>
|
|
295
|
+
maintain: (listed, input) => looseUpkeep(input.store, listed, input.at),
|
|
140
296
|
share: () => Effect.void,
|
|
141
|
-
copyRows: (listed, input) => copyRowsPage(calls, listed, input)
|
|
142
|
-
};
|
|
143
|
-
return {
|
|
144
|
-
reader: answering(face.reader),
|
|
145
|
-
pushedCommits: answering(face.pushedCommits),
|
|
146
|
-
receive: answering(face.receive),
|
|
147
|
-
fetch: answering(face.fetch),
|
|
148
|
-
maintain: answering(face.maintain),
|
|
149
|
-
share: answering(face.share),
|
|
150
|
-
copyRows: answering(face.copyRows),
|
|
297
|
+
copyRows: (listed, input) => copyRowsPage(calls, listed, input),
|
|
151
298
|
readyShallow: false,
|
|
152
299
|
pushObjectsMost: limits.objects
|
|
153
300
|
};
|
|
154
301
|
}
|
|
155
302
|
};
|
|
156
303
|
};
|
|
157
|
-
export { isLoose, loose, looseLimits, looseObjectsMost };
|
|
304
|
+
export { isLoose, loose, looseFileBytesMost, looseLimits, looseObjectsMost };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { RequestHolding } from "../store/call-count.mjs";
|
|
3
|
-
import { pushFloorsOf, readerFloors, readerMost } from "./budget.mjs";
|
|
4
|
-
import { packIndexerLimits } from "./pack-reads.mjs";
|
|
3
|
+
import { pushFloorsOf, readerFloors, readerMost, receiveObjectsMostOf } from "./budget.mjs";
|
|
4
|
+
import { indexBytes, packIndexerLimits } from "./pack-reads.mjs";
|
|
5
5
|
import { ReceivedPointers, lfsPointersMost, pageEntries } from "./lfs-pointers.mjs";
|
|
6
6
|
import { receiveRoomAdmitted } from "./receive-admission.mjs";
|
|
7
7
|
import { ReceiveRoom } from "./runs.mjs";
|
|
@@ -562,9 +562,10 @@ var MemoryBudget = class {
|
|
|
562
562
|
}
|
|
563
563
|
/**
|
|
564
564
|
* The queue's one wake, run wherever bytes or a waiter leave, granted, refused, interrupted or
|
|
565
|
-
* released: it lets in one waiter at a time by `#next`, until none fits. A grant
|
|
566
|
-
* waiter in
|
|
567
|
-
*
|
|
565
|
+
* released: it lets in one waiter at a time by `#next`, until none fits. A grant hands its
|
|
566
|
+
* waiter what it's granted in this step, and resumes the waiter's fiber a turn later, in its own
|
|
567
|
+
* request (#2719). Bytes given back in this step, by a refusal or a release a grant leads to,
|
|
568
|
+
* wake the queue again inside this one. Two things keep that safe. `#next` reads the queues as they are after every grant, so no
|
|
568
569
|
* waiter is granted twice. A wake inside a wake returns at once, marking another pass due, so a
|
|
569
570
|
* release that lets in a burst of waiters, each giving its bytes back at once, runs flat in this
|
|
570
571
|
* loop instead of a stack frame for each, which would overflow at about a thousand.
|
|
@@ -598,10 +599,21 @@ var MemoryBudget = class {
|
|
|
598
599
|
* Waits in `queue` as the waiter `enter` makes, `ms` at most; `None` past it. A wait interrupted,
|
|
599
600
|
* by its timeout too, leaves the queue and wakes it, since the waiter may have held up others,
|
|
600
601
|
* and runs its `left`.
|
|
602
|
+
*
|
|
603
|
+
* A grant comes in the step of whatever freed the bytes, often another request's. The waiter
|
|
604
|
+
* takes what it's granted in that step, through `enter`'s own bookkeeping, but its fiber resumes
|
|
605
|
+
* through a promise whose `then` it registered as it parked, so on a Worker it runs again in its
|
|
606
|
+
* own request: workerd refuses to resume one request's fiber in another's step, and the step
|
|
607
|
+
* that freed the bytes would fail instead (#2719). An interrupt between the grant and the resume
|
|
608
|
+
* finds the grant taken, as one after the resume does.
|
|
601
609
|
*/
|
|
602
610
|
#queued(queue, ms, enter) {
|
|
603
611
|
return Effect.callback((resume) => {
|
|
604
|
-
|
|
612
|
+
let grant = () => void 0;
|
|
613
|
+
new Promise((settle) => {
|
|
614
|
+
grant = settle;
|
|
615
|
+
}).then((granted) => resume(Effect.succeed(granted)));
|
|
616
|
+
const { waiter, left } = enter(grant);
|
|
605
617
|
queue.push(waiter);
|
|
606
618
|
if (!("room" in waiter) && waiter.grower !== void 0) this.#wakeRooms();
|
|
607
619
|
return Effect.sync(() => {
|
|
@@ -948,7 +960,8 @@ const upkeepRuns = {
|
|
|
948
960
|
* The room a prune walk's reader holds its packs' `.idx` and `.rev` in, whatever their sum: a
|
|
949
961
|
* fixed size, never sized up to what's spare, which a walk charges once in place of each pack's
|
|
950
962
|
* (#2230). About 1,050,000 objects' indexes at 32 B an object. A merge cuts each pack it writes so
|
|
951
|
-
* its index fits,
|
|
963
|
+
* its index fits, a push takes no more objects than `pruneIndexObjectsMost`, and a walk refuses a
|
|
964
|
+
* listed pack whose index alone passes it.
|
|
952
965
|
*
|
|
953
966
|
* It fits beside the rest of a walk at its bounds: `pruneWalkHeld()`'s 47,844,271, this
|
|
954
967
|
* 33,554,432 and the read reserve's 4,194,688 come to 85,593,391, under the default memory's
|
|
@@ -956,6 +969,29 @@ const upkeepRuns = {
|
|
|
956
969
|
*/
|
|
957
970
|
const pruneIndexFloor = 33554432;
|
|
958
971
|
/**
|
|
972
|
+
* The most objects whose pack's index fits `pruneIndexFloor`, 1,048,528: 32 B an object past its
|
|
973
|
+
* fixed 1,508, in a pack under 2 GiB, whose index takes no large offsets (#2402). Every pack prune
|
|
974
|
+
* meets is: a received one's entries each start under `pushUploadMost` and take at most
|
|
975
|
+
* `packFileBytes`, and a merge cuts under `maxPackSizeMost`.
|
|
976
|
+
*/
|
|
977
|
+
const pruneIndexObjectsMost = Math.floor((pruneIndexFloor - indexBytes({
|
|
978
|
+
objects: 0,
|
|
979
|
+
bytes: 0
|
|
980
|
+
})) / (indexBytes({
|
|
981
|
+
objects: 1,
|
|
982
|
+
bytes: 0
|
|
983
|
+
}) - indexBytes({
|
|
984
|
+
objects: 0,
|
|
985
|
+
bytes: 0
|
|
986
|
+
})));
|
|
987
|
+
/**
|
|
988
|
+
* The most objects one push of `size`'s length takes in a `packs()` instance of `memory`: what its
|
|
989
|
+
* memory takes, `receiveObjectsMostOf`, and no more than `pruneIndexObjectsMost`, so a prune walk
|
|
990
|
+
* holds its pack's index, which no merge cuts while it's alone. Past it, a push is refused before
|
|
991
|
+
* it waits, by the most. In a Worker's 128 MB, 1,048,528, whatever its length.
|
|
992
|
+
*/
|
|
993
|
+
const pushObjectsMostOf = (memory, size = {}) => Math.min(receiveObjectsMostOf(memory, size), pruneIndexObjectsMost);
|
|
994
|
+
/**
|
|
959
995
|
* What a prune walk's seen set holds (#2019): a bit for each object of each of `packs`, at its rank,
|
|
960
996
|
* and for each of `outside` objects no listed pack holds, its ID, at `fetchEntryBytes`. A part's
|
|
961
997
|
* save puts the same bytes, the IDs at 20 each, so its read holds no more.
|
|
@@ -1099,4 +1135,4 @@ var AllottedPointers = class {
|
|
|
1099
1135
|
return this.#pointers.finish();
|
|
1100
1136
|
}
|
|
1101
1137
|
};
|
|
1102
|
-
export { AllottedPointers, MemoryAllotment, MemoryBudget, allottedWithin, fetchBusy, growWaitMs, headStuckMs, joinRoomOf, outsideOn, pruneIndexFloor, pruneSeenBytes, pushBusy, pushEntryTooLarge, pushIndexTooLarge, pushMemoryOf, pushTooLarge, pushWaitMs, readBusy, readerMemoryOf, upkeepMemoryOf, upkeepRuns, upkeepTooLarge };
|
|
1138
|
+
export { AllottedPointers, MemoryAllotment, MemoryBudget, allottedWithin, fetchBusy, growWaitMs, headStuckMs, joinRoomOf, outsideOn, pruneIndexFloor, pruneIndexObjectsMost, pruneSeenBytes, pushBusy, pushEntryTooLarge, pushIndexTooLarge, pushMemoryOf, pushObjectsMostOf, pushTooLarge, pushWaitMs, readBusy, readerMemoryOf, upkeepMemoryOf, upkeepRuns, upkeepTooLarge };
|
|
@@ -28,9 +28,10 @@ var PastMost = class extends Data.TaggedError("PastMost") {};
|
|
|
28
28
|
const plan = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
29
29
|
const { inputs, limits, bounds = upkeepRuns } = input;
|
|
30
30
|
const total = inputs.reduce((sum, each) => sum + each.objects, 0);
|
|
31
|
+
const maxEntries = total + input.rows.length;
|
|
31
32
|
const packs = [];
|
|
32
33
|
const spent = [];
|
|
33
|
-
let pack = openPack(input.readers());
|
|
34
|
+
let pack = openPack(input.readers(), maxEntries);
|
|
34
35
|
let spend = packStart;
|
|
35
36
|
let opened = input.from ?? {
|
|
36
37
|
kind: "commit",
|
|
@@ -73,7 +74,7 @@ const plan = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
73
74
|
bytes: spend.bytes
|
|
74
75
|
});
|
|
75
76
|
spent.push(spend);
|
|
76
|
-
pack = openPack(input.readers());
|
|
77
|
+
pack = openPack(input.readers(), maxEntries);
|
|
77
78
|
spend = packStart;
|
|
78
79
|
opened = {
|
|
79
80
|
...at,
|
|
@@ -129,8 +129,14 @@ const MergeRow = Schema.Struct({
|
|
|
129
129
|
/** The packs the plan has cut so far, in write order, at most `mergePacksMost`. */
|
|
130
130
|
planned: Schema.Array(PlannedPack).check(Schema.isMaxLength(mergePacksMost)),
|
|
131
131
|
/** The packs written so far, in write order. */
|
|
132
|
-
written: Schema.Array(WrittenPack).check(Schema.isMaxLength(mergePacksMost))
|
|
132
|
+
written: Schema.Array(WrittenPack).check(Schema.isMaxLength(mergePacksMost)),
|
|
133
|
+
/**
|
|
134
|
+
* A prune merge's: the number of the pass's classes object its keep was read from. A later try
|
|
135
|
+
* reads that keep again for its remap only from the object of this number (#2196).
|
|
136
|
+
*/
|
|
137
|
+
classes: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))
|
|
133
138
|
}).check(Schema.makeFilter((row) => {
|
|
139
|
+
if (row.classes !== void 0 && row.owner !== "prune") return "only a prune merge's keep comes from a classes object";
|
|
134
140
|
if ((row.pass === "plan" || row.pass === "write") !== (row.cursor !== void 0)) return "only its plan and write passes have a cursor";
|
|
135
141
|
if (row.pass === "plan" ? row.written.length > 0 : row.planned.length === 0) return "it writes a pack before its plan is done";
|
|
136
142
|
const left = row.planned.length - row.written.length;
|