@ref0/git 0.20.0 → 0.25.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 +1 -1
- package/dist/auth/access-jwt.mjs +3 -3
- package/dist/auth/auth-namespace.d.mts +3 -3
- package/dist/auth/auth-namespace.mjs +3 -2
- package/dist/auth/auth.d.mts +3 -3
- package/dist/auth/auth.mjs +9 -8
- package/dist/auth/authorize.mjs +1 -1
- package/dist/auth/fences.d.mts +1 -1
- package/dist/auth/host-function.mjs +1 -1
- package/dist/auth/host-services.mjs +4 -6
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +6 -0
- package/dist/auth/token-cleanup.mjs +2 -2
- package/dist/auth/token-rows.mjs +6 -1
- package/dist/auth/token-text.mjs +1 -1
- package/dist/auth/tokens-base.d.mts +1 -1
- package/dist/auth/tokens.d.mts +1 -1
- package/dist/auth/tokens.mjs +1 -1
- package/dist/client/client.d.mts +15 -7
- package/dist/client/client.mjs +21 -12
- package/dist/client/git-http.mjs +1 -1
- package/dist/client/local.mjs +60 -24
- package/dist/client/negotiate.mjs +3 -3
- package/dist/client/push-upload.mjs +26 -10
- package/dist/client/remote.mjs +4 -3
- package/dist/client/run-remote-helper.d.mts +2 -2
- package/dist/client/run-remote-helper.mjs +6 -6
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +3 -3
- package/dist/contracts/blobs.d.mts +3 -3
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/calls-spent.mjs +5 -33
- package/dist/contracts/client.d.mts +15 -14
- package/dist/contracts/commits.d.mts +4 -4
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +2 -2
- package/dist/contracts/events.d.mts +1 -1
- package/dist/contracts/events.mjs +1 -1
- package/dist/contracts/files.d.mts +4 -4
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +4 -4
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +9 -5
- package/dist/contracts/grants.d.mts +1 -1
- package/dist/contracts/merges.d.mts +1 -1
- package/dist/contracts/object-values.d.mts +1 -0
- package/dist/contracts/object-values.mjs +16 -1
- package/dist/contracts/objects.d.mts +20 -17
- package/dist/contracts/opaque.mjs +1 -1
- package/dist/contracts/operations.mjs +1 -1
- package/dist/contracts/queue.d.mts +208 -44
- package/dist/contracts/queue.mjs +5 -5
- package/dist/contracts/refs.d.mts +5 -5
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +3 -6
- package/dist/contracts/repos.d.mts +3 -3
- package/dist/contracts/repos.mjs +1 -1
- package/dist/contracts/result.d.mts +10 -7
- package/dist/contracts/result.mjs +8 -3
- package/dist/contracts/rules.d.mts +2 -2
- package/dist/contracts/server.d.mts +8 -10
- package/dist/contracts/services.d.mts +6 -9
- package/dist/contracts/services.mjs +1 -2
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +2 -2
- package/dist/contracts/sync.d.mts +63 -6
- package/dist/contracts/sync.mjs +3 -2
- package/dist/contracts/tags.d.mts +3 -3
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +2 -2
- package/dist/contracts/tokens.mjs +1 -1
- package/dist/contracts/topics.d.mts +9 -9
- package/dist/contracts/trees.d.mts +4 -4
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +4 -4
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +1 -1
- package/dist/core/ancestry.mjs +30 -34
- package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
- package/dist/core/call-services.mjs +1 -1
- package/dist/core/events/deliver.d.mts +2 -2
- package/dist/core/events/deliver.mjs +3 -3
- package/dist/core/events/retired.mjs +1 -1
- package/dist/core/forks.mjs +5 -5
- package/dist/core/hooks/groups.mjs +2 -2
- package/dist/core/imports.mjs +101 -21
- package/dist/core/index-job.mjs +14 -9
- package/dist/core/index-lost.d.mts +1 -1
- package/dist/core/loose-tally.mjs +38 -15
- package/dist/core/merge-parts.d.mts +17 -4
- package/dist/core/merge-parts.mjs +7 -2
- package/dist/core/mirror-rows.mjs +31 -1
- package/dist/core/objects/blobs.mjs +8 -10
- package/dist/core/objects/files.mjs +20 -17
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/peel.mjs +1 -7
- package/dist/core/objects/reading.mjs +19 -18
- package/dist/core/objects/tree-edits.mjs +1 -1
- package/dist/core/objects/trees.mjs +257 -58
- package/dist/core/objects/writing.mjs +3 -9
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +8 -1
- package/dist/core/parts.mjs +8 -4
- package/dist/core/purge.mjs +31 -18
- package/dist/core/push.d.mts +2 -2
- package/dist/core/push.mjs +125 -94
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +9 -2
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +74 -31
- package/dist/core/refs.mjs +3 -3
- package/dist/core/repack.mjs +25 -30
- package/dist/core/repo-info.mjs +1 -1
- package/dist/core/repos.mjs +1 -1
- package/dist/core/rules/changes.mjs +18 -40
- package/dist/core/rules/check.mjs +6 -5
- package/dist/core/rules/commit-changes.mjs +3 -15
- package/dist/core/rules/context.d.mts +3 -3
- package/dist/core/rules/context.mjs +18 -14
- package/dist/core/rules/fetch.mjs +1 -1
- package/dist/core/rules/protect.mjs +30 -17
- package/dist/core/saved-caller-views.d.mts +1 -1
- package/dist/core/saved-caller-views.mjs +3 -3
- package/dist/core/saved-callers.d.mts +1 -1
- package/dist/core/saved-callers.mjs +1 -1
- package/dist/core/seam.d.mts +1 -2
- package/dist/core/view.d.mts +6 -3
- package/dist/core/view.mjs +11 -10
- package/dist/core/work.mjs +2 -2
- package/dist/engine/allotted-xdiff.mjs +3 -16
- package/dist/engine/combined.d.mts +3 -0
- package/dist/engine/combined.mjs +200 -185
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/merge.mjs +7 -9
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +22 -14
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +1 -1
- 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 +2 -2
- package/dist/event-streams/stream.mjs +3 -3
- package/dist/extend.d.mts +2 -6
- package/dist/extend.mjs +1 -5
- package/dist/http/core-parts.mjs +83 -26
- package/dist/http/handler.mjs +54 -9
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +138 -24
- package/dist/http/push-uploads.mjs +2 -2
- package/dist/http/receive-pack.mjs +14 -53
- package/dist/http/request-snapshot.mjs +258 -0
- package/dist/http/upload-pack.mjs +23 -18
- package/dist/index.d.mts +29 -21
- package/dist/index.mjs +11 -2
- package/dist/lfs/base.d.mts +1 -1
- package/dist/lfs/copy.d.mts +49 -1
- package/dist/lfs/copy.mjs +135 -22
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +4 -5
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -1
- package/dist/lfs/objects.mjs +3 -3
- package/dist/lfs/pointers.mjs +1 -1
- package/dist/lfs/rows.d.mts +1 -1
- package/dist/lfs/rows.mjs +11 -4
- package/dist/lfs/upkeep.mjs +40 -9
- package/dist/lfs/uploaded.mjs +1 -1
- package/dist/lfs/wire.mjs +1 -1
- package/dist/merges/merges.mjs +17 -2
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +1 -1
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +1 -1
- package/dist/protocol/diff/read.d.mts +2 -1
- package/dist/protocol/diff/read.mjs +102 -8
- package/dist/protocol/packs/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +1 -1
- package/dist/protocol/packs/idx.mjs +1 -1
- package/dist/protocol/packs/parts.mjs +1 -1
- package/dist/protocol/packs/reader.d.mts +1 -1
- package/dist/protocol/packs/reader.mjs +1 -1
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +3 -3
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +3 -2
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +9 -1
- package/dist/protocol/wire/lines.mjs +28 -1
- package/dist/protocol/wire/push-uploads.mjs +10 -7
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +1 -1
- package/dist/protocol/wire/v2.mjs +1 -1
- package/dist/queue/advance.mjs +31 -24
- package/dist/queue/base.d.mts +5 -3
- package/dist/queue/calls.mjs +5 -5
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -1
- package/dist/queue/layer.d.mts +0 -1
- package/dist/queue/layer.mjs +9 -5
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +1 -1
- package/dist/queue/state.mjs +1 -1
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/client.d.mts +1 -1
- package/dist/rest/client.mjs +6 -6
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/handler.mjs +2 -2
- package/dist/rest/handlers.mjs +16 -6
- package/dist/rest/layer.mjs +1 -1
- package/dist/rest/listen.mjs +2 -2
- package/dist/rest/refs.mjs +1 -1
- package/dist/server/edge.mjs +27 -3
- package/dist/server/git-layer.d.mts +1 -2
- package/dist/server/git-layer.mjs +4 -5
- package/dist/server/lifecycle.mjs +1 -1
- package/dist/server/registry.mjs +2 -8
- package/dist/server/server.mjs +62 -43
- package/dist/signin/context.d.mts +1 -1
- package/dist/signin/context.mjs +1 -1
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -2
- package/dist/signin/grants.mjs +1 -1
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/allotted.mjs +4 -9
- package/dist/storage/batch-upkeep.mjs +31 -12
- package/dist/storage/batches.d.mts +2 -3
- package/dist/storage/batches.mjs +52 -49
- package/dist/storage/budget.mjs +23 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +41 -43
- package/dist/storage/charged-cache.mjs +180 -0
- package/dist/storage/chunks.d.mts +3 -3
- package/dist/storage/chunks.mjs +121 -8
- package/dist/storage/counted-bucket.mjs +32 -10
- package/dist/storage/fetch-row-cache.d.mts +6 -0
- package/dist/storage/fetch-row-cache.mjs +211 -0
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +54 -242
- package/dist/storage/held-types.d.mts +0 -1
- package/dist/storage/host-bucket.mjs +9 -4
- package/dist/storage/index-bitmaps.mjs +77 -49
- package/dist/storage/index-build.d.mts +2 -3
- package/dist/storage/index-build.mjs +248 -48
- package/dist/storage/index-fetch.d.mts +3 -1
- package/dist/storage/index-fetch.mjs +60 -21
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +55 -25
- package/dist/storage/index-reach.mjs +15 -22
- package/dist/storage/index-whole.d.mts +7 -0
- package/dist/storage/index-whole.mjs +145 -37
- package/dist/storage/largest-files.mjs +1 -7
- package/dist/storage/layout.mjs +17 -1
- package/dist/storage/lfs-pointers.mjs +1 -6
- package/dist/storage/link-join.mjs +55 -16
- package/dist/storage/list-source.d.mts +7 -0
- package/dist/storage/list-source.mjs +288 -0
- package/dist/storage/loose.d.mts +8 -8
- package/dist/storage/loose.mjs +157 -91
- package/dist/storage/memory-budget.mjs +226 -22
- package/dist/storage/merge-cut.mjs +9 -6
- package/dist/storage/merge-fence.mjs +1 -1
- package/dist/storage/merge-row.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -3
- package/dist/storage/merge.mjs +2 -2
- package/dist/storage/object-rows.d.mts +3 -3
- package/dist/storage/object-rows.mjs +179 -38
- package/dist/storage/pack-order.mjs +97 -44
- package/dist/storage/pack-ranges.mjs +44 -16
- package/dist/storage/pack-reads.d.mts +5 -3
- package/dist/storage/pack-reads.mjs +236 -72
- package/dist/storage/pack-receive.d.mts +1 -2
- package/dist/storage/pack-receive.mjs +21 -17
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +477 -116
- package/dist/storage/placed-reads.mjs +33 -16
- package/dist/storage/prune-seen.mjs +1 -1
- package/dist/storage/prune-walk.mjs +1 -1
- package/dist/storage/prune.mjs +4 -31
- package/dist/storage/push-allotment.mjs +26 -14
- package/dist/storage/push-uploads.mjs +195 -57
- package/dist/storage/pushed-commits.mjs +20 -1
- package/dist/storage/quarantine.d.mts +2 -3
- package/dist/storage/range-cache.mjs +175 -40
- package/dist/storage/raw-ids.mjs +39 -10
- package/dist/storage/ready.d.mts +2 -3
- package/dist/storage/ready.mjs +114 -38
- package/dist/storage/receive-bounds.mjs +31 -9
- package/dist/storage/receive-cache.d.mts +7 -0
- package/dist/storage/receive-cache.mjs +147 -0
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +6 -8
- package/dist/storage/receive-steps.d.mts +20 -0
- package/dist/storage/receive-steps.mjs +298 -13
- package/dist/storage/repack-backlog.mjs +1 -6
- package/dist/storage/repack-contained.mjs +2 -2
- package/dist/storage/repack-job.mjs +1 -1
- package/dist/storage/repack.d.mts +2 -3
- package/dist/storage/repack.mjs +54 -9
- package/dist/storage/request-cache.mjs +57 -0
- package/dist/storage/roots.mjs +1 -24
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +1 -1
- package/dist/storage/send-list.mjs +62 -25
- package/dist/storage/stream-whole.mjs +84 -63
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +878 -450
- package/dist/storage/visible.mjs +110 -32
- package/dist/storage/walk.mjs +1 -0
- package/dist/storage/wants.mjs +22 -58
- package/dist/store/call-count.d.mts +2 -2
- package/dist/store/call-count.mjs +24 -11
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +19 -7
- package/dist/store/crossing.mjs +1 -7
- package/dist/store/cursor-seal.d.mts +1 -1
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/door.mjs +9 -4
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +107 -19
- package/dist/store/git-store.mjs +7 -2
- package/dist/store/job-try.mjs +90 -9
- package/dist/store/list-job.mjs +10 -34
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +2 -2
- package/dist/store/queue-jobs.mjs +6 -12
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +2 -2
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +2 -2
- package/dist/store/repo-record.d.mts +2 -2
- package/dist/store/repo-record.mjs +3 -3
- package/dist/store/request-snapshot.mjs +5 -0
- package/dist/store/reservations.mjs +2 -2
- package/dist/store/topic-jobs.mjs +5 -11
- package/dist/sync/bound.d.mts +3 -3
- package/dist/sync/bound.mjs +10 -7
- package/dist/sync/github.mjs +65 -67
- package/dist/sync/http.mjs +1 -1
- package/dist/sync/import.mjs +201 -66
- package/dist/sync/layer.d.mts +1 -1
- package/dist/sync/layer.mjs +6 -6
- package/dist/sync/lfs-batch.mjs +1 -1
- package/dist/sync/lfs-copy.mjs +175 -15
- package/dist/sync/mirror.mjs +5 -10
- package/dist/sync/said.mjs +1 -1
- package/dist/sync/step.mjs +268 -86
- package/dist/sync/tries.mjs +25 -6
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +3 -3
- package/dist/topics/calls.mjs +1 -1
- package/dist/topics/layer.d.mts +15 -14
- package/dist/topics/members.mjs +1 -1
- package/dist/topics/topic.mjs +1 -1
- package/package.json +3 -13
- package/dist/auth/helpers.mjs +0 -17
- package/dist/auth.d.mts +0 -5
- package/dist/auth.mjs +0 -5
- package/dist/core/rules/commit-changes.d.mts +0 -12
- package/dist/effect.d.mts +0 -9
- package/dist/effect.mjs +0 -7
- package/dist/server/joined.d.mts +0 -70
- package/dist/server/joined.mjs +0 -41
|
@@ -4,13 +4,13 @@ import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
|
4
4
|
import { Sha1 } from "../protocol/bytes/sha1.mjs";
|
|
5
5
|
import { writeCommitGraph } from "../protocol/packs/graph.mjs";
|
|
6
6
|
import { IndexerCache } from "../protocol/packs/indexer.mjs";
|
|
7
|
-
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
7
|
+
import { indexHeadBytes, oidBytes, tablesOf } from "../protocol/packs/idx.mjs";
|
|
8
8
|
import { noRepoRoots } from "../protocol/objects/commit.mjs";
|
|
9
9
|
import { rawLinks } from "../protocol/objects/links-raw.mjs";
|
|
10
10
|
import { rootsDigest } from "../store/repo-record.mjs";
|
|
11
11
|
import { randomText } from "../store/random.mjs";
|
|
12
12
|
import { allottableOf, uploadPartBytes } from "./budget.mjs";
|
|
13
|
-
import { bucketDo, bucketPut, joined, readEach, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
|
|
13
|
+
import { bucketDeleteMany, bucketDo, bucketPut, joined, readEach, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
|
|
14
14
|
import { BitmapsPart, EdgeFiles, bitmapOrder, bitmapsMostBytes, bitmapsPut, copyBitmaps, copyHeldBytes, copyRunBytes, edgesBytesOf, edgesFileOf, ewahMostWords, noNumber, orderKey, partBitmaps, partBytesMost, runsMost, storedBitmaps, storedSize, writeBitmaps } from "./index-bitmaps.mjs";
|
|
15
15
|
import { BasesWriter, TypesWriter, indexBasesBytes, indexTypesBytes, openBases, openTypes, typeCodes } from "./index-files.mjs";
|
|
16
16
|
import { bitmapOf, bitmapWords, ewahOf, orEwah } from "./ewah.mjs";
|
|
@@ -27,9 +27,9 @@ import { PackBlocks, blocksHeld, packIndexerLimits } from "./pack-reads.mjs";
|
|
|
27
27
|
import { rangeRanks, readExactly } from "./pack-ranges.mjs";
|
|
28
28
|
import { rangeCached, wholeCached } from "./range-cache.mjs";
|
|
29
29
|
import { compareIds } from "./raw-ids.mjs";
|
|
30
|
+
import * as Schema from "effect/Schema";
|
|
30
31
|
import * as Effect from "effect/Effect";
|
|
31
32
|
import * as Option from "effect/Option";
|
|
32
|
-
import * as Schema from "effect/Schema";
|
|
33
33
|
import * as Cause from "effect/Cause";
|
|
34
34
|
import * as Result from "effect/Result";
|
|
35
35
|
// src/storage/index-build.ts
|
|
@@ -46,6 +46,11 @@ import * as Result from "effect/Result";
|
|
|
46
46
|
* Its files are under `index/<repo>/`, a build's own under its ID, so prune lists one repo's.
|
|
47
47
|
*/
|
|
48
48
|
const lost = (message) => gitError("DATA_LOSS", message);
|
|
49
|
+
/**
|
|
50
|
+
* Safety wait when a published staged batch holds back `git.index`: `core/repack.ts` wakes
|
|
51
|
+
* `git.index` immediately when the batch finishes promoting, so this only backs up a stalled run.
|
|
52
|
+
*/
|
|
53
|
+
const batchWaitMs = 3e4;
|
|
49
54
|
/** A build's ID, new for each: `i_` and 12 random bytes. */
|
|
50
55
|
const newBuildId = () => `i_${randomText(12)}`;
|
|
51
56
|
const Count = /* @__PURE__ */ Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
@@ -136,7 +141,12 @@ const IndexData = /* @__PURE__ */ Schema.Struct({
|
|
|
136
141
|
const BitmapsCut = /* @__PURE__ */ Schema.Struct({
|
|
137
142
|
order: Schema.String,
|
|
138
143
|
done: Count,
|
|
139
|
-
parts: Schema.Array(Count)
|
|
144
|
+
parts: Schema.Array(Count),
|
|
145
|
+
/**
|
|
146
|
+
* Digest (`rootsDigest`) of the tips the cut finished for: when equal to the join try's tips,
|
|
147
|
+
* `bitmapsWritten` joins directly without re-opening pack layout, graph, or region (#596).
|
|
148
|
+
*/
|
|
149
|
+
ready: Schema.optionalKey(Schema.String)
|
|
140
150
|
});
|
|
141
151
|
/** A build its row no longer names, kept readable until `at` and prune's grace pass. */
|
|
142
152
|
const ReplacedBuild = /* @__PURE__ */ Schema.Struct({
|
|
@@ -629,6 +639,14 @@ const joinCharged = (links, ranges, region, allotment) => {
|
|
|
629
639
|
return Effect.acquireUseRelease(allotment.grow(bytes), () => joinLinks(links, ranges, region), () => Effect.sync(() => allotment.shrink(bytes)));
|
|
630
640
|
};
|
|
631
641
|
/**
|
|
642
|
+
* Rows to a page of the region's read: a scan at 1,000 objects reads in 2 store reads, not 11,
|
|
643
|
+
* so a commit landing mid-scan rarely moves it (#2974). A page past 16 MiB steps down through
|
|
644
|
+
* `eachPageAt`'s fallback, as a clone's `wholePageRows` page does. The page itself is held
|
|
645
|
+
* uncharged while its rows are parsed, as at 100 rows: one answer is at most 16 MiB either way,
|
|
646
|
+
* and about 140 KiB at 1,000 objects.
|
|
647
|
+
*/
|
|
648
|
+
const regionPageRows = 1e3;
|
|
649
|
+
/**
|
|
632
650
|
* The repo's object rows at `listed`'s version, each one a region position after the packs':
|
|
633
651
|
* their IDs, the SHA-1 of those, and, for the region step, their types, links and commits.
|
|
634
652
|
* `undefined` once the repo moved under the read.
|
|
@@ -636,7 +654,7 @@ const joinCharged = (links, ranges, region, allotment) => {
|
|
|
636
654
|
const readRegion = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, each, skip) {
|
|
637
655
|
let ids = /* @__PURE__ */ new Uint8Array(1280);
|
|
638
656
|
let rows = 0;
|
|
639
|
-
|
|
657
|
+
const whole = yield* eachPageAt(parts.store, listed.repo, listed.version, (page) => Effect.gen(function* () {
|
|
640
658
|
for (const row of page) {
|
|
641
659
|
if (skip?.has(row.id) === true) continue;
|
|
642
660
|
if ((rows + 1) * 20 > ids.length) {
|
|
@@ -649,7 +667,8 @@ const readRegion = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, e
|
|
|
649
667
|
rows += 1;
|
|
650
668
|
}
|
|
651
669
|
return true;
|
|
652
|
-
})
|
|
670
|
+
}), void 0, regionPageRows);
|
|
671
|
+
if (whole !== "done") return whole;
|
|
653
672
|
const sha = new Sha1();
|
|
654
673
|
sha.update(ids.subarray(0, rows * 20));
|
|
655
674
|
return {
|
|
@@ -663,11 +682,24 @@ const readRegion = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, e
|
|
|
663
682
|
* charged to `allotment`: its links as they grow, and each row's ID, type and commit entry and
|
|
664
683
|
* the row's own bytes while it's parsed.
|
|
665
684
|
*/
|
|
666
|
-
const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
|
|
685
|
+
const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment, onStart) {
|
|
667
686
|
const { bucket } = parts;
|
|
668
687
|
const files = indexFiles(listed.repo, data.build);
|
|
669
|
-
|
|
670
|
-
|
|
688
|
+
let layout;
|
|
689
|
+
let held;
|
|
690
|
+
let packed;
|
|
691
|
+
if (data.below.length > 0) {
|
|
692
|
+
const belowRead = yield* readRegion(parts, listed);
|
|
693
|
+
if (belowRead === "batched") return "batched";
|
|
694
|
+
if (belowRead === "moved") return void 0;
|
|
695
|
+
const opened = yield* layoutOf(bucket, listed, data);
|
|
696
|
+
layout = opened.layout;
|
|
697
|
+
packed = opened.packed;
|
|
698
|
+
held = yield* heldInLayers(belowRead, opened.layout, opened.first);
|
|
699
|
+
} else {
|
|
700
|
+
const byId = new Map(listed.packs.map((pack) => [pack.id, pack]));
|
|
701
|
+
packed = data.packs.reduce((sum, id) => sum + (byId.get(id)?.objects ?? 0), 0);
|
|
702
|
+
}
|
|
671
703
|
const roots = rootsIn(parts);
|
|
672
704
|
const links = new SliceLinks((bytes) => allotment.tryGrow(bytes));
|
|
673
705
|
const types = [];
|
|
@@ -697,7 +729,9 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
|
|
|
697
729
|
yield* allotment.grow(regionRowBytes + object.bytes.byteLength);
|
|
698
730
|
yield* parsed(object, at).pipe(Effect.ensuring(Effect.sync(() => allotment.shrink(object.bytes.byteLength))));
|
|
699
731
|
}), held);
|
|
700
|
-
if (read ===
|
|
732
|
+
if (read === "batched") return "batched";
|
|
733
|
+
if (read === "moved") return void 0;
|
|
734
|
+
if (onStart !== void 0) yield* onStart();
|
|
701
735
|
const done = {
|
|
702
736
|
...data,
|
|
703
737
|
rows: read.rows,
|
|
@@ -706,8 +740,9 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
|
|
|
706
740
|
};
|
|
707
741
|
if (rootPositions.size > 0) done.rootPositions = withPositions(data.rootPositions, rootPositions);
|
|
708
742
|
if (read.rows === 0) return done;
|
|
709
|
-
const
|
|
710
|
-
const
|
|
743
|
+
const openedLayout = layout ?? (yield* layoutOf(bucket, listed, data)).layout;
|
|
744
|
+
const region = withRows(openedLayout.region, packed, read.ids);
|
|
745
|
+
const targets = yield* joinCharged(links, openedLayout.ranges, region, allotment);
|
|
711
746
|
const slice = data.slices.length;
|
|
712
747
|
yield* allotment.grow(edgesMostOf(links) + read.rows + graphFileBytes(commits));
|
|
713
748
|
const edges = edgesFileOf(files.edges(slice, read.rows), packed, read.rows, links, targets, rootPositions);
|
|
@@ -725,13 +760,12 @@ const regionStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, d
|
|
|
725
760
|
};
|
|
726
761
|
});
|
|
727
762
|
/**
|
|
728
|
-
* The rows the layers below hold, which an update's region leaves at their
|
|
729
|
-
*
|
|
763
|
+
* The rows of `read` that the layers below hold, which an update's region leaves at their
|
|
764
|
+
* positions there: each found among the layers below `first`, kept by ID.
|
|
730
765
|
*/
|
|
731
|
-
const
|
|
732
|
-
const read = yield* readRegion(parts, listed);
|
|
766
|
+
const heldInLayers = /* @__PURE__ */ Effect.fnUntraced(function* (read, layout, first) {
|
|
733
767
|
const held = /* @__PURE__ */ new Set();
|
|
734
|
-
if (read
|
|
768
|
+
if (read.rows === 0) return held;
|
|
735
769
|
const positions = yield* layout.positionsOf(read.ids, read.rows);
|
|
736
770
|
for (let at = 0; at < read.rows; at += 1) if ((positions[at] ?? 4294967295) < first) held.add(hexOf(read.ids.subarray(at * 20, at * 20 + 20)));
|
|
737
771
|
return held;
|
|
@@ -848,8 +882,14 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, dat
|
|
|
848
882
|
offset: data.offset,
|
|
849
883
|
position: data.position
|
|
850
884
|
};
|
|
851
|
-
const
|
|
852
|
-
const opened = yield* Effect.result(cutAtSpent(
|
|
885
|
+
const primed = yield* roomyReadJoins(bucket, listed, data, allotment);
|
|
886
|
+
const opened = yield* Effect.result(cutAtSpent(primed === void 0 ? layoutOf(bucket, listed, data) : Effect.andThen(Effect.all(primed.prime.map(({ key, offset, length }) => primed.joins.prime(key, {
|
|
887
|
+
offset,
|
|
888
|
+
length
|
|
889
|
+
})), {
|
|
890
|
+
concurrency: 6,
|
|
891
|
+
discard: true
|
|
892
|
+
}), layoutOf(primed.joins.bucket, listed, data, { cached: true }))));
|
|
853
893
|
if (Result.isFailure(opened)) {
|
|
854
894
|
const spent = spentOf(opened.failure);
|
|
855
895
|
if (spent === void 0) return yield* Effect.fail(opened.failure);
|
|
@@ -895,9 +935,14 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, dat
|
|
|
895
935
|
yield* allotment.grow(edgesMostOf(links) + slice.bases.length * 4);
|
|
896
936
|
const positions = slice.types.length;
|
|
897
937
|
const made = edgesFileOf(files.edges(number, positions), first, positions, links, targets, slice.roots);
|
|
898
|
-
yield*
|
|
899
|
-
|
|
900
|
-
|
|
938
|
+
yield* Effect.all([
|
|
939
|
+
putOnce(bucket, made.slice.key, made.bytes),
|
|
940
|
+
putOnce(bucket, files.typesPart(number, positions), slice.types),
|
|
941
|
+
putOnce(bucket, files.basesPart(number, positions), wordsBytes(slice.bases))
|
|
942
|
+
], {
|
|
943
|
+
concurrency: 3,
|
|
944
|
+
discard: true
|
|
945
|
+
});
|
|
901
946
|
return made;
|
|
902
947
|
}).pipe(cutAtSpent, Effect.catchIf((error) => spentOf(error) !== void 0, () => Effect.fail(reserveShort(data.packs[data.pack] ?? "", at.position, whole))));
|
|
903
948
|
const slices = [...data.slices, {
|
|
@@ -1146,6 +1191,50 @@ const bitmapsJoinMost = 25165824;
|
|
|
1146
1191
|
* `bitmapsJoinMost`. It's what a join can read, from the counts alone, never what a try did.
|
|
1147
1192
|
*/
|
|
1148
1193
|
const bitmapsJoinHeld = (objects) => Math.min(bitmapsJoinMost, objects.reduce((sum, count) => sum + count * 24 + Math.ceil(count / rangeRanks) * 2 * 320, 0));
|
|
1194
|
+
/** The `.idx` and `.pos` spans `readStep` primes for a pack of `objects` objects, with offsets when active and non-empty. */
|
|
1195
|
+
const readPackSpans = (objects, withOffsets) => {
|
|
1196
|
+
const spans = [{
|
|
1197
|
+
file: "idx",
|
|
1198
|
+
offset: 0,
|
|
1199
|
+
length: indexHeadBytes + objects * 20
|
|
1200
|
+
}, {
|
|
1201
|
+
file: "pos",
|
|
1202
|
+
offset: 0,
|
|
1203
|
+
length: 12 + objects * 4
|
|
1204
|
+
}];
|
|
1205
|
+
if (withOffsets && objects > 0) spans.push({
|
|
1206
|
+
file: "idx",
|
|
1207
|
+
offset: tablesOf(objects).offsets,
|
|
1208
|
+
length: objects * 4
|
|
1209
|
+
});
|
|
1210
|
+
return spans;
|
|
1211
|
+
};
|
|
1212
|
+
/** The room primed `.idx` and `.pos` spans cost, bytes plus one entry charge a span. */
|
|
1213
|
+
const readSpansCost = (spans) => spans.reduce((sum, span) => sum + span.length + 320, 0);
|
|
1214
|
+
/**
|
|
1215
|
+
* What a read step holds for the primed `.idx` and `.pos` tables of packs of `objects` objects,
|
|
1216
|
+
* the active pack at `active` (0 by default) also holding its `.idx` offsets when non-empty:
|
|
1217
|
+
* derived from `readPackSpans` and capped at `bitmapsJoinMost` (#664).
|
|
1218
|
+
*/
|
|
1219
|
+
const readJoinHeld = (objects, active = 0) => Math.min(bitmapsJoinMost, objects.reduce((sum, count, at) => sum + readSpansCost(readPackSpans(count, at === active)), 0));
|
|
1220
|
+
/** The covered packs for `readStep`, active pack first so it gets priming room before the rest. */
|
|
1221
|
+
const readPacksOf = (listed, data) => {
|
|
1222
|
+
const covered = new Set([...data.below, spanOf(data)].flatMap((layer) => layer.groups.flatMap((group) => group.packs)));
|
|
1223
|
+
const activeId = data.packs[data.pack];
|
|
1224
|
+
const packs = listed.packs.filter(({ id }) => covered.has(id));
|
|
1225
|
+
const active = packs.find(({ id }) => id === activeId);
|
|
1226
|
+
return active === void 0 ? packs : [active, ...packs.filter(({ id }) => id !== activeId)];
|
|
1227
|
+
};
|
|
1228
|
+
/** The `.idx` and `.pos` ranges `readStep` primes for one pack, keyed onto `packFiles(pack.id)`. */
|
|
1229
|
+
const readPackRanges = (pack, withOffsets) => {
|
|
1230
|
+
if (!isPackId(pack.id)) return [];
|
|
1231
|
+
const files = packFiles(pack.id);
|
|
1232
|
+
return readPackSpans(pack.objects, withOffsets).map(({ file, offset, length }) => ({
|
|
1233
|
+
key: files[file],
|
|
1234
|
+
offset,
|
|
1235
|
+
length
|
|
1236
|
+
}));
|
|
1237
|
+
};
|
|
1149
1238
|
/** What a step keeps of its layout's join ranges, `bitmapsJoinHeld` over the packs `data` covers. */
|
|
1150
1239
|
const joinsHeldOf = (listed, data) => {
|
|
1151
1240
|
const covered = new Set([...data.below, spanOf(data)].flatMap((layer) => layer.groups.flatMap((group) => group.packs)));
|
|
@@ -1184,6 +1273,31 @@ const roomy = (allotment, held, make, drop) => {
|
|
|
1184
1273
|
}));
|
|
1185
1274
|
};
|
|
1186
1275
|
/**
|
|
1276
|
+
* The read step's primed `.idx` and `.pos` tables in a room of `readJoinHeld`: granted before any
|
|
1277
|
+
* prime starts, dropped if the room shrinks, and skipped for any pack past what's left (#664).
|
|
1278
|
+
*/
|
|
1279
|
+
const roomyReadJoins = (bucket, listed, data, allotment) => {
|
|
1280
|
+
const packs = readPacksOf(listed, data);
|
|
1281
|
+
const activeId = data.packs[data.pack];
|
|
1282
|
+
const held = readJoinHeld(packs.map((pack) => pack.objects), packs[0]?.id === activeId ? 0 : -1);
|
|
1283
|
+
const prime = [];
|
|
1284
|
+
let left = held;
|
|
1285
|
+
for (const [at, pack] of packs.entries()) {
|
|
1286
|
+
const ranges = readPackRanges(pack, at === 0 && pack.id === activeId);
|
|
1287
|
+
const cost = readSpansCost(ranges);
|
|
1288
|
+
if (cost > left) continue;
|
|
1289
|
+
left -= cost;
|
|
1290
|
+
prime.push(...ranges);
|
|
1291
|
+
}
|
|
1292
|
+
return Effect.map(roomy(allotment, held, () => rangeCached(bucket, held, {
|
|
1293
|
+
evict: false,
|
|
1294
|
+
headers: true
|
|
1295
|
+
}), (ranges) => ranges.clear()), (joins) => joins === void 0 ? void 0 : {
|
|
1296
|
+
joins,
|
|
1297
|
+
prime
|
|
1298
|
+
});
|
|
1299
|
+
};
|
|
1300
|
+
/**
|
|
1187
1301
|
* The step's join ranges kept as `keptJoins` keeps them, in a room, so the layout a step opens and
|
|
1188
1302
|
* the join that reads it again read each range once a step (#2518).
|
|
1189
1303
|
*/
|
|
@@ -1200,6 +1314,8 @@ const roomyIds = (data, allotment) => roomy(allotment, keptIdsBytes(data.commits
|
|
|
1200
1314
|
const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower, listed, data, input, allotment, walks) {
|
|
1201
1315
|
const bucket = lower?.bucket ?? parts.bucket;
|
|
1202
1316
|
const files = indexFiles(listed.repo, data.build);
|
|
1317
|
+
const tipsKey = data.below.length === 0 && lower !== void 0 ? rootsDigest(input.tips) : void 0;
|
|
1318
|
+
if (tipsKey !== void 0 && data.bitmapsCut?.ready === tipsKey) return yield* bitmapsJoined(parts, files, data, data.bitmapsCut, coveredPositions(listed, data), allotment);
|
|
1203
1319
|
const joins = data.below.length === 0 ? yield* roomyJoins(bucket, listed, data, allotment) : yield* keptJoins(bucket, listed, data, allotment);
|
|
1204
1320
|
const { layout, first } = joins === void 0 ? yield* layoutOf(bucket, listed, data) : yield* layoutOf(joins.bucket, listed, data, { cached: true });
|
|
1205
1321
|
const { positions } = layout;
|
|
@@ -1339,7 +1455,7 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
|
|
|
1339
1455
|
kept: Math.min(madeMost, madeAll)
|
|
1340
1456
|
};
|
|
1341
1457
|
if (below !== void 0) bitmapsInput.below = below;
|
|
1342
|
-
if (
|
|
1458
|
+
if (tipsKey !== void 0) return yield* bitmapsCutTry(parts, files, data, bitmapsInput, tipsKey, allotment);
|
|
1343
1459
|
const already = yield* storedSize(bucket, files.bitmaps);
|
|
1344
1460
|
const written = already === void 0 ? yield* writeBitmaps(bitmapsInput) : yield* storedBitmaps(bucket, files.bitmaps, positions, already);
|
|
1345
1461
|
if (written === void 0) return void 0;
|
|
@@ -1357,7 +1473,7 @@ const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower
|
|
|
1357
1473
|
* bitmap the bound cuts is left whole for the next try, and a try that makes none refuses, as the
|
|
1358
1474
|
* next would spend its calls at the same place.
|
|
1359
1475
|
*/
|
|
1360
|
-
const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files, data, input, allotment) {
|
|
1476
|
+
const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files, data, input, tipsKey, allotment) {
|
|
1361
1477
|
const order = bitmapOrder(input.chosen);
|
|
1362
1478
|
const ordered = orderKey(order);
|
|
1363
1479
|
const cut = data.bitmapsCut?.order === ordered ? data.bitmapsCut : {
|
|
@@ -1373,7 +1489,7 @@ const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files,
|
|
|
1373
1489
|
const count = yield* partCount(key, landed);
|
|
1374
1490
|
return {
|
|
1375
1491
|
...data,
|
|
1376
|
-
bitmapsCut: next(cut, count)
|
|
1492
|
+
bitmapsCut: next(cut, count, order.length, tipsKey)
|
|
1377
1493
|
};
|
|
1378
1494
|
}
|
|
1379
1495
|
const into = new BitmapsPart(partBytesMost);
|
|
@@ -1392,19 +1508,55 @@ const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files,
|
|
|
1392
1508
|
return yield* Effect.fail(bitmapUnwritten(spent.bound, most, order[cut.done]?.position ?? 0));
|
|
1393
1509
|
}
|
|
1394
1510
|
} else if (into.count === 0) return yield* Effect.fail(lost(`No bitmap of ${input.positions} positions fits a part`));
|
|
1511
|
+
if (cut.parts.length === 0 && Result.isSuccess(made) && into.count === order.length) {
|
|
1512
|
+
const atMost = bitmapsMostBytes(input.positions, into.count);
|
|
1513
|
+
const directNeeds = 1 + Math.max(4, streamedPutCalls(parts.bucket.multipart, atMost));
|
|
1514
|
+
const { counted } = parts;
|
|
1515
|
+
const madeCalls = counted?.made();
|
|
1516
|
+
const callsFit = counted === void 0 || madeCalls === void 0 || directNeeds <= counted.most.bucket - madeCalls.bucket && directNeeds <= counted.most.subrequests - madeCalls.subrequests;
|
|
1517
|
+
const putBuffer = Math.min(atMost, uploadPartBytes);
|
|
1518
|
+
if (callsFit && (putBuffer === 0 || allotment.tryGrow(putBuffer))) return yield* Effect.ensuring(Effect.gen(function* () {
|
|
1519
|
+
const already = yield* storedSize(parts.bucket, files.bitmaps);
|
|
1520
|
+
const written = already === void 0 ? yield* Effect.scoped(Effect.gen(function* () {
|
|
1521
|
+
const bitmaps = partBitmaps(into.finish());
|
|
1522
|
+
if (bitmaps?.length !== into.count) return yield* Effect.fail(lost(`${files.bitmaps} part buffer is unreadable`));
|
|
1523
|
+
const put = yield* bitmapsPut(parts.bucket, files.bitmaps, input.positions, into.count);
|
|
1524
|
+
for (const bitmap of bitmaps) yield* put.addBytes(bitmap.position, bitmap.number, bitmap.bytes);
|
|
1525
|
+
return yield* put.finish;
|
|
1526
|
+
})) : yield* storedBitmaps(parts.bucket, files.bitmaps, input.positions, already);
|
|
1527
|
+
const { bitmapsCut: _, ...rest } = data;
|
|
1528
|
+
return {
|
|
1529
|
+
...rest,
|
|
1530
|
+
step: "files",
|
|
1531
|
+
bitmaps: written.count,
|
|
1532
|
+
table: written.table
|
|
1533
|
+
};
|
|
1534
|
+
}), Effect.sync(() => {
|
|
1535
|
+
if (putBuffer > 0) allotment.shrink(putBuffer);
|
|
1536
|
+
}));
|
|
1537
|
+
}
|
|
1395
1538
|
const count = yield* partPut(parts.bucket, key, into);
|
|
1396
1539
|
if (count === void 0) return data;
|
|
1397
1540
|
return {
|
|
1398
1541
|
...data,
|
|
1399
|
-
bitmapsCut: next(cut, count)
|
|
1542
|
+
bitmapsCut: next(cut, count, order.length, tipsKey)
|
|
1400
1543
|
};
|
|
1401
1544
|
});
|
|
1402
|
-
/** `cut` with its next part, of `count` bitmaps, made. */
|
|
1403
|
-
const next = (cut, count) =>
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1545
|
+
/** `cut` with its next part, of `count` bitmaps, made; marked `ready` once all `total` fit. */
|
|
1546
|
+
const next = (cut, count, total, tipsKey) => {
|
|
1547
|
+
const done = cut.done + count;
|
|
1548
|
+
const parts = [...cut.parts, count];
|
|
1549
|
+
return done >= total ? {
|
|
1550
|
+
order: cut.order,
|
|
1551
|
+
done,
|
|
1552
|
+
parts,
|
|
1553
|
+
ready: tipsKey
|
|
1554
|
+
} : {
|
|
1555
|
+
order: cut.order,
|
|
1556
|
+
done,
|
|
1557
|
+
parts
|
|
1558
|
+
};
|
|
1559
|
+
};
|
|
1408
1560
|
/** How many bitmaps the part at `key` holds, as `bytes` read. */
|
|
1409
1561
|
const partCount = (key, bytes) => {
|
|
1410
1562
|
const held = partBitmaps(bytes);
|
|
@@ -1450,10 +1602,14 @@ const bitmapsJoined = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files,
|
|
|
1450
1602
|
table: written.table
|
|
1451
1603
|
};
|
|
1452
1604
|
});
|
|
1605
|
+
/** Maximum concurrent scratch-part reads across `filesStep` (matches `locateReads`). */
|
|
1606
|
+
const filesReads = 6;
|
|
1453
1607
|
/**
|
|
1454
1608
|
* The files step: `.types` and `.bases`, each its parts streamed in position order, and each
|
|
1455
1609
|
* found there on its own when a try that died after its put landed is done again. It holds a
|
|
1456
|
-
* part as read, its words, and what it writes of it, charged to `allotment` first
|
|
1610
|
+
* part as read, its words, and what it writes of it, charged to `allotment` first, running
|
|
1611
|
+
* `.types` and `.bases` concurrently and prefetching scratch parts in bounded waves when
|
|
1612
|
+
* `allotment` has room (#596).
|
|
1457
1613
|
*/
|
|
1458
1614
|
const filesStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
|
|
1459
1615
|
const { bucket } = parts;
|
|
@@ -1462,13 +1618,42 @@ const filesStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, da
|
|
|
1462
1618
|
const every = firstOf(data.below) + positions;
|
|
1463
1619
|
const deltas = data.slices.reduce((sum, slice) => sum + slice.deltas, 0);
|
|
1464
1620
|
const ordered = byPosition(data);
|
|
1465
|
-
const
|
|
1621
|
+
const typesPartMost = data.slices.reduce((most, slice) => Math.max(most, slice.positions), 0);
|
|
1622
|
+
const basesPartMost = data.slices.reduce((most, slice) => Math.max(most, slice.deltas * 8), 0);
|
|
1623
|
+
const part = Math.max(typesPartMost, basesPartMost);
|
|
1466
1624
|
yield* allotment.grow(3 * part + Math.ceil(every / 4096) * 4 + 65536);
|
|
1625
|
+
const [typesSize, basesSize] = yield* Effect.all([storedSize(bucket, files.types), storedSize(bucket, files.bases)], { concurrency: 2 });
|
|
1626
|
+
const needTypes = typesSize === void 0;
|
|
1627
|
+
const needBases = basesSize === void 0;
|
|
1628
|
+
const secondStreamExtra = 3 * part + 65536;
|
|
1629
|
+
const parallelStreams = needTypes && needBases && (secondStreamExtra === 0 || allotment.tryGrow(secondStreamExtra));
|
|
1630
|
+
const perStreamCap = parallelStreams ? Math.max(1, Math.floor(filesReads / 2)) : filesReads;
|
|
1631
|
+
const streamParts = (keys, partBytes, consume) => Effect.suspend(() => {
|
|
1632
|
+
let wave = Math.min(perStreamCap, Math.max(1, keys.length));
|
|
1633
|
+
let extra = 0;
|
|
1634
|
+
while (wave > 1) {
|
|
1635
|
+
const needed = (wave - 1) * partBytes;
|
|
1636
|
+
if (needed === 0 || allotment.tryGrow(needed)) {
|
|
1637
|
+
extra = needed;
|
|
1638
|
+
break;
|
|
1639
|
+
}
|
|
1640
|
+
wave = Math.floor(wave / 2);
|
|
1641
|
+
}
|
|
1642
|
+
return Effect.ensuring(Effect.gen(function* () {
|
|
1643
|
+
for (let at = 0; at < keys.length; at += wave) {
|
|
1644
|
+
const batch = keys.slice(at, at + wave);
|
|
1645
|
+
const loaded = batch.length === 1 ? [yield* readScratch(bucket, batch[0])] : yield* Effect.all(batch.map((key) => readScratch(bucket, key)), { concurrency: wave });
|
|
1646
|
+
for (const bytes of loaded) yield* consume(bytes);
|
|
1647
|
+
}
|
|
1648
|
+
}), Effect.sync(() => {
|
|
1649
|
+
if (extra > 0) allotment.shrink(extra);
|
|
1650
|
+
}));
|
|
1651
|
+
});
|
|
1467
1652
|
const types = Effect.gen(function* () {
|
|
1468
1653
|
const writer = new TypesWriter(positions);
|
|
1469
1654
|
const put = yield* startPut(bucket, files.types, { size: indexTypesBytes(positions) });
|
|
1470
1655
|
yield* put.write(writer.head());
|
|
1471
|
-
|
|
1656
|
+
yield* streamParts(ordered.map(([number, slice]) => files.typesPart(number, slice.positions)), typesPartMost, (bytes) => Effect.flatMap(writer.part(bytes), (chunk) => put.write(chunk)));
|
|
1472
1657
|
yield* put.write(yield* writer.end());
|
|
1473
1658
|
yield* put.finish;
|
|
1474
1659
|
});
|
|
@@ -1476,12 +1661,19 @@ const filesStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, da
|
|
|
1476
1661
|
const writer = new BasesWriter(every, deltas);
|
|
1477
1662
|
const put = yield* startPut(bucket, files.bases, { size: indexBasesBytes(every, deltas) });
|
|
1478
1663
|
yield* put.write(writer.head());
|
|
1479
|
-
|
|
1664
|
+
yield* streamParts(ordered.map(([number, slice]) => files.basesPart(number, slice.positions)), basesPartMost, (bytes) => Effect.flatMap(writer.rows(wordsOf(bytes)), (chunk) => put.write(chunk)));
|
|
1480
1665
|
yield* put.write(yield* writer.end());
|
|
1481
1666
|
yield* put.finish;
|
|
1482
1667
|
});
|
|
1483
|
-
|
|
1484
|
-
|
|
1668
|
+
yield* Effect.ensuring(parallelStreams ? Effect.all([types, bases], {
|
|
1669
|
+
concurrency: 2,
|
|
1670
|
+
discard: true
|
|
1671
|
+
}) : Effect.gen(function* () {
|
|
1672
|
+
if (needTypes) yield* types;
|
|
1673
|
+
if (needBases) yield* bases;
|
|
1674
|
+
}), Effect.sync(() => {
|
|
1675
|
+
if (parallelStreams && secondStreamExtra > 0) allotment.shrink(secondStreamExtra);
|
|
1676
|
+
}));
|
|
1485
1677
|
return {
|
|
1486
1678
|
...data,
|
|
1487
1679
|
step: "commit"
|
|
@@ -1756,8 +1948,9 @@ const mergeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, da
|
|
|
1756
1948
|
/**
|
|
1757
1949
|
* Deletes every file under the repo's prefix whose build `keep` doesn't name, once prune's grace
|
|
1758
1950
|
* has passed since it was replaced, or, for one no row names, since it was written, and never
|
|
1759
|
-
* before `from`; and the scratch of a build kept for its stored files alone
|
|
1760
|
-
* file it kept is due: `at` itself once it has
|
|
1951
|
+
* before `from`; and the scratch of a build kept for its stored files alone, each listed page's in
|
|
1952
|
+
* one `bucketDeleteMany`. Answers when the next file it kept is due: `at` itself once it has
|
|
1953
|
+
* deleted `pruneMost`, with more left to look at.
|
|
1761
1954
|
*/
|
|
1762
1955
|
const pruneBuilds = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, repo, keep, replaced, at, grace, from = 0) {
|
|
1763
1956
|
const prefix = indexPrefix(repo);
|
|
@@ -1767,6 +1960,7 @@ const pruneBuilds = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, repo, k
|
|
|
1767
1960
|
let deleted = 0;
|
|
1768
1961
|
for (;;) {
|
|
1769
1962
|
const page = yield* bucketDo(bucket.list(prefix, after === void 0 ? {} : { after }));
|
|
1963
|
+
const doomed = [];
|
|
1770
1964
|
for (const item of page.items) {
|
|
1771
1965
|
const name = item.key.slice(prefix.length);
|
|
1772
1966
|
const build = name.split(/[./]/)[0] ?? "";
|
|
@@ -1778,10 +1972,12 @@ const pruneBuilds = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, repo, k
|
|
|
1778
1972
|
due = Math.min(due ?? Number.POSITIVE_INFINITY, since + grace);
|
|
1779
1973
|
continue;
|
|
1780
1974
|
}
|
|
1781
|
-
|
|
1782
|
-
deleted
|
|
1783
|
-
if (deleted >= 200) return at;
|
|
1975
|
+
doomed.push(item.key);
|
|
1976
|
+
if (deleted + doomed.length >= 200) break;
|
|
1784
1977
|
}
|
|
1978
|
+
if (doomed.length > 0) yield* bucketDeleteMany(bucket, doomed);
|
|
1979
|
+
deleted += doomed.length;
|
|
1980
|
+
if (deleted >= 200) return at;
|
|
1785
1981
|
if (page.next === void 0) return due;
|
|
1786
1982
|
after = page.next;
|
|
1787
1983
|
}
|
|
@@ -1910,10 +2106,10 @@ const layersLost = (listed, error) => Effect.logError(`git.index found repo ${li
|
|
|
1910
2106
|
const upToDate = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, built, tips) {
|
|
1911
2107
|
const covered = coveredPacks(built.layers);
|
|
1912
2108
|
if (listed.packs.some((pack) => !covered.has(pack.id))) return false;
|
|
2109
|
+
const read = yield* readRegion(parts, listed);
|
|
2110
|
+
if (read === "batched" || read === "moved") return read;
|
|
1913
2111
|
const allotment = yield* parts.budget.upkeep(0, readBusy);
|
|
1914
2112
|
const layout = yield* openLayout(parts.bucket, listed, built.layers, void 0, { allotment });
|
|
1915
|
-
const read = yield* readRegion(parts, listed);
|
|
1916
|
-
if (read === void 0) return "moved";
|
|
1917
2113
|
if ((yield* layout.positionsOf(read.ids, read.rows)).some((position) => position === 4294967295)) return false;
|
|
1918
2114
|
const bitmaps = yield* openLayerBitmaps(parts.bucket, listed.repo, built.layers);
|
|
1919
2115
|
const unique = [...new Set(tips)];
|
|
@@ -2070,6 +2266,7 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
|
|
|
2070
2266
|
if (input.data === void 0 && row !== void 0 && !stale && !indexSaves(indexStatus(row, limits, input.at, listedIds(listed)))) return prunedAt(yield* prune());
|
|
2071
2267
|
const current = input.data === void 0 && built?.lost === true ? "lost" : input.data === void 0 && built !== void 0 && !stale && coversAll(built.layers, listed) ? yield* upToDate(parts, listed, built, input.tips).pipe(Effect.catchIf(isLost, (error) => Effect.as(layersLost(listed, error), "lost"))) : false;
|
|
2072
2268
|
if (current === true) return prunedAt(yield* prune());
|
|
2269
|
+
if (current === "batched") return prunedAt(input.at + batchWaitMs);
|
|
2073
2270
|
if (current === "moved" && input.lastCheck !== true) return { kind: "moved" };
|
|
2074
2271
|
const fresh = () => built === void 0 || stale || current === "lost" || !coversAll(built.layers, listed) ? started(listed, rootsKey) : built.layers.length < 8 ? startedUpdate(listed, built) : startedMerge(listed, built);
|
|
2075
2272
|
const kept = input.data;
|
|
@@ -2082,7 +2279,6 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
|
|
|
2082
2279
|
});
|
|
2083
2280
|
const orWhole = (step) => data.below.length === 0 ? step : step.pipe(Effect.catchIf(isLost, (error) => Effect.as(layersLost(listed, error), started(listed, rootsKey))));
|
|
2084
2281
|
if (input.lastCheck === true && input.data === void 0) return more(data);
|
|
2085
|
-
if (data.step === "region") yield* prune(data.build);
|
|
2086
2282
|
if (data.step === "commit" && addsNothing(data)) {
|
|
2087
2283
|
yield* prune();
|
|
2088
2284
|
return prunedAt(input.at);
|
|
@@ -2090,7 +2286,11 @@ const indexStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, in
|
|
|
2090
2286
|
if (data.step === "commit") return yield* commitStep(listed, data, input);
|
|
2091
2287
|
const allotment = yield* parts.budget.upkeep(floors.cache + floors.blocks, readBusy);
|
|
2092
2288
|
const named = spentNamed(data.step, listed.repo);
|
|
2093
|
-
if (data.step === "region")
|
|
2289
|
+
if (data.step === "region") {
|
|
2290
|
+
const region = yield* named(orWhole(regionStep(parts, listed, data, allotment, () => prune(data.build))));
|
|
2291
|
+
if (region === "batched") return prunedAt(input.at + batchWaitMs);
|
|
2292
|
+
return more(region ?? kept ?? data);
|
|
2293
|
+
}
|
|
2094
2294
|
if (data.step === "files") return more(yield* named(orWhole(filesStep(parts, listed, data, allotment))));
|
|
2095
2295
|
if (data.step === "merge") {
|
|
2096
2296
|
const merged = yield* Effect.result(named(orWhole(mergeStep(parts, listed, data, input, allotment))));
|
|
@@ -2167,4 +2367,4 @@ const indexTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, limits, lis
|
|
|
2167
2367
|
data: ended.data
|
|
2168
2368
|
};
|
|
2169
2369
|
});
|
|
2170
|
-
export { BitmapsCut, BuiltIndex, IndexBounds, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, bitmapsJoinHeld, bitmapsJoinMost, boundsOf, builtIndexOf, builtOver, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, denseBelow, denseBelowReads, edgesMost, entriesHeld, floors, graphMostOf, indexBitmapsCallsAfter, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, limitsOf, lostIndexRow, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, reachesBytes, reachesOf, readFurther, roomy, rootsKeyOf, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };
|
|
2370
|
+
export { BitmapsCut, BuiltIndex, IndexBounds, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, bitmapsJoinHeld, bitmapsJoinMost, boundsOf, builtIndexOf, builtOver, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, denseBelow, denseBelowReads, edgesMost, entriesHeld, floors, graphMostOf, indexBitmapsCallsAfter, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, limitsOf, lostIndexRow, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, reachesBytes, reachesOf, readFurther, readJoinHeld, roomy, rootsKeyOf, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };
|
|
@@ -2,11 +2,13 @@ import "./send-list.mjs";
|
|
|
2
2
|
import "../contracts/ids.mjs";
|
|
3
3
|
import "../contracts/objects.mjs";
|
|
4
4
|
import "../contracts/result.mjs";
|
|
5
|
-
import "../contracts/services.mjs";
|
|
6
5
|
import "../contracts/store.mjs";
|
|
7
6
|
import "../protocol/packs/writer.mjs";
|
|
8
7
|
import "./fetch.mjs";
|
|
9
8
|
import "./index-build.mjs";
|
|
9
|
+
import "./list-source.mjs";
|
|
10
|
+
import "./index-whole.mjs";
|
|
10
11
|
import "./shallow.mjs";
|
|
11
12
|
import "./walk.mjs";
|
|
13
|
+
import { Row } from "@ref0/infra";
|
|
12
14
|
import "effect/Effect";
|