@ref0/git 0.20.0 → 0.26.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 +30 -18
- 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 +13 -12
- 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 +145 -98
- 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 +114 -58
- 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/held-types.mjs +13 -4
- package/dist/storage/host-bucket.mjs +9 -4
- package/dist/storage/index-bitmaps.mjs +340 -65
- package/dist/storage/index-build.d.mts +2 -3
- package/dist/storage/index-build.mjs +274 -56
- 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 +24 -18
- 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
|
@@ -3,7 +3,7 @@ import { BufferError, BufferMeter } from "../protocol/bytes/buffers.mjs";
|
|
|
3
3
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
4
4
|
import { Sha1 } from "../protocol/bytes/sha1.mjs";
|
|
5
5
|
import { sha1Now } from "../protocol/bytes/sha1-hasher.mjs";
|
|
6
|
-
import { objectHeader, objectId } from "../protocol/objects/object.mjs";
|
|
6
|
+
import { emptyTree, objectHeader, objectId } from "../protocol/objects/object.mjs";
|
|
7
7
|
import { DeltaError, deltaResultSize } from "../protocol/packs/delta.mjs";
|
|
8
8
|
import { oidBytes, ownedPackIndex, readPackIndex } from "../protocol/packs/idx.mjs";
|
|
9
9
|
import { ownedPackReverse, readPackReverse } from "../protocol/packs/rev.mjs";
|
|
@@ -24,10 +24,12 @@ import { allotted, keptOrLeft } from "./allotted.mjs";
|
|
|
24
24
|
import { fileBytesMost } from "./file-limits.mjs";
|
|
25
25
|
import { packCodes } from "./plan-columns.mjs";
|
|
26
26
|
import * as Effect from "effect/Effect";
|
|
27
|
+
import * as Predicate from "effect/Predicate";
|
|
27
28
|
import * as Option from "effect/Option";
|
|
28
29
|
import * as Cause from "effect/Cause";
|
|
30
|
+
import * as Exit from "effect/Exit";
|
|
29
31
|
import * as Result from "effect/Result";
|
|
30
|
-
import * as
|
|
32
|
+
import * as Deferred from "effect/Deferred";
|
|
31
33
|
import * as Fiber from "effect/Fiber";
|
|
32
34
|
import * as Hex from "effect/encoding/Hex";
|
|
33
35
|
// src/storage/pack-reads.ts
|
|
@@ -406,48 +408,69 @@ var PackBlocks = class {
|
|
|
406
408
|
*/
|
|
407
409
|
const packRun = (bucket, pack, from, to) => {
|
|
408
410
|
let reader;
|
|
411
|
+
let opening;
|
|
412
|
+
let failed;
|
|
413
|
+
let closed = false;
|
|
409
414
|
let piece = /* @__PURE__ */ new Uint8Array(0);
|
|
410
415
|
let pieceAt = from;
|
|
411
416
|
const missing = (at) => lost(`Pack ${pack.id} is missing its bytes from ${at}`);
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
if (
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
return Effect.
|
|
420
|
-
|
|
421
|
-
|
|
417
|
+
const cancel = (stream) => Effect.promise(() => stream.cancel().catch(() => void 0));
|
|
418
|
+
const open = Effect.suspend(() => {
|
|
419
|
+
if (reader !== void 0) return Effect.succeed(reader);
|
|
420
|
+
if (failed !== void 0) return Effect.failCause(failed);
|
|
421
|
+
if (opening !== void 0) return Deferred.await(opening);
|
|
422
|
+
const pending = Deferred.makeUnsafe();
|
|
423
|
+
opening = pending;
|
|
424
|
+
return Effect.uninterruptible(Effect.flatMap(bucketStream(bucket, packFiles(pack.id).pack, {
|
|
425
|
+
offset: from,
|
|
426
|
+
length: to - from
|
|
427
|
+
}), (body) => {
|
|
428
|
+
if (body === void 0) return Effect.fail(missing(from));
|
|
429
|
+
if (closed) return Effect.andThen(cancel(body), Effect.interrupt);
|
|
430
|
+
const opened = body.getReader();
|
|
431
|
+
reader = opened;
|
|
432
|
+
return Effect.succeed(opened);
|
|
433
|
+
})).pipe(Effect.onExit((exit) => Effect.sync(() => {
|
|
434
|
+
opening = void 0;
|
|
435
|
+
if (Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause)) failed = exit.cause;
|
|
436
|
+
Deferred.doneUnsafe(pending, exit);
|
|
437
|
+
})));
|
|
438
|
+
});
|
|
422
439
|
/**
|
|
423
440
|
* The body's next piece, or its end, its failure as `bucketTry` maps one: a closed server's, and
|
|
424
441
|
* one past a call bound, stay defects. An interruption cancels the body. The read takes no signal,
|
|
425
442
|
* so it adds no listener to one.
|
|
426
443
|
*/
|
|
427
444
|
const nextPiece = (opened) => bucketTry(() => opened.read()).pipe(Effect.onInterrupt(() => cancel(opened)));
|
|
445
|
+
const read = Effect.fnUntraced(function* (offset, end) {
|
|
446
|
+
if (offset < pieceAt || end > to) return yield* Effect.die(/* @__PURE__ */ new Error(`a run of ${from} to ${to} can't read ${offset} to ${end}`));
|
|
447
|
+
const opened = reader ?? (yield* open);
|
|
448
|
+
while (offset >= pieceAt + piece.byteLength) {
|
|
449
|
+
pieceAt += piece.byteLength;
|
|
450
|
+
const next = yield* nextPiece(opened);
|
|
451
|
+
if (next.done) return yield* Effect.fail(missing(pieceAt));
|
|
452
|
+
const { value } = next;
|
|
453
|
+
piece = value.buffer instanceof ArrayBuffer ? new Uint8Array(value.buffer, value.byteOffset, value.byteLength) : value.slice();
|
|
454
|
+
}
|
|
455
|
+
return piece.subarray(offset - pieceAt, Math.min(piece.byteLength, end - pieceAt));
|
|
456
|
+
});
|
|
428
457
|
return {
|
|
429
458
|
from,
|
|
430
459
|
to,
|
|
431
460
|
reads: (offset) => offset >= pieceAt && offset < to,
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
const opened = reader ?? (yield* open);
|
|
435
|
-
while (offset >= pieceAt + piece.byteLength) {
|
|
436
|
-
pieceAt += piece.byteLength;
|
|
437
|
-
const next = yield* nextPiece(opened);
|
|
438
|
-
if (next.done) return yield* Effect.fail(missing(pieceAt));
|
|
439
|
-
const { value } = next;
|
|
440
|
-
piece = value.buffer instanceof ArrayBuffer ? new Uint8Array(value.buffer, value.byteOffset, value.byteLength) : value.slice();
|
|
441
|
-
}
|
|
442
|
-
return piece.subarray(offset - pieceAt, Math.min(piece.byteLength, end - pieceAt));
|
|
443
|
-
}),
|
|
461
|
+
start: Effect.asVoid(open),
|
|
462
|
+
read,
|
|
444
463
|
close: Effect.suspend(() => {
|
|
464
|
+
closed = true;
|
|
445
465
|
const opened = reader;
|
|
466
|
+
reader = void 0;
|
|
446
467
|
piece = /* @__PURE__ */ new Uint8Array(0);
|
|
447
468
|
return opened === void 0 ? Effect.void : cancel(opened);
|
|
448
469
|
})
|
|
449
470
|
};
|
|
450
471
|
};
|
|
472
|
+
/** Bucket-scoped cache key for an immutable index file; disjoint from `PackId` (`p_...`). */
|
|
473
|
+
const fileCacheKey = (bucketId, key) => `file:${bucketId}:${key}`;
|
|
451
474
|
/**
|
|
452
475
|
* The most of the index cache's room one receive's seed may take, as a share of `room.most`: a
|
|
453
476
|
* pack's entry past it is read by a load instead, so one push never fills half of what the cache can
|
|
@@ -460,9 +483,10 @@ const indexSeedShare = 1 / 2;
|
|
|
460
483
|
*/
|
|
461
484
|
const seedBytes = (files) => 384 + 2 * (files.index.byteLength + files.reverse.byteLength);
|
|
462
485
|
/**
|
|
463
|
-
* The `.idx` and `.rev` of each pack a server has read, across every repo, by the pack's ID
|
|
464
|
-
*
|
|
465
|
-
*
|
|
486
|
+
* The `.idx` and `.rev` of each pack a server has read, across every repo, by the pack's ID, and
|
|
487
|
+
* the small immutable index files (`index/<r>/<build>.{graph,types,bitmaps,bases}` and
|
|
488
|
+
* `packs/<p>.{idx,pos}`) read whole by `heldIndex`, scoped to `(bucket, key)`: each is kept in
|
|
489
|
+
* one LRU under the server's index `CacheRoom` until the cache is full or shrinks (#2518).
|
|
466
490
|
*/
|
|
467
491
|
var PackIndexes = class {
|
|
468
492
|
#kept = /* @__PURE__ */ new Map();
|
|
@@ -471,16 +495,25 @@ var PackIndexes = class {
|
|
|
471
495
|
* caller alone is loaded again by a waiter, and a failed one is never kept.
|
|
472
496
|
*/
|
|
473
497
|
#loading = new SingleFlight();
|
|
498
|
+
/** Each index file's read under way, keyed by `(bucket, key[, range])`, sharing one bucket get. */
|
|
499
|
+
#reading = new SingleFlight();
|
|
500
|
+
/** Opaque per-bucket IDs scoping cached file keys to the bucket they were read from. */
|
|
501
|
+
#buckets = /* @__PURE__ */ new WeakMap();
|
|
474
502
|
#room;
|
|
503
|
+
#nextBucket = 0;
|
|
475
504
|
#held = 0;
|
|
476
505
|
/**
|
|
477
|
-
* `room`: what it keeps of the `.idx
|
|
506
|
+
* `room`: what it keeps of the `.idx`, `.rev` and immutable index files it reads, each entry
|
|
478
507
|
* counted with `cacheEntryBytes`. A room of 0 that never grows keeps none.
|
|
479
508
|
*/
|
|
480
509
|
constructor(room) {
|
|
481
510
|
this.#room = room;
|
|
482
511
|
room.watch((bytes) => this.#evictTo(bytes));
|
|
483
512
|
}
|
|
513
|
+
/** Total bytes currently held by kept entries (each with `cacheEntryBytes`). */
|
|
514
|
+
get heldBytes() {
|
|
515
|
+
return this.#held;
|
|
516
|
+
}
|
|
484
517
|
/**
|
|
485
518
|
* `listed`'s `.idx` and `.rev`, kept or read. One load of a pack runs at a time, whoever asks:
|
|
486
519
|
* the cache owns it, and every other caller waits on it, so 16 cold reads of one pack make one
|
|
@@ -497,7 +530,7 @@ var PackIndexes = class {
|
|
|
497
530
|
bytes: listed.bytes
|
|
498
531
|
};
|
|
499
532
|
const kept = this.#kept.get(id);
|
|
500
|
-
if (kept !== void 0) {
|
|
533
|
+
if (kept !== void 0 && kept.kind === "pack") {
|
|
501
534
|
this.#kept.delete(id);
|
|
502
535
|
this.#kept.set(id, kept);
|
|
503
536
|
return {
|
|
@@ -529,6 +562,7 @@ var PackIndexes = class {
|
|
|
529
562
|
const reverse = yield* ownedPackReverse(reversed, index).pipe(Effect.mapError((error) => lost(`Pack ${id}'s reverse index is unreadable: ${error.message}`)));
|
|
530
563
|
const held = 384 + bytes.buffer.byteLength + reversed.buffer.byteLength;
|
|
531
564
|
this.#remember(id, {
|
|
565
|
+
kind: "pack",
|
|
532
566
|
index,
|
|
533
567
|
reverse,
|
|
534
568
|
bytes: held
|
|
@@ -568,23 +602,32 @@ var PackIndexes = class {
|
|
|
568
602
|
const over = this.#held + held - this.#room.bytes;
|
|
569
603
|
if (over > 0 && !this.#room.grow(over)) return;
|
|
570
604
|
this.#remember(id, {
|
|
605
|
+
kind: "pack",
|
|
571
606
|
index: index.value,
|
|
572
607
|
reverse: reverse.value,
|
|
573
608
|
bytes: held
|
|
574
609
|
});
|
|
575
610
|
});
|
|
576
611
|
/**
|
|
577
|
-
* Lets go of pack `id`'s kept `.idx` and `.rev`,
|
|
578
|
-
*
|
|
579
|
-
* no load of it is running.
|
|
612
|
+
* Lets go of pack `id`'s kept `.idx` and `.rev`, and any kept raw `packs/<id>.{idx,pos}` files,
|
|
613
|
+
* for a pack whose files were deleted. A load of it under way when it's called keeps what it
|
|
614
|
+
* reads once it ends, so a pack is forgotten only once no load of it is running.
|
|
580
615
|
*/
|
|
581
616
|
forget = (id) => {
|
|
582
617
|
if (!isPackId(id)) return;
|
|
583
618
|
const kept = this.#kept.get(id);
|
|
584
|
-
if (kept
|
|
585
|
-
|
|
586
|
-
|
|
619
|
+
if (kept !== void 0) {
|
|
620
|
+
this.#kept.delete(id);
|
|
621
|
+
this.#held -= kept.bytes;
|
|
622
|
+
}
|
|
623
|
+
const { idx, pos } = packFiles(id);
|
|
624
|
+
for (const [each, entry] of this.#kept) if (entry.kind === "file" && (entry.key === idx || entry.key === pos)) {
|
|
625
|
+
this.#kept.delete(each);
|
|
626
|
+
this.#held -= entry.bytes;
|
|
627
|
+
}
|
|
587
628
|
};
|
|
629
|
+
/** Whether the cache currently keeps pack `id`'s `.idx` and `.rev`, without changing recency. */
|
|
630
|
+
has = (id) => isPackId(id) && this.#kept.has(id);
|
|
588
631
|
/**
|
|
589
632
|
* The `.idx` the cache keeps for pack `id`, read by no call and made the most recent, or
|
|
590
633
|
* `undefined` when it keeps none: a lookup that must hold no `.idx` of its own reads one held
|
|
@@ -593,26 +636,98 @@ var PackIndexes = class {
|
|
|
593
636
|
peek = (id) => {
|
|
594
637
|
if (!isPackId(id)) return void 0;
|
|
595
638
|
const kept = this.#kept.get(id);
|
|
596
|
-
if (kept === void 0) return void 0;
|
|
639
|
+
if (kept === void 0 || kept.kind !== "pack") return void 0;
|
|
597
640
|
this.#kept.delete(id);
|
|
598
641
|
this.#kept.set(id, kept);
|
|
599
642
|
return kept.index;
|
|
600
643
|
};
|
|
601
644
|
/**
|
|
602
|
-
* `
|
|
603
|
-
*
|
|
604
|
-
|
|
645
|
+
* Kept bytes of immutable file `key` read from `bucket`, made the most recent, or `undefined`.
|
|
646
|
+
* Scoped to `bucket`'s identity so one bucket's bytes never answer another's.
|
|
647
|
+
*/
|
|
648
|
+
peekFile(bucket, key) {
|
|
649
|
+
const bucketId = this.#buckets.get(bucket);
|
|
650
|
+
if (bucketId === void 0) return void 0;
|
|
651
|
+
const cacheKey = fileCacheKey(bucketId, key);
|
|
652
|
+
const kept = this.#kept.get(cacheKey);
|
|
653
|
+
if (kept === void 0 || kept.kind !== "file") return void 0;
|
|
654
|
+
this.#kept.delete(cacheKey);
|
|
655
|
+
this.#kept.set(cacheKey, kept);
|
|
656
|
+
return kept.data;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Reads `file` from `bucket` through `read`, sharing one in-flight read per `(bucket, key[, range])`
|
|
660
|
+
* across concurrent callers and keeping immutable whole files within this cache's room.
|
|
661
|
+
*/
|
|
662
|
+
readFile = Effect.fnUntraced({ self: this }, function* (bucket, file, read, limit) {
|
|
663
|
+
const bucketId = this.#bucketIdOf(bucket);
|
|
664
|
+
const cacheKey = fileCacheKey(bucketId, file.key);
|
|
665
|
+
if (file.immutable === true && file.range === void 0) {
|
|
666
|
+
const kept = this.#kept.get(cacheKey);
|
|
667
|
+
if (kept !== void 0 && kept.kind === "file") {
|
|
668
|
+
this.#kept.delete(cacheKey);
|
|
669
|
+
this.#kept.set(cacheKey, kept);
|
|
670
|
+
return {
|
|
671
|
+
kind: "file",
|
|
672
|
+
bytes: kept.data,
|
|
673
|
+
charged: kept.data.byteLength
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
const flightKey = file.range === void 0 ? cacheKey : `${cacheKey}@${file.range.offset}:${file.range.length}`;
|
|
678
|
+
let led = false;
|
|
679
|
+
const loaded = yield* this.#reading.run(flightKey, Effect.suspend(() => {
|
|
680
|
+
led = true;
|
|
681
|
+
return this.#readFile(file, cacheKey, read);
|
|
682
|
+
}));
|
|
683
|
+
if (Option.isNone(loaded)) return yield* this.readFile(bucket, file, read, limit);
|
|
684
|
+
const result = loaded.value;
|
|
685
|
+
if (!led && result.kind === "past" && limit() > result.limit) return yield* this.readFile(bucket, file, read, limit);
|
|
686
|
+
return result;
|
|
687
|
+
});
|
|
688
|
+
#readFile = Effect.fnUntraced({ self: this }, function* (file, cacheKey, read) {
|
|
689
|
+
const result = yield* read();
|
|
690
|
+
if (result.kind === "file" && file.immutable === true && file.range === void 0) {
|
|
691
|
+
const { bytes } = result;
|
|
692
|
+
const owned = bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength ? bytes : bytes.slice();
|
|
693
|
+
this.#remember(cacheKey, {
|
|
694
|
+
kind: "file",
|
|
695
|
+
key: file.key,
|
|
696
|
+
data: owned,
|
|
697
|
+
bytes: 384 + owned.buffer.byteLength
|
|
698
|
+
});
|
|
699
|
+
return {
|
|
700
|
+
kind: "file",
|
|
701
|
+
bytes: owned,
|
|
702
|
+
charged: result.charged
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
return result;
|
|
706
|
+
});
|
|
707
|
+
#bucketIdOf(bucket) {
|
|
708
|
+
const existing = this.#buckets.get(bucket);
|
|
709
|
+
if (existing !== void 0) return existing;
|
|
710
|
+
const id = this.#nextBucket += 1;
|
|
711
|
+
this.#buckets.set(bucket, id);
|
|
712
|
+
return id;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* `kept` at `key`, the most recent. Entries larger than the room's most (or larger than its
|
|
716
|
+
* current bytes when growth is refused) aren't kept, leaving entries that fit untouched. One
|
|
717
|
+
* already there is let go first, so `#held` is always the sum of the entries kept.
|
|
605
718
|
*/
|
|
606
|
-
#remember(
|
|
607
|
-
|
|
719
|
+
#remember(key, kept) {
|
|
720
|
+
if (kept.bytes > this.#room.most) return;
|
|
721
|
+
const displaced = this.#kept.get(key);
|
|
722
|
+
const over = this.#held - (displaced?.bytes ?? 0) + kept.bytes - this.#room.bytes;
|
|
723
|
+
if (over > 0 && !this.#room.grow(over) && kept.bytes > this.#room.bytes) return;
|
|
608
724
|
if (displaced !== void 0) {
|
|
609
|
-
this.#kept.delete(
|
|
725
|
+
this.#kept.delete(key);
|
|
610
726
|
this.#held -= displaced.bytes;
|
|
611
727
|
}
|
|
612
|
-
this.#kept.set(
|
|
728
|
+
this.#kept.set(key, kept);
|
|
613
729
|
this.#held += kept.bytes;
|
|
614
|
-
|
|
615
|
-
if (over > 0 && !this.#room.grow(over)) this.#evictTo(this.#room.bytes);
|
|
730
|
+
if (this.#held > this.#room.bytes) this.#evictTo(this.#room.bytes);
|
|
616
731
|
}
|
|
617
732
|
#evictTo(bytes) {
|
|
618
733
|
for (const [each, kept] of this.#kept) {
|
|
@@ -918,12 +1033,16 @@ const isIndexShort = (error) => error.cause instanceof IndexShort;
|
|
|
918
1033
|
* against its ID.
|
|
919
1034
|
*/
|
|
920
1035
|
const packReader = (input) => {
|
|
921
|
-
const { store, bucket, indexes, listed, memory } = input;
|
|
1036
|
+
const { store, bucket, indexes, listed, memory, observe } = input;
|
|
922
1037
|
const blocks = input.blocks ?? new PackBlocks(bucket, memory.blocks);
|
|
923
|
-
const { listedOnly } = input;
|
|
924
|
-
const rows = listedOnly === true ? () => Effect.void : eachHeldRow(store, listed);
|
|
925
|
-
const rowsSized = listedOnly === true ? () => Effect.succeed(/* @__PURE__ */ new Map()) : rowSizes(store, listed);
|
|
926
|
-
const rowsHeaders = listedOnly === true ? () => Effect.succeed(/* @__PURE__ */ new Map()) : rowHeaders(store, listed);
|
|
1038
|
+
const { listedOnly, rowCache } = input;
|
|
1039
|
+
const rows = listedOnly === true ? () => Effect.void : eachHeldRow(store, listed, void 0, rowCache);
|
|
1040
|
+
const rowsSized = listedOnly === true ? () => Effect.succeed(/* @__PURE__ */ new Map()) : rowSizes(store, listed, rowCache);
|
|
1041
|
+
const rowsHeaders = listedOnly === true ? () => Effect.succeed(/* @__PURE__ */ new Map()) : rowHeaders(store, listed, void 0, rowCache);
|
|
1042
|
+
const observedRowHeaders = listedOnly === true || observe === void 0 ? rowsHeaders : rowHeaders(store, listed, (row, header) => {
|
|
1043
|
+
observe.located(row.id, void 0);
|
|
1044
|
+
observe.row(row, header);
|
|
1045
|
+
}, rowCache);
|
|
927
1046
|
const wholeAt = packObjects(blocks, memory.cache, memory.outside);
|
|
928
1047
|
const named = new Set(listed.packs.map((pack) => pack.id));
|
|
929
1048
|
const kept = /* @__PURE__ */ new Map();
|
|
@@ -967,7 +1086,7 @@ const packReader = (input) => {
|
|
|
967
1086
|
* until it fits, before the load, so the reader never holds past the floor while it reads. One
|
|
968
1087
|
* the room let go of fails as `indexReloaded`, and one past `canLoad` as `indexShort`.
|
|
969
1088
|
*/
|
|
970
|
-
const roomed = Effect.fnUntraced(function* (pack, { bytes: floor, canLoad }) {
|
|
1089
|
+
const roomed = Effect.fnUntraced(function* (pack, { bytes: floor, canLoad }, from = bucket) {
|
|
971
1090
|
const known = kept.get(pack.id);
|
|
972
1091
|
if (known !== void 0) {
|
|
973
1092
|
kept.delete(pack.id);
|
|
@@ -983,7 +1102,7 @@ const packReader = (input) => {
|
|
|
983
1102
|
const bytes = indexBytes(pack);
|
|
984
1103
|
makeRoom(bytes, floor);
|
|
985
1104
|
for (const told of loadings) told(pack.id);
|
|
986
|
-
const loaded = yield* indexes.load(
|
|
1105
|
+
const loaded = yield* indexes.load(from, pack);
|
|
987
1106
|
const raced = kept.get(pack.id);
|
|
988
1107
|
if (raced !== void 0) return raced;
|
|
989
1108
|
makeRoom(bytes, floor);
|
|
@@ -1064,7 +1183,7 @@ const packReader = (input) => {
|
|
|
1064
1183
|
scope: repoScope(listed.repo),
|
|
1065
1184
|
reads: [{
|
|
1066
1185
|
collection: objectCollections.leaving,
|
|
1067
|
-
limit:
|
|
1186
|
+
limit: 1e3,
|
|
1068
1187
|
...page
|
|
1069
1188
|
}]
|
|
1070
1189
|
})).results[0] ?? [];
|
|
@@ -1074,7 +1193,7 @@ const packReader = (input) => {
|
|
|
1074
1193
|
objects: value.objects,
|
|
1075
1194
|
bytes: value.bytes
|
|
1076
1195
|
})).filter(unnamed),
|
|
1077
|
-
next: rows.length <
|
|
1196
|
+
next: rows.length < 1e3 ? void 0 : rows.at(-1)?.id
|
|
1078
1197
|
};
|
|
1079
1198
|
});
|
|
1080
1199
|
/**
|
|
@@ -1153,12 +1272,15 @@ const packReader = (input) => {
|
|
|
1153
1272
|
const inRows = /* @__PURE__ */ new Set();
|
|
1154
1273
|
yield* rows(unpacked, (object) => {
|
|
1155
1274
|
inRows.add(object.oid);
|
|
1275
|
+
observe?.located(object.oid, void 0);
|
|
1276
|
+
observe?.whole(object);
|
|
1156
1277
|
return row(object);
|
|
1157
1278
|
});
|
|
1158
1279
|
const missing = unpacked.filter((oid) => !inRows.has(oid));
|
|
1159
1280
|
if (missing.length > 0) for (const [oid, place] of yield* found(missing, "all", skip)) where.set(oid, place);
|
|
1160
1281
|
const skipped = skip === void 0 ? [] : missing.filter((oid) => !where.has(oid));
|
|
1161
1282
|
if (skipped.length > 0) for (const [oid, place] of yield* found(skipped)) where.set(oid, place);
|
|
1283
|
+
if (observe !== void 0) for (const [oid, { indexed }] of where) observe.located(oid, indexed.pack.id);
|
|
1162
1284
|
return where;
|
|
1163
1285
|
});
|
|
1164
1286
|
/**
|
|
@@ -1168,7 +1290,11 @@ const packReader = (input) => {
|
|
|
1168
1290
|
*/
|
|
1169
1291
|
const eachOf = (skip) => Effect.fnUntraced(function* (oids, take) {
|
|
1170
1292
|
const where = yield* located(oids, take, skip);
|
|
1171
|
-
for (const [oid, { indexed, offset }] of where)
|
|
1293
|
+
for (const [oid, { indexed, offset }] of where) {
|
|
1294
|
+
const whole = yield* wholeAt(oid, indexed, offset);
|
|
1295
|
+
observe?.whole(whole);
|
|
1296
|
+
yield* take(whole);
|
|
1297
|
+
}
|
|
1172
1298
|
});
|
|
1173
1299
|
/**
|
|
1174
1300
|
* `each` under `indexFloor`: the listed packs' objects a pack at a time, each read whole while its
|
|
@@ -1176,16 +1302,21 @@ const packReader = (input) => {
|
|
|
1176
1302
|
* holds, then the packs listed since and those leaving.
|
|
1177
1303
|
*/
|
|
1178
1304
|
const eachInRoom = Effect.fnUntraced(function* (oids, take) {
|
|
1179
|
-
const
|
|
1305
|
+
const deliver = (whole, pack) => {
|
|
1306
|
+
observe?.located(whole.oid, pack);
|
|
1307
|
+
observe?.whole(whole);
|
|
1308
|
+
return take(whole);
|
|
1309
|
+
};
|
|
1310
|
+
const left = yield* byPacks(oids, (indexed, entries) => Effect.forEach(entries, ({ oid, offset }) => Effect.flatMap(wholeAt(oid, indexed, offset), (whole) => deliver(whole, indexed.pack.id)), { discard: true }));
|
|
1180
1311
|
if (left.length === 0) return;
|
|
1181
1312
|
const inRows = /* @__PURE__ */ new Set();
|
|
1182
1313
|
yield* rows(left, (object) => {
|
|
1183
1314
|
inRows.add(object.oid);
|
|
1184
|
-
return
|
|
1315
|
+
return deliver(object, void 0);
|
|
1185
1316
|
});
|
|
1186
1317
|
const missing = left.filter((oid) => !inRows.has(oid));
|
|
1187
1318
|
if (missing.length === 0) return;
|
|
1188
|
-
for (const [oid, { indexed, offset }] of yield* found(missing, "beyond")) yield*
|
|
1319
|
+
for (const [oid, { indexed, offset }] of yield* found(missing, "beyond")) yield* deliver(yield* wholeAt(oid, indexed, offset), indexed.pack.id);
|
|
1189
1320
|
});
|
|
1190
1321
|
const each = indexFloor === void 0 ? eachOf() : eachInRoom;
|
|
1191
1322
|
/** Which of `oids` the repo holds, read whole, through `take`'s reads. */
|
|
@@ -1218,16 +1349,39 @@ const packReader = (input) => {
|
|
|
1218
1349
|
return (yield* wholeAt.atIn(oid, lookup, offset)).bytes.byteLength;
|
|
1219
1350
|
});
|
|
1220
1351
|
/**
|
|
1221
|
-
* The size of each of `oids` the repo holds, none held whole past its own read:
|
|
1222
|
-
*
|
|
1352
|
+
* The size of each of `oids` the repo holds, none held whole past its own read: in-memory cached
|
|
1353
|
+
* rows first (no call), then listed packs by their `.idx` (so a fully packed repo asks the store
|
|
1354
|
+
* for no row, as `located` does), then loose/staged rows for any left, then packs listed since
|
|
1355
|
+
* and those leaving. Each pack's entries are read in offset order so its neighbourhoods are read
|
|
1356
|
+
* once (#2960).
|
|
1223
1357
|
*/
|
|
1224
1358
|
const sizesOf = (skip) => Effect.fnUntraced(function* (oids) {
|
|
1225
1359
|
const sized = /* @__PURE__ */ new Map();
|
|
1226
|
-
|
|
1227
|
-
const
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1360
|
+
const needed = [];
|
|
1361
|
+
for (const oid of new Set(oids)) {
|
|
1362
|
+
if (listedOnly !== true && oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904") {
|
|
1363
|
+
sized.set(emptyTree, 0);
|
|
1364
|
+
continue;
|
|
1365
|
+
}
|
|
1366
|
+
const cached = listedOnly === true ? void 0 : rowCache?.headerOf(oid);
|
|
1367
|
+
if (cached !== void 0) {
|
|
1368
|
+
sized.set(oid, cached.size);
|
|
1369
|
+
continue;
|
|
1370
|
+
}
|
|
1371
|
+
needed.push(oid);
|
|
1372
|
+
}
|
|
1373
|
+
if (needed.length === 0) return sized;
|
|
1374
|
+
const where = yield* found(needed, "listed", skip);
|
|
1375
|
+
const unpacked = needed.filter((oid) => !where.has(oid));
|
|
1376
|
+
if (unpacked.length > 0) {
|
|
1377
|
+
for (const [oid, size] of yield* rowsSized(unpacked)) sized.set(oid, size);
|
|
1378
|
+
const missing = unpacked.filter((oid) => !sized.has(oid));
|
|
1379
|
+
if (missing.length > 0) {
|
|
1380
|
+
for (const [oid, place] of yield* found(missing, "beyond", skip)) where.set(oid, place);
|
|
1381
|
+
const skipped = skip === void 0 ? [] : missing.filter((oid) => !where.has(oid));
|
|
1382
|
+
if (skipped.length > 0) for (const [oid, place] of yield* found(skipped)) where.set(oid, place);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1231
1385
|
for (const [oid, { indexed, offset }] of byPlace(where)) sized.set(oid, yield* sizeAt(oid, loadedLookup(indexed), offset));
|
|
1232
1386
|
return sized;
|
|
1233
1387
|
});
|
|
@@ -1312,16 +1466,20 @@ const packReader = (input) => {
|
|
|
1312
1466
|
*/
|
|
1313
1467
|
const headers = Effect.fnUntraced(function* (oids) {
|
|
1314
1468
|
const listedAt = yield* found(oids, "listed");
|
|
1469
|
+
if (observe !== void 0) for (const [oid, { indexed }] of listedAt) observe.located(oid, indexed.pack.id);
|
|
1315
1470
|
const unpacked = oids.filter((oid) => !listedAt.has(oid));
|
|
1316
|
-
const answer = new Map(unpacked.length === 0 ? [] : yield*
|
|
1471
|
+
const answer = new Map(unpacked.length === 0 ? [] : yield* observedRowHeaders(unpacked));
|
|
1472
|
+
if (observe !== void 0) for (const oid of answer.keys()) observe.located(oid, void 0);
|
|
1317
1473
|
const missing = unpacked.filter((oid) => !answer.has(oid));
|
|
1318
1474
|
const later = missing.length === 0 ? [] : yield* found(missing, "beyond");
|
|
1475
|
+
if (observe !== void 0) for (const [oid, { indexed }] of later) observe.located(oid, indexed.pack.id);
|
|
1319
1476
|
const where = byPlace(new Map([...listedAt, ...later]));
|
|
1320
1477
|
const known = /* @__PURE__ */ new Map();
|
|
1321
1478
|
for (const [oid, { indexed, offset }] of where) {
|
|
1322
1479
|
const type = yield* typeAt(indexed, offset, known);
|
|
1323
1480
|
if (type === void 0) {
|
|
1324
1481
|
const whole = yield* wholeAt(oid, indexed, offset);
|
|
1482
|
+
observe?.whole(whole);
|
|
1325
1483
|
answer.set(oid, {
|
|
1326
1484
|
type: whole.type,
|
|
1327
1485
|
size: whole.bytes.byteLength
|
|
@@ -1407,7 +1565,8 @@ const packReader = (input) => {
|
|
|
1407
1565
|
* it's `storedOf`'s answer set in the columns.
|
|
1408
1566
|
*/
|
|
1409
1567
|
const storedInto = Effect.fnUntraced(function* (columns, ordinals, skip) {
|
|
1410
|
-
const asking = Uint32Array.from(ordinals);
|
|
1568
|
+
const asking = rowCache === void 0 ? Uint32Array.from(ordinals) : Uint32Array.from(ordinals).filter((ordinal) => !rowCache.has(columns.oidAt(ordinal)));
|
|
1569
|
+
if (asking.length === 0) return;
|
|
1411
1570
|
if (indexFloor !== void 0 && skip === void 0) {
|
|
1412
1571
|
const entries = yield* storedOf(Array.from(asking, (ordinal) => columns.oidAt(ordinal)));
|
|
1413
1572
|
for (const ordinal of asking) {
|
|
@@ -1474,7 +1633,11 @@ const packReader = (input) => {
|
|
|
1474
1633
|
gets: (entries) => blocks.gets(entries),
|
|
1475
1634
|
run: (pack, from, to) => packRun(bucket, pack, from, to),
|
|
1476
1635
|
kept: (pack, offset) => blocks.keeps(pack, offset),
|
|
1477
|
-
packed: (oids) => Effect.map(found(oids, "listed"), (where) => new Set(where.keys()))
|
|
1636
|
+
packed: (oids) => Effect.map(found(oids, "listed"), (where) => new Set(where.keys())),
|
|
1637
|
+
...rowCache !== void 0 && {
|
|
1638
|
+
cachedRow: (oid) => rowCache.has(oid),
|
|
1639
|
+
pinCachedRows: (reserveBytes) => rowCache.pin(reserveBytes)
|
|
1640
|
+
}
|
|
1478
1641
|
};
|
|
1479
1642
|
/**
|
|
1480
1643
|
* The object `oid` as `ObjectReader.read` hands it on, rows first: a whole entry past
|
|
@@ -1603,12 +1766,12 @@ const packReader = (input) => {
|
|
|
1603
1766
|
* lookups load them, once a pack, through the server's cache, so a fetch's index path and its
|
|
1604
1767
|
* walk read them once between them, and none when the cache holds them.
|
|
1605
1768
|
*/
|
|
1606
|
-
const indexed = Effect.fnUntraced(function* (pack) {
|
|
1607
|
-
if (indexFloor !== void 0) return yield* roomed(pack, indexFloor);
|
|
1769
|
+
const indexed = Effect.fnUntraced(function* (pack, from = bucket) {
|
|
1770
|
+
if (indexFloor !== void 0) return yield* roomed(pack, indexFloor, from);
|
|
1608
1771
|
const known = kept.get(pack.id);
|
|
1609
1772
|
if (known !== void 0) return known;
|
|
1610
1773
|
yield* charge(pack);
|
|
1611
|
-
const loaded = yield* indexes.load(
|
|
1774
|
+
const loaded = yield* indexes.load(from, pack);
|
|
1612
1775
|
kept.set(pack.id, loaded);
|
|
1613
1776
|
return loaded;
|
|
1614
1777
|
});
|
|
@@ -1720,6 +1883,7 @@ const packReader = (input) => {
|
|
|
1720
1883
|
};
|
|
1721
1884
|
const reads = {
|
|
1722
1885
|
indexed,
|
|
1886
|
+
cachedIndex: (pack) => kept.has(pack.id) || indexes.has(pack.id),
|
|
1723
1887
|
loadedOf: (pack) => kept.get(pack.id),
|
|
1724
1888
|
onLoading: (told) => {
|
|
1725
1889
|
loadings.add(told);
|
|
@@ -1804,4 +1968,4 @@ const narrowedTo = (reads, visible) => {
|
|
|
1804
1968
|
wholeBlobs: (oids) => Effect.flatMap(only(oids), reads.wholeBlobs)
|
|
1805
1969
|
};
|
|
1806
1970
|
};
|
|
1807
|
-
export { IndexReloaded, IndexShort, PackBlocks, PackIndexes, blockBytes, blockHeld, blocksHeld, entryEnd, hashedNowMost, hashedRunMost, headerLimits, indexBytes, indexSeedShare, isIndexReloaded, isIndexShort, loadedLookup, packIndexerLimits, packObjectBytes, packObjects, packReader, rangedLookup, readCacheBytes, readInto, seedBytes };
|
|
1971
|
+
export { IndexReloaded, IndexShort, PackBlocks, PackIndexes, blockBytes, blockHeld, blocksHeld, entryEnd, hashedNowMost, hashedRunMost, headerLimits, indexBytes, indexSeedShare, isIndexReloaded, isIndexShort, leavingPageRows, loadedLookup, packIndexerLimits, packObjectBytes, packObjects, packReader, rangedLookup, readCacheBytes, readInto, seedBytes };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "../contracts/time.mjs";
|
|
2
2
|
import "../contracts/objects.mjs";
|
|
3
3
|
import "../contracts/result.mjs";
|
|
4
|
-
import "../contracts/services.mjs";
|
|
5
4
|
import "../contracts/store.mjs";
|
|
6
5
|
import "../protocol/packs/indexer.mjs";
|
|
7
6
|
import "../protocol/packs/step.mjs";
|
|
@@ -11,6 +10,6 @@ import "./runs.mjs";
|
|
|
11
10
|
import "./receive-state.mjs";
|
|
12
11
|
import "./pack-reads.mjs";
|
|
13
12
|
import "./quarantine.mjs";
|
|
14
|
-
import "effect/Effect";
|
|
15
13
|
import { Moment } from "@ref0/infra";
|
|
14
|
+
import "effect/Effect";
|
|
16
15
|
import "effect/Types";
|
|
@@ -13,7 +13,7 @@ import { catchSpent, ownSpentOf } from "../contracts/calls-spent.mjs";
|
|
|
13
13
|
import { bestEffort } from "../store/errors.mjs";
|
|
14
14
|
import { CallBudget, requestCount, spentBudget } from "../store/call-count.mjs";
|
|
15
15
|
import { newChangeId } from "../store/scopes.mjs";
|
|
16
|
-
import { bucketPut, bucketReading, bucketStreamScoped } from "./calls.mjs";
|
|
16
|
+
import { bucketPut, bucketReading, bucketStreamScoped, bucketTry } from "./calls.mjs";
|
|
17
17
|
import { packPutOptions, startPut } from "./merge.mjs";
|
|
18
18
|
import { repoTypes } from "./held-types.mjs";
|
|
19
19
|
import { checkedFilesRefused, checkedOverflow, checkedRecords, fsckRefusal, receiveChecked } from "./fsck.mjs";
|
|
@@ -37,8 +37,8 @@ import { dropRefused, openQuarantine, stillOpen } from "./quarantine.mjs";
|
|
|
37
37
|
import { malformedPack, ofsRefused, readFailure } from "./unpack.mjs";
|
|
38
38
|
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
39
39
|
import * as Effect from "effect/Effect";
|
|
40
|
-
import * as Result from "effect/Result";
|
|
41
40
|
import * as Data from "effect/Data";
|
|
41
|
+
import * as Result from "effect/Result";
|
|
42
42
|
// src/storage/pack-receive.ts
|
|
43
43
|
/**
|
|
44
44
|
* How large the reader lets an entry be: a whole one to `fileBytesMost`, kept only if it's a blob,
|
|
@@ -216,7 +216,10 @@ const unindexable = (offset, why, most = packObjectBytes) => {
|
|
|
216
216
|
hint: deepHint,
|
|
217
217
|
context: { reason: "too-large" }
|
|
218
218
|
});
|
|
219
|
-
return gitError("INVALID_ARGUMENT", `The delta at ${offset} has no base before it in the pack`, {
|
|
219
|
+
return gitError("INVALID_ARGUMENT", `The delta at ${offset} has no base before it in the pack`, {
|
|
220
|
+
hint: "Push again, with every object the pack needs: this server asks for no thin packs",
|
|
221
|
+
context: { reason: "base-not-before" }
|
|
222
|
+
});
|
|
220
223
|
};
|
|
221
224
|
/**
|
|
222
225
|
* The pack's bytes on their way to the bucket as they're read, through `startPut`, the last
|
|
@@ -315,20 +318,16 @@ const spentRuns = {
|
|
|
315
318
|
*/
|
|
316
319
|
const putAgain = (bucket, key, bytes, put) => put.pipe(Effect.catchIf((error) => error.code === "ALREADY_EXISTS", (error) => Effect.flatMap(sameFile(bucket, key, bytes), (same) => same ? Effect.void : Effect.fail(error))));
|
|
317
320
|
/** Whether the file at `key` holds exactly `bytes`. */
|
|
318
|
-
const sameFile = (bucket, key, bytes) => bucketReading(bucket, key, void 0,
|
|
319
|
-
if (
|
|
320
|
-
const reader = body.getReader();
|
|
321
|
+
const sameFile = (bucket, key, bytes) => bucketReading(bucket, key, void 0, Effect.fnUntraced(function* (reader) {
|
|
322
|
+
if (reader === void 0) return false;
|
|
321
323
|
let at = 0;
|
|
322
|
-
for (let piece =
|
|
324
|
+
for (let piece = yield* bucketTry(() => reader.read()); !piece.done; piece = yield* bucketTry(() => reader.read())) {
|
|
323
325
|
const { value } = piece;
|
|
324
|
-
if (at + value.byteLength > bytes.byteLength || value.some((byte, index) => byte !== bytes[at + index]))
|
|
325
|
-
await reader.cancel();
|
|
326
|
-
return false;
|
|
327
|
-
}
|
|
326
|
+
if (at + value.byteLength > bytes.byteLength || value.some((byte, index) => byte !== bytes[at + index])) return false;
|
|
328
327
|
at += value.byteLength;
|
|
329
328
|
}
|
|
330
329
|
return at === bytes.byteLength;
|
|
331
|
-
});
|
|
330
|
+
}));
|
|
332
331
|
/** The pack's bytes and files under its opened row, as `receivePack` says. */
|
|
333
332
|
const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, step) {
|
|
334
333
|
const { store, bucket, indexes, listed, receive, memory } = input;
|
|
@@ -411,10 +410,12 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
411
410
|
const boundary = new Set(joining === void 0 ? receive.boundary : []);
|
|
412
411
|
yield* room.take(boundary.size * 120) ?? Effect.void;
|
|
413
412
|
const named = !partial && new Set(receive.boundary).size === 0;
|
|
413
|
+
const looseRows = receive.hasLooseRows === false ? { hasLooseRows: false } : {};
|
|
414
414
|
const typesHeld = repoTypes({
|
|
415
415
|
...reading,
|
|
416
416
|
memory: memory.join,
|
|
417
|
-
reader
|
|
417
|
+
reader,
|
|
418
|
+
...looseRows
|
|
418
419
|
});
|
|
419
420
|
const linkedTypes = (there) => {
|
|
420
421
|
const types = /* @__PURE__ */ new Map();
|
|
@@ -1016,11 +1017,16 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
1016
1017
|
const put = bucketPut(bucket, key, bytes);
|
|
1017
1018
|
return step === void 0 ? put : putAgain(bucket, key, bytes, put);
|
|
1018
1019
|
};
|
|
1019
|
-
yield*
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1020
|
+
yield* Effect.all([
|
|
1021
|
+
putFile(files.idx, written.index),
|
|
1022
|
+
putFile(files.rev, written.reverse),
|
|
1023
|
+
putFile(files.pos, written.positions),
|
|
1024
|
+
putFile(files.graph, graph),
|
|
1025
|
+
putFile(files.types, written.types)
|
|
1026
|
+
], {
|
|
1027
|
+
concurrency: 5,
|
|
1028
|
+
discard: true
|
|
1029
|
+
});
|
|
1024
1030
|
if (step === void 0 && (received.spilled() || ended.spilled || links.spilled())) yield* dropRuns(bucket, opened.pack);
|
|
1025
1031
|
yield* stillOpen({
|
|
1026
1032
|
store,
|