@ref0/git 0.14.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/auth/access-jwt.mjs +2 -2
- package/dist/auth/authorize.mjs +3 -3
- 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/host-function.mjs +18 -1
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- 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 -27
- package/dist/auth/tokens-layer.mjs +6 -11
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -10
- package/dist/auth/tokens.mjs +9 -80
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +17 -7
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +9 -8
- package/dist/client/remote.mjs +8 -10
- 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/blobs.d.mts +55 -8
- 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 +15 -16
- package/dist/contracts/commits.d.mts +24 -24
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +10 -10
- package/dist/contracts/forks.d.mts +17 -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 +21 -0
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -2
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +23 -25
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +26 -23
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +4 -1
- package/dist/contracts/repos.d.mts +29 -138
- package/dist/contracts/repos.mjs +5 -3
- package/dist/contracts/result.d.mts +35 -16
- package/dist/contracts/result.mjs +35 -7
- package/dist/contracts/server.d.mts +25 -50
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +11 -7
- package/dist/contracts/sync.mjs +12 -2
- 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 -17
- package/dist/contracts/tokens.mjs +3 -2
- package/dist/contracts/topics.d.mts +1 -1
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +24 -13
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +20 -9
- package/dist/core/ancestry.d.mts +1 -0
- package/dist/core/asked.mjs +1 -1
- package/dist/core/call-names.mjs +6 -1
- package/dist/core/call-services.mjs +11 -3
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +43 -36
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +928 -432
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +29 -23
- package/dist/core/index-job.mjs +122 -34
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/objects/blobs.mjs +129 -3
- 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 +4 -5
- package/dist/core/parts.mjs +3 -8
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +287 -83
- package/dist/core/push-decide.mjs +2 -0
- package/dist/core/push-files.d.mts +1 -1
- package/dist/core/push.mjs +58 -47
- package/dist/core/receipts.mjs +8 -3
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +2 -2
- package/dist/core/refs.mjs +5 -5
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +36 -21
- package/dist/core/repo-info.mjs +3 -3
- package/dist/core/repos.mjs +21 -9
- 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.mjs +7 -15
- package/dist/core/work.mjs +59 -14
- package/dist/effect.d.mts +3 -12
- package/dist/effect.mjs +1 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +4 -4
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +37 -14
- package/dist/extend.d.mts +2 -3
- package/dist/extend.mjs +2 -1
- package/dist/http/answers.mjs +8 -5
- package/dist/http/core-parts.mjs +95 -79
- package/dist/http/handler.mjs +34 -7
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +56 -27
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +30 -26
- package/dist/http/push-uploads.mjs +36 -21
- package/dist/http/upload-pack.mjs +3 -3
- package/dist/index.d.mts +14 -14
- package/dist/index.mjs +2 -2
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +2 -0
- package/dist/lfs/base.mjs +25 -1
- package/dist/lfs/copy.d.mts +21 -7
- package/dist/lfs/copy.mjs +89 -6
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +24 -11
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -0
- package/dist/lfs/objects.mjs +87 -17
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- 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/queue/advance.mjs +21 -24
- 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 +1 -15
- package/dist/queue/host.mjs +2 -7
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +10 -3
- 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 +5 -3
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4271
- package/dist/rest/caller.mjs +4 -0
- package/dist/rest/client.d.mts +8 -5
- package/dist/rest/client.mjs +19 -2
- package/dist/rest/handlers.mjs +50 -5
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +5 -12
- package/dist/rest/me.d.mts +3 -432
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +11 -8
- package/dist/server/edge-node.mjs +9 -6
- 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 +5 -5
- package/dist/server/git-layer.mjs +28 -22
- package/dist/server/git-namespace.d.mts +4 -3
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +6 -18
- package/dist/server/joined.mjs +9 -36
- package/dist/server/lifecycle.mjs +18 -106
- package/dist/server/registry.mjs +24 -7
- package/dist/server/server.mjs +205 -346
- 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/storage/batches.d.mts +8 -0
- package/dist/storage/batches.mjs +344 -0
- 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 +72 -9
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +287 -210
- 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 +0 -1
- package/dist/storage/index-build.mjs +80 -23
- package/dist/storage/index-fetch.mjs +113 -72
- 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-remap.mjs +200 -64
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +1 -1
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +212 -67
- package/dist/storage/memory-budget.mjs +16 -4
- 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 +158 -42
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +2 -2
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +136 -66
- 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 +134 -41
- package/dist/storage/prune-walk.mjs +202 -62
- package/dist/storage/prune.mjs +194 -91
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +4 -4
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +8 -6
- package/dist/storage/receive-bounds.mjs +23 -8
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +1 -1
- 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/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +127 -26
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +2 -2
- package/dist/storage/walk.mjs +192 -38
- 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 +145 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal.d.mts +1 -2
- package/dist/store/cursor-seal.mjs +16 -6
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +15 -33
- 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 +3 -0
- package/dist/store/records.mjs +3 -0
- package/dist/store/repo-record.d.mts +1 -2
- package/dist/store/repo-record.mjs +32 -20
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +11 -0
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/github.mjs +3 -3
- package/dist/sync/import.mjs +31 -18
- package/dist/sync/lfs-batch.mjs +4 -5
- package/dist/sync/lfs-copy.mjs +17 -6
- package/dist/sync/mirror.mjs +34 -31
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/step.mjs +33 -25
- package/dist/sync/tries.mjs +9 -9
- 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 +1 -1
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +2 -3
- 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 -4
- 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/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -833
- package/dist/rest/commits.d.mts +0 -3543
- package/dist/rest/errors.d.mts +0 -2124
- package/dist/rest/events.d.mts +0 -426
- package/dist/rest/files.d.mts +0 -1342
- package/dist/rest/forks.d.mts +0 -2160
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -477
- package/dist/rest/queue.d.mts +0 -5917
- package/dist/rest/refs.d.mts +0 -2988
- package/dist/rest/repos.d.mts +0 -2567
- package/dist/rest/tags.d.mts +0 -1316
- package/dist/rest/tokens.d.mts +0 -2614
- package/dist/rest/topics.d.mts +0 -2224
- package/dist/rest/trees.d.mts +0 -1709
- package/dist/rest/work.d.mts +0 -1695
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
|
@@ -2,7 +2,7 @@ import { gitError } from "../contracts/result.mjs";
|
|
|
2
2
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
3
3
|
import { Sha1 } from "../protocol/bytes/sha1.mjs";
|
|
4
4
|
import { answerSpent, pastCallLimit } from "../store/errors.mjs";
|
|
5
|
-
import { copyHeldBytes, isMergeIncomplete, mergeIncomplete } from "./index-bitmaps.mjs";
|
|
5
|
+
import { copyHeldBytes, isKeepUnclosed, isMergeIncomplete, mergeIncomplete } from "./index-bitmaps.mjs";
|
|
6
6
|
import { belowGraphs, copyMergedBitmaps, coveredPacks, indexRowOf, mergeCallsAfterOpen, mergeChunk, newBuildId, putOnce, wordsOf } from "./index-build.mjs";
|
|
7
7
|
import { BasesWriter, TypesWriter, indexBasesBytes, indexTypesBytes, openBases, openTypes, typeCodes } from "./index-files.mjs";
|
|
8
8
|
import { mergeHeldBytes, mergeIndexGraphs } from "./index-graph.mjs";
|
|
@@ -14,13 +14,15 @@ import { spentIn } from "../contracts/calls-spent.mjs";
|
|
|
14
14
|
import { startPut } from "./merge.mjs";
|
|
15
15
|
import { writeOrder } from "./merge-choose.mjs";
|
|
16
16
|
import { openRanges, rangeRanks, readExactly } from "./pack-ranges.mjs";
|
|
17
|
-
import {
|
|
17
|
+
import { hasBit, setBit } from "./prune-keep.mjs";
|
|
18
|
+
import { compareIds, orderById } from "./raw-ids.mjs";
|
|
18
19
|
import * as Effect from "effect/Effect";
|
|
19
20
|
// src/storage/index-remap.ts
|
|
20
21
|
/**
|
|
21
22
|
* The plan of a remap of `layers` once a merge takes `merged`'s packs, of `objects` objects in
|
|
22
|
-
* all: `undefined` when it can't remap, as when a
|
|
23
|
-
* covered pack isn't listed. `listed` is the listing
|
|
23
|
+
* all, 0 for packs a prune step empties with no merge: `undefined` when it can't remap, as when a
|
|
24
|
+
* merged pack isn't one the row covers, or a covered pack isn't listed. `listed` is the listing
|
|
25
|
+
* before the merge.
|
|
24
26
|
*/
|
|
25
27
|
const remapPlan = (layers, listed, merged, objects) => {
|
|
26
28
|
const counts = new Map(listed.packs.map((pack) => [pack.id, pack.objects]));
|
|
@@ -87,24 +89,38 @@ const keptRowBytes = 64;
|
|
|
87
89
|
* planned: the map, 4 bytes a tail position, with the tail's IDs, the rows kept and their join;
|
|
88
90
|
* then the map through the graph merge's and the copy's, with every bitmap's entry,
|
|
89
91
|
* `mergeEntryBytes`; or `.bases`' rows, the old and the new, with each row's code and a chunk of
|
|
90
|
-
* `.types`.
|
|
92
|
+
* `.types`. A merge that `keeps` adds a bit a tail position, the IDs it dropped as they're built
|
|
93
|
+
* beside the tail's and then beside the graph merge's, and the bitmaps' copy beside both, since
|
|
94
|
+
* it runs before the graph's file finishes.
|
|
91
95
|
*/
|
|
92
|
-
const remapHeldMost = (plan, layers, objects) => {
|
|
96
|
+
const remapHeldMost = (plan, layers, objects, keeps = false) => {
|
|
93
97
|
const tail = plan.positions - plan.prefix;
|
|
94
98
|
const positions = plan.prefix + tail + objects;
|
|
95
99
|
const commits = layers.reduce((sum, layer) => sum + layer.commits, 0);
|
|
96
100
|
const bitmaps = layers.reduce((sum, layer) => sum + layer.bitmaps, 0);
|
|
97
101
|
const deltas = layers.reduce((sum, layer) => sum + layer.deltas, 0);
|
|
98
102
|
const files = layers.map((layer) => layer.first + layer.positions);
|
|
99
|
-
const map = tail * 4;
|
|
103
|
+
const map = tail * 4 + (keeps ? Math.ceil(tail / 8) : 0);
|
|
104
|
+
const taken = plan.tail.reduce((sum, pack) => sum + (pack.next === void 0 ? pack.objects : 0), 0);
|
|
105
|
+
const dropped = keeps ? Math.max(0, taken - objects) : 0;
|
|
106
|
+
const ids = map + tail * 20 + joinBytes(tail) + plan.rows * keptRowBytes;
|
|
107
|
+
const graph = commits * 4 + mergeHeldBytes(layers.length);
|
|
108
|
+
const copy = bitmaps * 640 + copyHeldBytes(positions, bitmaps, files);
|
|
100
109
|
const phases = [
|
|
101
|
-
|
|
102
|
-
map +
|
|
103
|
-
map +
|
|
110
|
+
ids + goneBuildBytes(dropped),
|
|
111
|
+
map + goneHeldBytes(dropped) + graph,
|
|
112
|
+
map + (keeps ? goneHeldBytes(dropped) + graph : 0) + copy,
|
|
104
113
|
map + bitmaps * 640 + deltas * 16 + objects * 8 + plan.rows * 112 + mergeChunk * 9
|
|
105
114
|
];
|
|
106
115
|
return Math.max(...phases);
|
|
107
116
|
};
|
|
117
|
+
/**
|
|
118
|
+
* What `goneIds` holds as it builds `count` dropped IDs: theirs twice, gathered then sorted, their
|
|
119
|
+
* order, and `orderById`'s two tables of counts.
|
|
120
|
+
*/
|
|
121
|
+
const goneBuildBytes = (count) => count === 0 ? 0 : count * 44 + 524292;
|
|
122
|
+
/** What the sorted dropped IDs hold once built, through the graph merge. */
|
|
123
|
+
const goneHeldBytes = (count) => count * 20;
|
|
108
124
|
/** Where `layers` hold an old position: its layer and its place there. */
|
|
109
125
|
const layerAt = (layers, position) => layers.find((layer) => position >= layer.first && position < layer.first + layer.positions);
|
|
110
126
|
/** The `.types` parts `oldTypes` reads over old positions `[from, to)`: one a layer or chunk. */
|
|
@@ -152,6 +168,8 @@ const defaultRemapCpuMost = 3e4;
|
|
|
152
168
|
const remapUnits = (plan, layers) => layers.reduce((sum, layer) => sum + layer.bitmaps, 0) * (plan.positions - plan.prefix);
|
|
153
169
|
/** Whether a remap's CPU, its units at `remapNsPerUnit`, would pass `cpuMost` ms. */
|
|
154
170
|
const remapCpuPast = (units, cpuMost) => units * 26 > Math.round(cpuMost * 1e6);
|
|
171
|
+
/** The objects `merged` lays in the tail: its pack's, or none for packs emptied. */
|
|
172
|
+
const mergedObjects = (merged) => merged.kind === "pack" ? merged.pack.objects : 0;
|
|
155
173
|
/**
|
|
156
174
|
* The calls a remap makes past its graphs' heads: `remapCalls` with a layer merge's reads of
|
|
157
175
|
* graphs of `octopus` table entries each, its `.bitmaps` over the merged pack's positions too, in
|
|
@@ -201,17 +219,31 @@ const remapPast = (input) => {
|
|
|
201
219
|
const layers = row.layers;
|
|
202
220
|
if (remapCpuPast(remapUnits(plan, layers), input.cpuMost)) return "cpu";
|
|
203
221
|
if (input.lease !== void 0 && input.lease >= input.grace) return "lease";
|
|
204
|
-
if (pastCallsLeft(input.calls, remapCallsMost(plan, layers, merged
|
|
205
|
-
const held = remapHeldMost(plan, layers, merged.
|
|
222
|
+
if (pastCallsLeft(input.calls, remapCallsMost(plan, layers, mergedObjects(merged), input.bucket.multipart))) return "calls";
|
|
223
|
+
const held = remapHeldMost(plan, layers, mergedObjects(merged), input.keeps !== void 0);
|
|
206
224
|
if (!input.allotment.tryGrow(held)) return "memory";
|
|
207
225
|
input.allotment.shrink(held);
|
|
208
226
|
};
|
|
227
|
+
/**
|
|
228
|
+
* Whether a remap fits, from its plan and the merge alone, before any read: `'cpu'` when its CPU
|
|
229
|
+
* passes `cpuMost`, which no try changes, and `'calls'` when `before`, its own calls at most and
|
|
230
|
+
* the listing's commit pass what the try has left, as `remapPast` weighs them. A resumed merge
|
|
231
|
+
* whose remap fits a fresh try, but not what its last try has left, saves for the next (#2196).
|
|
232
|
+
*/
|
|
233
|
+
const remapFits = (fit) => {
|
|
234
|
+
const { plan, layers } = fit;
|
|
235
|
+
if (remapCpuPast(remapUnits(plan, layers), fit.cpuMost)) return "cpu";
|
|
236
|
+
const needs = (fit.before ?? 0) + remapCallsMost(plan, layers, fit.objects, fit.multipart);
|
|
237
|
+
return pastCallsLeft(fit.calls, needs) ? "calls" : void 0;
|
|
238
|
+
};
|
|
209
239
|
const lost = (message) => gitError("DATA_LOSS", message);
|
|
210
240
|
/**
|
|
211
241
|
* A remap's decline, one line in the log with its cause, so a bound it always passes shows as a
|
|
212
242
|
* pattern: then the merge commits alone, and the next `git.index` builds again.
|
|
213
243
|
*/
|
|
214
244
|
const declined = (repo, cause) => Effect.logWarning(`git.repack's remap of repo ${repo} declined, ${cause}`).pipe(Effect.as(void 0));
|
|
245
|
+
/** A remap's decline past a bound `remapPast` weighs, as `remapIndex` logs it. */
|
|
246
|
+
const declinedPast = (repo, past) => declined(repo, `past its ${past} bound`);
|
|
215
247
|
/** A remap's allotment's refusal to grow, its own, so `remapFailure` tells it from another's. */
|
|
216
248
|
const remapBusy = /* @__PURE__ */ gitError("UNAVAILABLE", "A repack's remap couldn't grow its allotment", { context: { reason: "busy" } });
|
|
217
249
|
/**
|
|
@@ -257,20 +289,26 @@ const mergedRanges = (bucket, pack, base) => Effect.map(mergedOwn(rangesOf(bucke
|
|
|
257
289
|
});
|
|
258
290
|
/**
|
|
259
291
|
* Each tail position's ID, by its old position, and the rows the merge left: theirs from each
|
|
260
|
-
* run's region, by ID, each with its old position. `
|
|
261
|
-
* row held.
|
|
292
|
+
* run's region, by ID, each with its old position. With `input.keeps`, the tail positions the
|
|
293
|
+
* merge dropped too, a bit each. `undefined` when a folded row isn't one the row held.
|
|
262
294
|
*/
|
|
263
295
|
const tailIds = /* @__PURE__ */ Effect.fnUntraced(function* (input, old) {
|
|
264
296
|
const { bucket, listed, plan } = input;
|
|
265
297
|
const tail = plan.positions - plan.prefix;
|
|
266
298
|
const ids = new Uint8Array(tail * 20);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
for (let
|
|
272
|
-
const
|
|
273
|
-
|
|
299
|
+
const dropped = input.keeps === void 0 ? void 0 : new Uint8Array(Math.ceil(tail / 8));
|
|
300
|
+
for (const [index, ranges] of old.entries()) {
|
|
301
|
+
const pack = plan.tail[index];
|
|
302
|
+
const keeps = pack?.next === void 0 ? input.keeps : void 0;
|
|
303
|
+
for (let rank = 0; rank < ranges.count; rank += rangeRanks) {
|
|
304
|
+
const count = Math.min(rangeRanks, ranges.count - rank);
|
|
305
|
+
const chunk = yield* ranges.ids(rank, count);
|
|
306
|
+
const positions = yield* ranges.positions(rank, count);
|
|
307
|
+
for (let at = 0; at < count; at += 1) {
|
|
308
|
+
const place = ranges.base + (positions[at] ?? 0) - plan.prefix;
|
|
309
|
+
ids.set(chunk.subarray(at * 20, at * 20 + 20), place * 20);
|
|
310
|
+
if (dropped !== void 0 && keeps?.(pack?.id ?? "", rank + at) === false) setBit(dropped, place);
|
|
311
|
+
}
|
|
274
312
|
}
|
|
275
313
|
}
|
|
276
314
|
const folded = new Set(input.folded);
|
|
@@ -293,13 +331,52 @@ const tailIds = /* @__PURE__ */ Effect.fnUntraced(function* (input, old) {
|
|
|
293
331
|
kept.sort((a, b) => compareIds(a.id, 0, b.id, 0));
|
|
294
332
|
return {
|
|
295
333
|
ids,
|
|
296
|
-
kept
|
|
334
|
+
kept,
|
|
335
|
+
dropped
|
|
297
336
|
};
|
|
298
337
|
});
|
|
299
|
-
/**
|
|
338
|
+
/** How many tail positions `map` leaves `missing`: the objects the merge dropped. */
|
|
339
|
+
const goneCount = (map) => {
|
|
340
|
+
let count = 0;
|
|
341
|
+
for (const to of map) if (to === 4294967295) count += 1;
|
|
342
|
+
return count;
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* The IDs of the `count` tail positions `map` leaves `missing`, the ones the merge dropped, in ID
|
|
346
|
+
* order, for the graph merge to leave out.
|
|
347
|
+
*/
|
|
348
|
+
const goneIds = (ids, map, count) => {
|
|
349
|
+
const gone = new Uint8Array(count * 20);
|
|
350
|
+
let at = 0;
|
|
351
|
+
for (const [place, to] of map.entries()) if (to === 4294967295) {
|
|
352
|
+
gone.set(ids.subarray(place * 20, place * 20 + 20), at * 20);
|
|
353
|
+
at += 1;
|
|
354
|
+
}
|
|
355
|
+
const sorted = new Uint8Array(count * 20);
|
|
356
|
+
for (const [to, from] of orderById(gone, count).entries()) sorted.set(gone.subarray(from * 20, from * 20 + 20), to * 20);
|
|
357
|
+
return sorted;
|
|
358
|
+
};
|
|
359
|
+
/** Whether `sorted`, IDs in order, holds the one at `offset` of `ids`. */
|
|
360
|
+
const holdsId = (sorted, ids, offset) => {
|
|
361
|
+
let low = 0;
|
|
362
|
+
let high = sorted.length / 20;
|
|
363
|
+
while (low < high) {
|
|
364
|
+
const middle = low + high >>> 1;
|
|
365
|
+
const order = compareIds(sorted, middle * 20, ids, offset);
|
|
366
|
+
if (order === 0) return true;
|
|
367
|
+
if (order < 0) low = middle + 1;
|
|
368
|
+
else high = middle;
|
|
369
|
+
}
|
|
370
|
+
return false;
|
|
371
|
+
};
|
|
372
|
+
/**
|
|
373
|
+
* A bitmap's bits moved: the prefix's words as they were, each tail bit through `map`. `false`
|
|
374
|
+
* when a bit is at a position `map` leaves `missing`, one the merge dropped.
|
|
375
|
+
*/
|
|
300
376
|
const movedBits = (prefix, map) => (bits, into) => {
|
|
301
377
|
const whole = prefix >>> 5;
|
|
302
378
|
into.set(bits.subarray(0, Math.min(whole, into.length)));
|
|
379
|
+
let placed = true;
|
|
303
380
|
for (let word = whole; word < bits.length; word += 1) {
|
|
304
381
|
let left = bits[word] ?? 0;
|
|
305
382
|
while (left !== 0) {
|
|
@@ -307,9 +384,11 @@ const movedBits = (prefix, map) => (bits, into) => {
|
|
|
307
384
|
left ^= low;
|
|
308
385
|
const position = word * 32 + (31 - Math.clz32(low));
|
|
309
386
|
const to = position < prefix ? position : map[position - prefix] ?? 4294967295;
|
|
310
|
-
if (to
|
|
387
|
+
if (to === 4294967295) placed = false;
|
|
388
|
+
else into[to >>> 5] = (into[to >>> 5] ?? 0) | 1 << (to & 31);
|
|
311
389
|
}
|
|
312
390
|
}
|
|
391
|
+
return placed;
|
|
313
392
|
};
|
|
314
393
|
/** Each layer's `.types`, its header read and checked once a remap, as a layer merge opens it. */
|
|
315
394
|
const layerTypes = (input) => {
|
|
@@ -356,11 +435,12 @@ const oldBases = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
356
435
|
/**
|
|
357
436
|
* The remapped `.bases` rows: the prefix's as they were; the merged pack's, from its own plan,
|
|
358
437
|
* past the prefix; and each other tail pack's, moved as its pack is. A row of a merged pack is
|
|
359
|
-
* gone, its pack's objects the merged pack's now.
|
|
438
|
+
* gone, its pack's objects the merged pack's now, or gone with them when they're emptied.
|
|
360
439
|
*/
|
|
361
440
|
const remappedBases = (input, old) => {
|
|
362
441
|
const { plan, merged } = input;
|
|
363
|
-
const
|
|
442
|
+
const own = merged.kind === "pack" ? merged.bases : /* @__PURE__ */ new Uint32Array(0);
|
|
443
|
+
const out = new Uint32Array(old.length + own.length);
|
|
364
444
|
let length = 0;
|
|
365
445
|
const push = (position, base) => {
|
|
366
446
|
out[length] = position;
|
|
@@ -368,7 +448,7 @@ const remappedBases = (input, old) => {
|
|
|
368
448
|
length += 2;
|
|
369
449
|
};
|
|
370
450
|
for (let at = 0; at < old.length && (old[at] ?? 0) < plan.prefix; at += 2) push(old[at] ?? 0, old[at + 1] ?? 0);
|
|
371
|
-
for (let at = 0; at <
|
|
451
|
+
for (let at = 0; at < own.length; at += 2) push((own[at] ?? 0) + plan.prefix, (own[at + 1] ?? 0) + plan.prefix);
|
|
372
452
|
for (let at = 0; at < old.length; at += 2) {
|
|
373
453
|
const position = old[at] ?? 0;
|
|
374
454
|
const pack = plan.tail.find((each) => position >= each.old && position < each.old + each.objects);
|
|
@@ -393,25 +473,26 @@ const remapIndex = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
393
473
|
if (past !== void 0) return yield* declined(listed.repo, `past its ${past} bound`);
|
|
394
474
|
const graphs = yield* belowGraphs(bucket, listed.repo, layers);
|
|
395
475
|
const octopus = graphs.map((graph) => graph.octopus);
|
|
396
|
-
if (pastCallsLeft(input.calls, callsAfterHeads(plan, layers, merged
|
|
476
|
+
if (pastCallsLeft(input.calls, callsAfterHeads(plan, layers, mergedObjects(merged), octopus, bucket.multipart))) return yield* declined(listed.repo, "past its calls bound, with its graphs' octopus tables");
|
|
397
477
|
const build = newBuildId();
|
|
398
478
|
const files = indexFiles(listed.repo, build);
|
|
399
|
-
const objects = merged
|
|
479
|
+
const objects = mergedObjects(merged);
|
|
400
480
|
const positions = plan.prefix + tailOf(plan, objects, input.folded.length);
|
|
401
481
|
const tail = plan.positions - plan.prefix;
|
|
402
482
|
const bytesOf = new Map(listed.packs.map((pack) => [pack.id, pack.bytes]));
|
|
403
|
-
|
|
483
|
+
const map4 = tail * 4 + (input.keeps === void 0 ? 0 : Math.ceil(tail / 8));
|
|
484
|
+
yield* allotment.grow(map4);
|
|
404
485
|
yield* allotment.grow(tail * 20 + joinBytes(tail));
|
|
405
486
|
const old = yield* Effect.forEach(plan.tail, (pack) => rangesOf(bucket, pack.id, pack.objects, bytesOf.get(pack.id) ?? 0, pack.old));
|
|
406
487
|
const read = yield* tailIds(input, old);
|
|
407
488
|
if (read === void 0) {
|
|
408
|
-
allotment.shrink(tail *
|
|
489
|
+
allotment.shrink(map4 + tail * 20 + joinBytes(tail));
|
|
409
490
|
return yield* declined(listed.repo, "a row the merge folded isn't one the row held");
|
|
410
491
|
}
|
|
411
492
|
const rowsFirst = positions - read.kept.length;
|
|
412
493
|
const regionIds = new Uint8Array(read.kept.length * 20);
|
|
413
494
|
for (const [at, each] of read.kept.entries()) regionIds.set(each.id, at * 20);
|
|
414
|
-
const next = [yield* mergedRanges(bucket, merged.pack, plan.prefix), ...plan.tail.flatMap((pack, at) => {
|
|
495
|
+
const next = [...merged.kind === "pack" ? [yield* mergedRanges(bucket, merged.pack, plan.prefix)] : [], ...plan.tail.flatMap((pack, at) => {
|
|
415
496
|
const ranges = old[at];
|
|
416
497
|
return pack.next === void 0 || ranges === void 0 ? [] : [{
|
|
417
498
|
...ranges,
|
|
@@ -423,17 +504,12 @@ const remapIndex = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
423
504
|
positions: Uint32Array.from(read.kept, (_, at) => rowsFirst + at)
|
|
424
505
|
};
|
|
425
506
|
const map = yield* joinIds(read.ids, tail, next, region);
|
|
426
|
-
|
|
427
|
-
if (map.
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
allotment
|
|
433
|
-
});
|
|
434
|
-
const entries = layers.reduce((sum, layer) => sum + layer.bitmaps, 0) * 640;
|
|
435
|
-
yield* allotment.grow(entries);
|
|
436
|
-
const stored = yield* openLayerBitmaps(bucket, listed.repo, layers);
|
|
507
|
+
const { dropped } = read;
|
|
508
|
+
if (map.some((to, at) => to === 4294967295 && (dropped === void 0 || !hasBit(dropped, at)))) return yield* Effect.fail(mergeIncomplete("The merge left a tail object out"));
|
|
509
|
+
const count = goneCount(map);
|
|
510
|
+
yield* allotment.grow(goneBuildBytes(count));
|
|
511
|
+
const gone = count === 0 ? void 0 : goneIds(read.ids, map, count);
|
|
512
|
+
allotment.shrink(tail * 20 + joinBytes(tail) + goneBuildBytes(count) - goneHeldBytes(count));
|
|
437
513
|
const move = {
|
|
438
514
|
bits: movedBits(plan.prefix, map),
|
|
439
515
|
position: (at) => {
|
|
@@ -441,15 +517,46 @@ const remapIndex = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
441
517
|
return to === 4294967295 ? void 0 : to;
|
|
442
518
|
}
|
|
443
519
|
};
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
520
|
+
const copy = Effect.fnUntraced(function* (renumbered) {
|
|
521
|
+
const entries = layers.reduce((sum, layer) => sum + layer.bitmaps, 0) * 640;
|
|
522
|
+
yield* allotment.grow(entries);
|
|
523
|
+
const stored = yield* openLayerBitmaps(bucket, listed.repo, layers);
|
|
524
|
+
return {
|
|
525
|
+
entries,
|
|
526
|
+
bitmaps: yield* copyMergedBitmaps({
|
|
527
|
+
bucket,
|
|
528
|
+
graphs,
|
|
529
|
+
files,
|
|
530
|
+
positions,
|
|
531
|
+
kept: stored.entries.filter(({ entry }) => move.position(entry.position) !== void 0),
|
|
532
|
+
allotment,
|
|
533
|
+
move,
|
|
534
|
+
renumbered
|
|
535
|
+
})
|
|
536
|
+
};
|
|
452
537
|
});
|
|
538
|
+
const copied = yield* Effect.gen(function* () {
|
|
539
|
+
const early = [];
|
|
540
|
+
const { commits } = yield* mergeIndexGraphs({
|
|
541
|
+
bucket,
|
|
542
|
+
graphs,
|
|
543
|
+
key: files.graph,
|
|
544
|
+
allotment,
|
|
545
|
+
drops: gone === void 0 ? void 0 : (ids, offset) => holdsId(gone, ids, offset),
|
|
546
|
+
beforeFinish: gone === void 0 ? void 0 : (renumbered) => Effect.map(copy(renumbered), (each) => {
|
|
547
|
+
early.push(each);
|
|
548
|
+
})
|
|
549
|
+
});
|
|
550
|
+
allotment.shrink(goneHeldBytes(count));
|
|
551
|
+
const { entries, bitmaps } = early[0] ?? (yield* copy());
|
|
552
|
+
return {
|
|
553
|
+
commits,
|
|
554
|
+
entries,
|
|
555
|
+
bitmaps
|
|
556
|
+
};
|
|
557
|
+
}).pipe(Effect.catchIf(isKeepUnclosed, (error) => Effect.logError(`git.repack's remap of repo ${listed.repo} declined, its merge's keep isn't closed: ${error.message}`).pipe(Effect.as(void 0))));
|
|
558
|
+
if (copied === void 0) return void 0;
|
|
559
|
+
const { commits, entries, bitmaps } = copied;
|
|
453
560
|
const filesBytes = layers.reduce((sum, layer) => sum + layer.deltas, 0) * 16 + objects * 8 + plan.rows * 112 + mergeChunk * 9;
|
|
454
561
|
yield* allotment.grow(filesBytes);
|
|
455
562
|
const types = Effect.gen(function* () {
|
|
@@ -459,7 +566,7 @@ const remapIndex = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
459
566
|
yield* put.write(writer.head());
|
|
460
567
|
const typesOf = layerTypes(input);
|
|
461
568
|
yield* oldTypes(input, typesOf, 0, plan.prefix, write);
|
|
462
|
-
for (const kind of writeOrder) for (let left = merged.kinds[kind]; left > 0; left -= mergeChunk) yield* write(new Uint8Array(Math.min(left, mergeChunk)).fill(typeCodes[kind]));
|
|
569
|
+
for (const kind of writeOrder) for (let left = merged.kind === "pack" ? merged.kinds[kind] : 0; left > 0; left -= mergeChunk) yield* write(new Uint8Array(Math.min(left, mergeChunk)).fill(typeCodes[kind]));
|
|
463
570
|
for (const pack of plan.tail) if (pack.next !== void 0) yield* oldTypes(input, typesOf, pack.old, pack.old + pack.objects, write);
|
|
464
571
|
const rowCodes = /* @__PURE__ */ new Map();
|
|
465
572
|
for (const run of plan.runs) yield* oldTypes(input, typesOf, run.first, run.first + run.rows, (codes, first) => Effect.sync(() => {
|
|
@@ -481,7 +588,7 @@ const remapIndex = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
481
588
|
});
|
|
482
589
|
yield* Effect.scoped(types);
|
|
483
590
|
yield* Effect.scoped(bases);
|
|
484
|
-
allotment.shrink(filesBytes + entries +
|
|
591
|
+
allotment.shrink(filesBytes + entries + map4);
|
|
485
592
|
const sha = new Sha1();
|
|
486
593
|
sha.update(regionIds);
|
|
487
594
|
if (regionIds.byteLength > 0) yield* putOnce(bucket, files.region, regionIds);
|
|
@@ -490,7 +597,7 @@ const remapIndex = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
490
597
|
groups: [{
|
|
491
598
|
packs: [
|
|
492
599
|
...plan.prefixPacks,
|
|
493
|
-
merged.pack.id,
|
|
600
|
+
...merged.kind === "pack" ? [merged.pack.id] : [],
|
|
494
601
|
...plan.tail.flatMap((pack) => pack.next === void 0 ? [] : [pack.id])
|
|
495
602
|
],
|
|
496
603
|
rows: read.kept.length
|
|
@@ -521,7 +628,29 @@ const remapIndex = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
521
628
|
return rebuilt;
|
|
522
629
|
});
|
|
523
630
|
/**
|
|
524
|
-
* The
|
|
631
|
+
* The row a merge's remap lays again, and its plan, from the row and the merge alone, as `remapRow`
|
|
632
|
+
* weighs them before any read: `undefined` when the row isn't built, is a refusal for spent tries,
|
|
633
|
+
* is marked lost, or doesn't cover the listing before the merge, but what `parts` holds; or the
|
|
634
|
+
* merge, `taken`, of `objects` objects, took a pack it doesn't cover.
|
|
635
|
+
*/
|
|
636
|
+
const remapDue = (parts, listed, taken, objects) => {
|
|
637
|
+
const row = indexRowOf({
|
|
638
|
+
...indexRowKey,
|
|
639
|
+
value: parts.row
|
|
640
|
+
});
|
|
641
|
+
if (row === void 0 || "refused" in row || row.refusal !== void 0 || row.lost === true) return void 0;
|
|
642
|
+
const held = parts.holdsUncovered === true ? pruneRemapHeld(row.layers, listed, taken) : parts.holds?.packs;
|
|
643
|
+
if (!coversListing(row.layers, listed, held)) return void 0;
|
|
644
|
+
const plan = remapPlan(row.layers, listed, taken, objects);
|
|
645
|
+
return plan === void 0 ? void 0 : {
|
|
646
|
+
row,
|
|
647
|
+
plan
|
|
648
|
+
};
|
|
649
|
+
};
|
|
650
|
+
/**
|
|
651
|
+
* The `index` row a geometric step's or a prune rewrite's merge leaves, laid again over its pack,
|
|
652
|
+
* the rewrite's dropped objects left out, or the row a prune step leaves when it empties packs
|
|
653
|
+
* with no merge, their positions gone, or `undefined` when
|
|
525
654
|
* it can't be: the row isn't built, is a refusal for spent tries, is marked lost, or doesn't
|
|
526
655
|
* cover the listing before the merge; the merge took a pack it doesn't cover; the remap
|
|
527
656
|
* declines, as `remapIndex` says; or it fails of its own, its calls run out, its allotment can't
|
|
@@ -531,14 +660,9 @@ const remapIndex = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
531
660
|
* any other failure.
|
|
532
661
|
*/
|
|
533
662
|
const remapRow = (parts, input) => Effect.scoped(Effect.gen(function* () {
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
});
|
|
538
|
-
if (row === void 0 || "refused" in row || row.refusal !== void 0 || row.lost === true) return void 0;
|
|
539
|
-
if (!coversListing(row.layers, input.listed, parts.holds?.packs)) return void 0;
|
|
540
|
-
const plan = remapPlan(row.layers, input.listed, input.taken, input.merged.pack.objects);
|
|
541
|
-
if (plan === void 0) return void 0;
|
|
663
|
+
const due = remapDue(parts, input.listed, input.taken, mergedObjects(input.merged));
|
|
664
|
+
if (due === void 0) return void 0;
|
|
665
|
+
const { row, plan } = due;
|
|
542
666
|
const { calls } = parts;
|
|
543
667
|
const built = yield* remapIndex({
|
|
544
668
|
bucket: calls === void 0 ? input.bucket : calls.within(remapCallsBound(calls.most)).bucket,
|
|
@@ -547,6 +671,7 @@ const remapRow = (parts, input) => Effect.scoped(Effect.gen(function* () {
|
|
|
547
671
|
plan,
|
|
548
672
|
merged: input.merged,
|
|
549
673
|
folded: input.folded,
|
|
674
|
+
keeps: input.keeps,
|
|
550
675
|
allotment: yield* parts.budget.upkeep(0, remapBusy),
|
|
551
676
|
at: input.at,
|
|
552
677
|
grace: parts.grace,
|
|
@@ -597,6 +722,17 @@ const coversListing = (layers, listed, held = /* @__PURE__ */ new Set()) => {
|
|
|
597
722
|
const ids = new Set(listed.packs.map((pack) => pack.id));
|
|
598
723
|
return [...covered].every((id) => ids.has(id)) && listed.packs.every((pack) => covered.has(pack.id) || held.has(pack.id));
|
|
599
724
|
};
|
|
725
|
+
/**
|
|
726
|
+
* What a prune rewrite's remap holds: each listed pack `layers` don't cover that the merge doesn't
|
|
727
|
+
* take, `taken`, as a push's pack waits for git.index's update. A cruft step's pack, listed before
|
|
728
|
+
* the rewrite's step and not yet covered, so stays out of the row it lays, and a merge never waits
|
|
729
|
+
* on git.index to drop what it drops. A pack the merge takes that the row doesn't cover still
|
|
730
|
+
* declines the remap, in `remapPlan`.
|
|
731
|
+
*/
|
|
732
|
+
const pruneRemapHeld = (layers, listed, taken) => {
|
|
733
|
+
const covered = coveredPacks(layers);
|
|
734
|
+
return new Set(listed.packs.flatMap((pack) => covered.has(pack.id) || taken.has(pack.id) ? [] : [pack.id]));
|
|
735
|
+
};
|
|
600
736
|
/** The object rows `layers` cover: each group's rows, as git.index read them. */
|
|
601
737
|
const rowsCovered = (layers) => layers.reduce((sum, layer) => sum + layer.groups.reduce((each, group) => each + group.rows, 0), 0);
|
|
602
738
|
/**
|
|
@@ -638,4 +774,4 @@ const liftsHolds = (old, now, listed) => {
|
|
|
638
774
|
const is = coveredPacks(now.layers);
|
|
639
775
|
return listed.packs.some((pack) => is.has(pack.id) && !was.has(pack.id)) || rowsCovered(now.layers) > rowsCovered(old.layers);
|
|
640
776
|
};
|
|
641
|
-
export { coversListing, defaultRemapCpuMost, indexHolds, liftsHolds, movedBits, remapCalls, remapCallsBound, remapCallsMost, remapCpuPast, remapHeldMost, remapIndex, remapPast, remapPlan, remapRow, remapUnits, replacedAtCommit };
|
|
777
|
+
export { coversListing, declinedPast, defaultRemapCpuMost, goneBuildBytes, indexHolds, liftsHolds, movedBits, pruneRemapHeld, remapCalls, remapCallsBound, remapCallsMost, remapCpuPast, remapDue, remapFits, remapHeldMost, remapIndex, remapPast, remapPlan, remapRow, remapUnits, replacedAtCommit };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { packIndexBytes } from "../protocol/packs/idx.mjs";
|
|
2
|
+
import { packPositionsBytes } from "../protocol/packs/pos.mjs";
|
|
3
|
+
import { bodyOfBytes, bucketDo, readEach } from "./calls.mjs";
|
|
4
|
+
import { indexBasesBytes, indexTypesBytes } from "./index-files.mjs";
|
|
5
|
+
import { indexGraphBytes } from "./index-graph.mjs";
|
|
6
|
+
import { indexFiles, isPackId, packFiles } from "./layout.mjs";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
// src/storage/index-whole.ts
|
|
9
|
+
/**
|
|
10
|
+
* The most a fetch reads of a small index's files whole, all at once, before its walk: 1 MiB, the
|
|
11
|
+
* writer's meter. Its files are read in turn by range otherwise, one wait each (#2523): about 23
|
|
12
|
+
* for a small fetch, at about 70 ms a get on R2. Past it, they're read by range as before.
|
|
13
|
+
*/
|
|
14
|
+
const wholeIndexMost = 1048576;
|
|
15
|
+
/**
|
|
16
|
+
* The files read at once, as the bitmaps' reads are: a small index's 6 in one round, and one over
|
|
17
|
+
* many packs in rounds of 16, never one get a file all open together.
|
|
18
|
+
*/
|
|
19
|
+
const filesAtOnce = 16;
|
|
20
|
+
/** The packs whose `.idx` holds no 8-byte offsets: under 2 GiB. */
|
|
21
|
+
const smallPackBytes = 2 ** 31;
|
|
22
|
+
/**
|
|
23
|
+
* The files a fetch's walk and send list read of an index of `layers` over `packs`: each layer's
|
|
24
|
+
* `.graph`, `.bitmaps` when it has any, `.types` and `.bases` when it has deltas, and each pack's
|
|
25
|
+
* `.idx` and `.pos`, with the least each can be from the row and the listing, no call made: a
|
|
26
|
+
* graph's octopus rows aren't in the row, so its least counts none. An index with a region's rows
|
|
27
|
+
* or a pack past 2 GiB is none of these: `undefined`, so it's read by range.
|
|
28
|
+
*/
|
|
29
|
+
const indexFilesOf = (repo, layers, packs) => {
|
|
30
|
+
const files = [];
|
|
31
|
+
for (const layer of layers) {
|
|
32
|
+
if (layer.groups.some((group) => group.rows > 0)) return void 0;
|
|
33
|
+
const at = indexFiles(repo, layer.build);
|
|
34
|
+
const positions = layer.first + layer.positions;
|
|
35
|
+
files.push({
|
|
36
|
+
key: at.graph,
|
|
37
|
+
least: indexGraphBytes(layer.commits, 0)
|
|
38
|
+
});
|
|
39
|
+
files.push({
|
|
40
|
+
key: at.types,
|
|
41
|
+
least: indexTypesBytes(layer.positions)
|
|
42
|
+
});
|
|
43
|
+
if (layer.bitmaps > 0) files.push({
|
|
44
|
+
key: at.bitmaps,
|
|
45
|
+
least: layer.table + layer.bitmaps * 20 + 20
|
|
46
|
+
});
|
|
47
|
+
if (layer.deltas > 0) files.push({
|
|
48
|
+
key: at.bases,
|
|
49
|
+
least: indexBasesBytes(positions, layer.deltas)
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
for (const pack of packs) {
|
|
53
|
+
if (pack.bytes >= smallPackBytes || !isPackId(pack.id)) return void 0;
|
|
54
|
+
const at = packFiles(pack.id);
|
|
55
|
+
files.push({
|
|
56
|
+
key: at.idx,
|
|
57
|
+
least: packIndexBytes(pack.objects, 0)
|
|
58
|
+
});
|
|
59
|
+
files.push({
|
|
60
|
+
key: at.pos,
|
|
61
|
+
least: packPositionsBytes(pack.objects)
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return files;
|
|
65
|
+
};
|
|
66
|
+
/** A file read whole past what was left of the bound. */
|
|
67
|
+
var PastBound = class {
|
|
68
|
+
_tag = "PastBound";
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Each of `files` read whole, `filesAtOnce` at a time, their buffers together at most `most`:
|
|
72
|
+
* `undefined` when they pass it, so the caller reads by range, as before. Each file's chunks are
|
|
73
|
+
* copied as they come into one buffer, the file's least to start, charged before it's made, so
|
|
74
|
+
* no chunk is kept and nothing live goes uncharged: one too small for a chunk is made again, at
|
|
75
|
+
* twice its size or the chunk's need, both charged while the copy runs, and the old one given
|
|
76
|
+
* back after. An empty chunk is skipped. A read's failure is the fetch's, as one by range is.
|
|
77
|
+
*/
|
|
78
|
+
const wholeFiles = (bucket, files, most) => Effect.suspend(() => {
|
|
79
|
+
let left = most;
|
|
80
|
+
const read = (file) => Effect.suspend(() => {
|
|
81
|
+
let held = /* @__PURE__ */ new Uint8Array(0);
|
|
82
|
+
let length = 0;
|
|
83
|
+
/** `held` made again with room for `need`, charged first: false past the bound. */
|
|
84
|
+
const grow = (need) => {
|
|
85
|
+
const size = Math.max(need, Math.min(held.byteLength * 2, left));
|
|
86
|
+
if (size > left) return false;
|
|
87
|
+
left -= size;
|
|
88
|
+
const next = new Uint8Array(size);
|
|
89
|
+
next.set(held.subarray(0, length));
|
|
90
|
+
left += held.byteLength;
|
|
91
|
+
held = next;
|
|
92
|
+
return true;
|
|
93
|
+
};
|
|
94
|
+
const take = (chunk) => {
|
|
95
|
+
if (chunk.byteLength === 0) return Effect.void;
|
|
96
|
+
if (length + chunk.byteLength > held.byteLength && !grow(length + chunk.byteLength)) return Effect.fail(new PastBound());
|
|
97
|
+
held.set(chunk, length);
|
|
98
|
+
length += chunk.byteLength;
|
|
99
|
+
return Effect.void;
|
|
100
|
+
};
|
|
101
|
+
if (!grow(file.least)) return Effect.succeed(void 0);
|
|
102
|
+
return bucketDo(readEach(bucket, file.key, void 0, take).pipe(Effect.map(() => [file.key, held.subarray(0, length)]), Effect.catchTag("PastBound", () => Effect.succeed(void 0))));
|
|
103
|
+
});
|
|
104
|
+
return Effect.map(Effect.forEach(files, read, { concurrency: filesAtOnce }), (read) => {
|
|
105
|
+
const held = read.filter((file) => file !== void 0);
|
|
106
|
+
return held.length === files.length ? {
|
|
107
|
+
files: new Map(held),
|
|
108
|
+
bytes: most - left
|
|
109
|
+
} : void 0;
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* `bucket`, each of `files` read from the bytes held, with no call: a range as the bucket answers
|
|
114
|
+
* it, cut at the file's end, and the whole file without one. Every other key reads through.
|
|
115
|
+
*/
|
|
116
|
+
const heldFiles = (bucket, files) => ({
|
|
117
|
+
...bucket,
|
|
118
|
+
read: (key, range) => {
|
|
119
|
+
const whole = files.get(key);
|
|
120
|
+
if (whole === void 0) return bucket.read(key, range);
|
|
121
|
+
if (range === void 0) return bodyOfBytes(whole);
|
|
122
|
+
const from = Math.min(range.offset, whole.byteLength);
|
|
123
|
+
const to = Math.max(from, Math.min(range.offset + range.length, whole.byteLength));
|
|
124
|
+
return bodyOfBytes(whole.subarray(from, to));
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
export { heldFiles, indexFilesOf, wholeFiles, wholeIndexMost };
|
|
@@ -42,7 +42,7 @@ var LargestFiles = class {
|
|
|
42
42
|
/** The largest of `objects`' blobs, as `LargestFiles` keeps them: a receive kept as rows. */
|
|
43
43
|
const largestOf = (objects) => {
|
|
44
44
|
const largest = new LargestFiles();
|
|
45
|
-
for (const object of objects) if (object.type === "blob") largest.add(object.oid, object.bytes.byteLength);
|
|
45
|
+
for (const object of objects) if (object.type === "blob") largest.add(object.oid, "size" in object ? object.size : object.bytes.byteLength);
|
|
46
46
|
return largest.finish();
|
|
47
47
|
};
|
|
48
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`. */
|
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>;
|