@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
|
@@ -1,73 +1,208 @@
|
|
|
1
|
-
import { bodyOfBytes, bucketBodyIn, joined, readEach } from "./calls.mjs";
|
|
1
|
+
import { bodyOfBytes, bucketBodyIn, bucketDo, joined, readEach } from "./calls.mjs";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Predicate from "effect/Predicate";
|
|
3
4
|
import "effect/Context";
|
|
4
5
|
/** Room each pack's kept ranges take for their entries beside their bytes: 64 entries. */
|
|
5
6
|
const rangeEntriesBytes = 20480;
|
|
6
7
|
/**
|
|
7
8
|
* `bucket`, its `.idx` and `.pos` range reads kept up to `most` bytes, the least recently used let
|
|
8
9
|
* go first, and replayed from memory with no call: it sits above `countedBucket`, so only a range
|
|
9
|
-
* that reaches the bucket is charged.
|
|
10
|
-
*
|
|
11
|
-
* through
|
|
12
|
-
*
|
|
10
|
+
* that reaches the bucket is charged. A requested range covered by one kept span, or by contiguous
|
|
11
|
+
* kept spans of the same key, is answered from them without reading the bucket. Every other read
|
|
12
|
+
* goes through as it is, and a range past `most` alone is never kept. With `evict: false`, a full
|
|
13
|
+
* cache keeps what it has and lets later ranges through: a scan past `most` in the same order every
|
|
14
|
+
* time, as a bitmaps step's joins, then still finds the ranges it kept, where letting the oldest go
|
|
15
|
+
* would find none. With `headers: true`, ranges starting at offset 0 are kept too, so a step that
|
|
16
|
+
* primes a file's header with its table answers both from the same read.
|
|
13
17
|
*/
|
|
14
|
-
const rangeCached = (bucket, most, { evict = true } = {}) => {
|
|
18
|
+
const rangeCached = (bucket, most, { evict = true, headers = false } = {}) => {
|
|
15
19
|
const kept = /* @__PURE__ */ new Map();
|
|
20
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
21
|
+
const filling = /* @__PURE__ */ new Set();
|
|
16
22
|
let held = 0;
|
|
23
|
+
let keptBytes = 0;
|
|
24
|
+
let fillingBytes = 0;
|
|
25
|
+
let primingBytes = 0;
|
|
17
26
|
let closed = false;
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return
|
|
27
|
+
const eligible = (key, range) => !closed && (key.endsWith(".idx") || key.endsWith(".pos")) && range !== void 0 && (headers || range.offset !== 0);
|
|
28
|
+
const touch = (span) => {
|
|
29
|
+
kept.delete(span.at);
|
|
30
|
+
kept.set(span.at, span);
|
|
31
|
+
};
|
|
32
|
+
const removeSpan = (span) => {
|
|
33
|
+
if (!kept.delete(span.at)) return;
|
|
34
|
+
held -= span.bytes.byteLength + 320;
|
|
35
|
+
keptBytes -= span.bytes.byteLength;
|
|
36
|
+
const spans = byKey.get(span.key);
|
|
37
|
+
if (spans === void 0) return;
|
|
38
|
+
const index = spans.indexOf(span);
|
|
39
|
+
if (index >= 0) spans.splice(index, 1);
|
|
40
|
+
if (spans.length === 0) byKey.delete(span.key);
|
|
41
|
+
};
|
|
42
|
+
const replay = (key, offset, length) => {
|
|
43
|
+
const spans = byKey.get(key);
|
|
44
|
+
if (spans === void 0 || spans.length === 0) return void 0;
|
|
45
|
+
const exact = kept.get(`${key}@${offset}+${length}`);
|
|
46
|
+
if (exact !== void 0) {
|
|
47
|
+
touch(exact);
|
|
48
|
+
return exact.bytes;
|
|
49
|
+
}
|
|
50
|
+
const end = offset + length;
|
|
51
|
+
for (const span of spans) if (span.offset <= offset && span.end >= end) {
|
|
52
|
+
touch(span);
|
|
53
|
+
return span.bytes.subarray(offset - span.offset, end - span.offset);
|
|
54
|
+
}
|
|
55
|
+
if (spans.length < 2) return void 0;
|
|
56
|
+
const overlapping = spans.filter((span) => span.end > offset && span.offset < end).sort((left, right) => left.offset - right.offset);
|
|
57
|
+
if (overlapping.length < 2) return void 0;
|
|
58
|
+
let cursor = offset;
|
|
59
|
+
const pieces = [];
|
|
60
|
+
for (const span of overlapping) {
|
|
61
|
+
if (span.end <= cursor) continue;
|
|
62
|
+
if (span.offset > cursor) return void 0;
|
|
63
|
+
const takeEnd = Math.min(span.end, end);
|
|
64
|
+
pieces.push({
|
|
65
|
+
span,
|
|
66
|
+
from: cursor - span.offset,
|
|
67
|
+
to: takeEnd - span.offset
|
|
68
|
+
});
|
|
69
|
+
cursor = takeEnd;
|
|
70
|
+
if (cursor === end) break;
|
|
71
|
+
}
|
|
72
|
+
if (cursor !== end) return void 0;
|
|
73
|
+
const out = new Uint8Array(length);
|
|
74
|
+
let written = 0;
|
|
75
|
+
for (const { span, from, to } of pieces) {
|
|
76
|
+
touch(span);
|
|
77
|
+
out.set(span.bytes.subarray(from, to), written);
|
|
78
|
+
written += to - from;
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
};
|
|
82
|
+
const makeRoom = (cost) => {
|
|
83
|
+
if (cost > most) return false;
|
|
84
|
+
if (evict) for (const [, oldest] of kept) {
|
|
85
|
+
if (held + fillingBytes + cost <= most) break;
|
|
86
|
+
removeSpan(oldest);
|
|
87
|
+
}
|
|
88
|
+
return held + fillingBytes + cost <= most;
|
|
25
89
|
};
|
|
26
|
-
const keep = (
|
|
90
|
+
const keep = (key, offset, bytes) => {
|
|
27
91
|
if (closed) return;
|
|
92
|
+
const at = `${key}@${offset}+${bytes.byteLength}`;
|
|
93
|
+
const prior = kept.get(at);
|
|
94
|
+
if (prior !== void 0) removeSpan(prior);
|
|
28
95
|
const cost = bytes.byteLength + 320;
|
|
29
|
-
if (cost
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
96
|
+
if (!makeRoom(cost)) return;
|
|
97
|
+
const span = {
|
|
98
|
+
at,
|
|
99
|
+
key,
|
|
100
|
+
offset,
|
|
101
|
+
end: offset + bytes.byteLength,
|
|
102
|
+
bytes
|
|
103
|
+
};
|
|
104
|
+
kept.set(at, span);
|
|
105
|
+
const spans = byKey.get(key);
|
|
106
|
+
if (spans === void 0) byKey.set(key, [span]);
|
|
107
|
+
else spans.push(span);
|
|
36
108
|
held += cost;
|
|
109
|
+
keptBytes += bytes.byteLength;
|
|
37
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Reads `range` of `key` directly into one buffer reserved against `most` before `bucket.read`
|
|
113
|
+
* starts, and keeps it for later exact or sub-range hits: no copy through `bodyOfBytes`, and
|
|
114
|
+
* dropped at once if `clear` runs mid-read. Missing or short bytes keep nothing, letting the
|
|
115
|
+
* caller's own read report `DATA_LOSS`; other failures and spent call bounds propagate.
|
|
116
|
+
*/
|
|
117
|
+
const prime = (key, range) => Effect.suspend(() => {
|
|
118
|
+
if (range.length === 0 || !eligible(key, range)) return Effect.void;
|
|
119
|
+
if (replay(key, range.offset, range.length) !== void 0) return Effect.void;
|
|
120
|
+
const cost = range.length + 320;
|
|
121
|
+
if (!makeRoom(cost)) return Effect.void;
|
|
122
|
+
let target = new Uint8Array(range.length);
|
|
123
|
+
primingBytes += target.byteLength;
|
|
124
|
+
let filled = 0;
|
|
125
|
+
const dropTarget = () => {
|
|
126
|
+
if (target === void 0) return;
|
|
127
|
+
primingBytes -= target.byteLength;
|
|
128
|
+
target = void 0;
|
|
129
|
+
};
|
|
130
|
+
const fill = {
|
|
131
|
+
cost,
|
|
132
|
+
drop: dropTarget
|
|
133
|
+
};
|
|
134
|
+
filling.add(fill);
|
|
135
|
+
fillingBytes += cost;
|
|
136
|
+
const release = () => {
|
|
137
|
+
if (filling.delete(fill)) fillingBytes -= fill.cost;
|
|
138
|
+
dropTarget();
|
|
139
|
+
};
|
|
140
|
+
return bucketDo(readEach(bucket, key, range, (chunk) => Effect.sync(() => {
|
|
141
|
+
if (target === void 0) return;
|
|
142
|
+
if (filled + chunk.byteLength > target.byteLength) {
|
|
143
|
+
dropTarget();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
target.set(chunk, filled);
|
|
147
|
+
filled += chunk.byteLength;
|
|
148
|
+
})).pipe(Effect.catchIf((error) => Predicate.isTagged(error, "NotFound"), () => Effect.sync(dropTarget)))).pipe(Effect.tap(() => Effect.sync(() => {
|
|
149
|
+
const bytes = target;
|
|
150
|
+
dropTarget();
|
|
151
|
+
if (bytes !== void 0 && filled === range.length && !closed) {
|
|
152
|
+
if (filling.delete(fill)) fillingBytes -= fill.cost;
|
|
153
|
+
keep(key, range.offset, bytes);
|
|
154
|
+
}
|
|
155
|
+
})), Effect.ensuring(Effect.sync(release)));
|
|
156
|
+
});
|
|
38
157
|
const cached = {
|
|
39
158
|
...bucket,
|
|
40
|
-
read: (key, range) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return Effect.suspend(() => {
|
|
44
|
-
const found = replay(at);
|
|
159
|
+
read: (key, range) => Effect.suspend(() => {
|
|
160
|
+
if (eligible(key, range)) {
|
|
161
|
+
const found = replay(key, range.offset, range.length);
|
|
45
162
|
if (found !== void 0) return bodyOfBytes(found);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
163
|
+
const cost = range.length + 320;
|
|
164
|
+
if (makeRoom(cost)) {
|
|
165
|
+
const fill = {
|
|
166
|
+
cost,
|
|
167
|
+
drop: () => void 0
|
|
168
|
+
};
|
|
169
|
+
filling.add(fill);
|
|
170
|
+
fillingBytes += cost;
|
|
171
|
+
const chunks = [];
|
|
172
|
+
return Effect.flatMap(Effect.interruptible(readEach(bucket, key, range, (chunk) => Effect.sync(() => void chunks.push(chunk)))), () => {
|
|
173
|
+
if (filling.delete(fill)) fillingBytes -= fill.cost;
|
|
174
|
+
const bytes = joined(chunks);
|
|
175
|
+
keep(key, range.offset, bytes);
|
|
176
|
+
return bodyOfBytes(bytes);
|
|
177
|
+
}).pipe(Effect.ensuring(Effect.sync(() => {
|
|
178
|
+
if (filling.delete(fill)) fillingBytes -= fill.cost;
|
|
179
|
+
})));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return bucket.read(key, range);
|
|
183
|
+
})
|
|
54
184
|
};
|
|
55
185
|
const clear = () => {
|
|
186
|
+
for (const fill of filling) fill.drop();
|
|
187
|
+
filling.clear();
|
|
188
|
+
fillingBytes = 0;
|
|
56
189
|
kept.clear();
|
|
190
|
+
byKey.clear();
|
|
57
191
|
held = 0;
|
|
192
|
+
keptBytes = 0;
|
|
58
193
|
closed = true;
|
|
59
194
|
};
|
|
60
195
|
const forget = (key) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
held -= bytes.byteLength + 320;
|
|
65
|
-
}
|
|
196
|
+
const spans = byKey.get(key);
|
|
197
|
+
if (spans === void 0) return;
|
|
198
|
+
for (const span of [...spans]) removeSpan(span);
|
|
66
199
|
};
|
|
67
200
|
return {
|
|
68
201
|
bucket: cached,
|
|
69
202
|
clear,
|
|
70
|
-
forget
|
|
203
|
+
forget,
|
|
204
|
+
held: () => keptBytes + primingBytes,
|
|
205
|
+
prime
|
|
71
206
|
};
|
|
72
207
|
};
|
|
73
208
|
/** The most a whole-file cache replays a piece: well within any reader's piece bound. */
|
package/dist/storage/raw-ids.mjs
CHANGED
|
@@ -19,19 +19,22 @@ const idsBytes = (ids) => {
|
|
|
19
19
|
bytes
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
/** `a`'s 20 bytes from `ai` against `b`'s from `bi`, as unsigned bytes. */
|
|
23
|
-
const
|
|
24
|
-
for (let each =
|
|
22
|
+
/** `a`'s 20 bytes from `ai + from` against `b`'s from `bi + from`, as unsigned bytes. */
|
|
23
|
+
const compareIdsFrom = (a, ai, b, bi, from) => {
|
|
24
|
+
for (let each = from; each < 20; each += 1) {
|
|
25
25
|
const diff = (a[ai + each] ?? 0) - (b[bi + each] ?? 0);
|
|
26
26
|
if (diff !== 0) return diff;
|
|
27
27
|
}
|
|
28
28
|
return 0;
|
|
29
29
|
};
|
|
30
|
+
/** `a`'s 20 bytes from `ai` against `b`'s from `bi`, as unsigned bytes. */
|
|
31
|
+
const compareIds = (a, ai, b, bi) => compareIdsFrom(a, ai, b, bi, 0);
|
|
30
32
|
/**
|
|
31
|
-
* The links' order by ID
|
|
32
|
-
*
|
|
33
|
+
* The links' order by ID and its 12-bit prefix fanout (4,096 buckets, `fanout[prefix]` to
|
|
34
|
+
* `fanout[prefix + 1]`): a counting sort on their first two bytes, then each bucket, a handful
|
|
35
|
+
* of links in a large slice, by insertion on the remaining 18 bytes.
|
|
33
36
|
*/
|
|
34
|
-
const
|
|
37
|
+
const orderWithStarts = (ids, size) => {
|
|
35
38
|
const starts = /* @__PURE__ */ new Uint32Array(65537);
|
|
36
39
|
for (let at = 0; at < size; at += 1) {
|
|
37
40
|
const bucket = (ids[at * 20] ?? 0) << 8 | (ids[at * 20 + 1] ?? 0);
|
|
@@ -50,14 +53,40 @@ const orderById = (ids, size) => {
|
|
|
50
53
|
const to = starts[bucket + 1] ?? 0;
|
|
51
54
|
for (let at = from + 1; at < to; at += 1) {
|
|
52
55
|
const link = order[at] ?? 0;
|
|
56
|
+
const linkOff = link * 20;
|
|
57
|
+
const link2 = ids[linkOff + 2] ?? 0;
|
|
53
58
|
let place = at;
|
|
54
|
-
while (place > from
|
|
55
|
-
|
|
59
|
+
while (place > from) {
|
|
60
|
+
const prev = order[place - 1] ?? 0;
|
|
61
|
+
const prevOff = prev * 20;
|
|
62
|
+
const diff2 = (ids[prevOff + 2] ?? 0) - link2;
|
|
63
|
+
if (diff2 < 0 || diff2 === 0 && compareIdsFrom(ids, prevOff, ids, linkOff, 3) <= 0) break;
|
|
64
|
+
order[place] = prev;
|
|
56
65
|
place -= 1;
|
|
57
66
|
}
|
|
58
67
|
order[place] = link;
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
|
-
return
|
|
70
|
+
return {
|
|
71
|
+
order,
|
|
72
|
+
starts
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* The links' order by ID: a counting sort on their first two bytes, then each bucket, a handful
|
|
77
|
+
* of links in a large slice, by insertion on the rest.
|
|
78
|
+
*/
|
|
79
|
+
const orderById = (ids, size) => orderWithStarts(ids, size).order;
|
|
80
|
+
/** The 12-bit prefix fanout size: 4,096 buckets over `(id[0] << 4) | (id[1] >>> 4)`. */
|
|
81
|
+
const idFanoutBuckets = 4096;
|
|
82
|
+
/** `orderById` with its 12-bit prefix fanout table (`fanout[p]..fanout[p + 1]`), 16 KiB. */
|
|
83
|
+
const orderByIdWithFanout = (ids, size) => {
|
|
84
|
+
const { order, starts } = orderWithStarts(ids, size);
|
|
85
|
+
const fanout = /* @__PURE__ */ new Uint32Array(4097);
|
|
86
|
+
for (let bucket = 0; bucket <= idFanoutBuckets; bucket += 1) fanout[bucket] = starts[bucket << 4] ?? size;
|
|
87
|
+
return {
|
|
88
|
+
order,
|
|
89
|
+
fanout
|
|
90
|
+
};
|
|
62
91
|
};
|
|
63
|
-
export { compareIds, idsBytes, orderById };
|
|
92
|
+
export { compareIds, compareIdsFrom, idFanoutBuckets, idsBytes, orderById, orderByIdWithFanout };
|
package/dist/storage/ready.d.mts
CHANGED
|
@@ -2,13 +2,12 @@ import "../contracts/time.mjs";
|
|
|
2
2
|
import "../contracts/objects.mjs";
|
|
3
3
|
import "../contracts/ids.mjs";
|
|
4
4
|
import "../contracts/result.mjs";
|
|
5
|
-
import "../contracts/services.mjs";
|
|
6
5
|
import "../contracts/store.mjs";
|
|
7
6
|
import "./fetch.mjs";
|
|
8
7
|
import "./walk.mjs";
|
|
9
|
-
import "effect/Effect";
|
|
10
|
-
import "effect/Schema";
|
|
11
8
|
import { Key, Moment, Row } from "@ref0/infra";
|
|
9
|
+
import "effect/Schema";
|
|
10
|
+
import "effect/Effect";
|
|
12
11
|
import "effect/Scope";
|
|
13
12
|
/**
|
|
14
13
|
* `packs()`' pack kept ready for a shallow clone of the default branch: one with exactly `depth`,
|
package/dist/storage/ready.mjs
CHANGED
|
@@ -12,12 +12,12 @@ import { isPackId, objectCollections, packFiles } from "./layout.mjs";
|
|
|
12
12
|
import { noRows } from "./object-rows.mjs";
|
|
13
13
|
import { openQuarantine } from "./quarantine.mjs";
|
|
14
14
|
import { leavingRow, removeAt } from "./rows.mjs";
|
|
15
|
-
import * as Clock from "effect/Clock";
|
|
16
|
-
import * as Effect from "effect/Effect";
|
|
17
15
|
import * as Schema from "effect/Schema";
|
|
16
|
+
import * as Effect from "effect/Effect";
|
|
18
17
|
import * as Exit from "effect/Exit";
|
|
19
|
-
import * as Hex from "effect/encoding/Hex";
|
|
20
18
|
import * as Deferred from "effect/Deferred";
|
|
19
|
+
import * as Clock from "effect/Clock";
|
|
20
|
+
import * as Hex from "effect/encoding/Hex";
|
|
21
21
|
// src/storage/ready.ts
|
|
22
22
|
/** `git clone --depth 1` of the default branch, within 20,000 objects. */
|
|
23
23
|
const defaultShallow = {
|
|
@@ -34,6 +34,19 @@ const readyBytesMost = 67108864;
|
|
|
34
34
|
* the row stays well under a store's 1 MiB.
|
|
35
35
|
*/
|
|
36
36
|
const readyShallowsMost = 1e4;
|
|
37
|
+
/**
|
|
38
|
+
* The most a shallow clone that missed waits for its ask for the ready pack to save, before its
|
|
39
|
+
* pack is planned: past it the ask is dropped, and a later clone asks again. Well under a stream's
|
|
40
|
+
* 30 s unread bound, though the ask is made before the stream is (#2898).
|
|
41
|
+
*/
|
|
42
|
+
const readyAskMs = 2e3;
|
|
43
|
+
/**
|
|
44
|
+
* What a shallow clone that missed keeps of its fetch's time for its own plan and pack, before it
|
|
45
|
+
* gives any to its ask: with less left, it doesn't ask. Planning and sending a first clone of 825
|
|
46
|
+
* and of 4,951 objects took 61 and 178 ms locally, so 5 s leaves room for a host's slower store
|
|
47
|
+
* (#2898).
|
|
48
|
+
*/
|
|
49
|
+
const readyAskRoomMs = 5e3;
|
|
37
50
|
/** How long a ready pack's build may take to write: a third of `git.repack`'s 15 minutes. */
|
|
38
51
|
const readyMilliseconds = 3e5;
|
|
39
52
|
const PackIdText = /* @__PURE__ */ Schema.String.check(Schema.isPattern(/^p_[A-Za-z0-9_-]{16}$/));
|
|
@@ -65,6 +78,21 @@ const readyRow = (value) => ({
|
|
|
65
78
|
...readyKey,
|
|
66
79
|
value
|
|
67
80
|
});
|
|
81
|
+
/**
|
|
82
|
+
* A shallow clone's ask for a ready pack, in `ready` by `wanted`: the tip it cloned, when it found
|
|
83
|
+
* none for that tip. Added, never put, so the repo holds one until `git.repack`'s ready step takes
|
|
84
|
+
* it: it builds the pack when the ask names the default branch's tip, and drops it otherwise.
|
|
85
|
+
*/
|
|
86
|
+
const ReadyWanted = /* @__PURE__ */ Schema.Struct({ tip: Schema.String });
|
|
87
|
+
const wantedKey = {
|
|
88
|
+
collection: objectCollections.ready,
|
|
89
|
+
id: "wanted"
|
|
90
|
+
};
|
|
91
|
+
/** The row a missed clone of `tip` adds. */
|
|
92
|
+
const wantedRow = (tip) => ({
|
|
93
|
+
...wantedKey,
|
|
94
|
+
value: { tip }
|
|
95
|
+
});
|
|
68
96
|
/** The tags a fetch may follow, as one digest: the sorted IDs, each once, hashed. */
|
|
69
97
|
const tagsDigest = (tags) => {
|
|
70
98
|
const sha = new Sha1();
|
|
@@ -80,6 +108,7 @@ const readyRequest = (tip, depth) => ({
|
|
|
80
108
|
includeTag: true
|
|
81
109
|
});
|
|
82
110
|
const decodeReady = (row) => row === void 0 ? Effect.succeed(void 0) : decodeRow(ReadyRow, row, "The ready shallow pack's row");
|
|
111
|
+
const decodeWanted = (row) => row === void 0 ? Effect.succeed(void 0) : decodeRow(ReadyWanted, row, "The ready shallow pack's ask");
|
|
83
112
|
const readOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed) {
|
|
84
113
|
const snapshot = yield* store.read({
|
|
85
114
|
scope: repoScope(listed.repo),
|
|
@@ -88,17 +117,34 @@ const readOf = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed) {
|
|
|
88
117
|
return yield* decodeReady(snapshot.results[0]?.[0]);
|
|
89
118
|
});
|
|
90
119
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
120
|
+
* Whether a clone's ask waits already: read only by a clone that would ask, apart from the ready
|
|
121
|
+
* row, which a request's snapshot answers from memory (#2899), so a clone the ready pack serves
|
|
122
|
+
* reads no more than before.
|
|
123
|
+
*/
|
|
124
|
+
const askWaits = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed) {
|
|
125
|
+
const snapshot = yield* store.read({
|
|
126
|
+
scope: repoScope(listed.repo),
|
|
127
|
+
reads: [wantedKey]
|
|
128
|
+
});
|
|
129
|
+
return (yield* decodeWanted(snapshot.results[0]?.[0])) !== void 0;
|
|
130
|
+
});
|
|
131
|
+
/**
|
|
132
|
+
* The ready row, the repo's roots and the ask for a pack, in one read: a step builds over the
|
|
133
|
+
* roots as they are now, with no fetch to pass them, as `git.index`'s build reads them.
|
|
93
134
|
*/
|
|
94
135
|
const readWithRoots = /* @__PURE__ */ Effect.fnUntraced(function* (store, listed) {
|
|
95
136
|
const snapshot = yield* store.read({
|
|
96
137
|
scope: repoScope(listed.repo),
|
|
97
|
-
reads: [
|
|
138
|
+
reads: [
|
|
139
|
+
readyKey,
|
|
140
|
+
repoRootsKey,
|
|
141
|
+
wantedKey
|
|
142
|
+
]
|
|
98
143
|
});
|
|
99
144
|
return {
|
|
100
145
|
ready: yield* decodeReady(snapshot.results[0]?.[0]),
|
|
101
|
-
roots: yield* rootsOf(snapshot.results[1])
|
|
146
|
+
roots: yield* rootsOf(snapshot.results[1]),
|
|
147
|
+
wanted: yield* decodeWanted(snapshot.results[2]?.[0])
|
|
102
148
|
};
|
|
103
149
|
});
|
|
104
150
|
/** The bytes of the ready pack `rows`, a read of `readyKey`, hold: 0 with none kept. */
|
|
@@ -108,6 +154,11 @@ const readyBytesOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows) {
|
|
|
108
154
|
return (yield* decodeRow(ReadyRow, row, "The ready shallow pack's row")).pack?.bytes ?? 0;
|
|
109
155
|
});
|
|
110
156
|
/**
|
|
157
|
+
* Whether a ready shallow pack can ever answer `request` before reading its row: one want, no
|
|
158
|
+
* haves or client shallows, an explicit shallow depth, no `deepen-relative`, and no filter.
|
|
159
|
+
*/
|
|
160
|
+
const readyEligible = (request) => request.haves.length === 0 && request.shallows.length === 0 && request.depth !== void 0 && request.deepenRelative !== true && request.filter === void 0 && new Set(request.wants).size === 1;
|
|
161
|
+
/**
|
|
111
162
|
* Whether a ready pack answers `input` exactly, as its plan would now: the one want its tip, no
|
|
112
163
|
* haves and no shallow commits, its depth, no `deepen-relative` and no filter, `include-tag`
|
|
113
164
|
* over the same tags, so a tag a rule hides from the caller never reaches them, and the same roots. The objects a tip
|
|
@@ -119,7 +170,7 @@ const answers = (ready, input) => {
|
|
|
119
170
|
if (pack === void 0) return false;
|
|
120
171
|
const tags = request.includeTag ? tagsDigest(input.tags ?? []) === ready.tags : pack.tagged === 0;
|
|
121
172
|
const roots = () => rootsDigest(input.roots ?? []) === ready.roots;
|
|
122
|
-
return
|
|
173
|
+
return readyEligible(request) && request.wants[0] === ready.tip && request.depth === ready.depth && tags && pack.objects <= limits.objects && pack.bytes <= limits.bytes && roots();
|
|
123
174
|
};
|
|
124
175
|
/**
|
|
125
176
|
* `bytes`, ended as a planned pack's stream is: when `signal` aborts, its reader gets the signal's
|
|
@@ -216,45 +267,54 @@ const untilEnded = /* @__PURE__ */ Effect.fnUntraced(function* (bytes, signal, l
|
|
|
216
267
|
return stream;
|
|
217
268
|
});
|
|
218
269
|
/**
|
|
219
|
-
* The ready pack that answers `input` exactly, and its stream from the bucket,
|
|
220
|
-
* one
|
|
270
|
+
* The ready pack that answers `input` exactly, and its stream from the bucket, as `opened`; or,
|
|
271
|
+
* when none does, the tip to ask one for, as `want`: a clone at `depth` of a tip no ready row
|
|
272
|
+
* names, with no ask waiting. Its one get is checked against `calls` before it's made.
|
|
221
273
|
*/
|
|
222
|
-
const readyOpened = /* @__PURE__ */ Effect.fnUntraced(function* (store, bucket, listed, input, calls) {
|
|
274
|
+
const readyOpened = /* @__PURE__ */ Effect.fnUntraced(function* (store, bucket, listed, input, depth, calls) {
|
|
223
275
|
const ready = yield* readOf(store, listed);
|
|
224
|
-
if (ready?.pack === void 0 || !answers(ready, input))
|
|
276
|
+
if (ready?.pack === void 0 || !answers(ready, input)) {
|
|
277
|
+
const [tip] = input.request.wants;
|
|
278
|
+
if (tip === void 0 || input.request.depth !== depth) return {};
|
|
279
|
+
if (ready?.tip === tip && ready.depth === depth && ready.roots === rootsDigest(input.roots ?? [])) return {};
|
|
280
|
+
return (yield* askWaits(store, listed)) ? {} : { want: tip };
|
|
281
|
+
}
|
|
225
282
|
const { id, objects, shallow } = ready.pack;
|
|
226
|
-
if (!isPackId(id)) return
|
|
283
|
+
if (!isPackId(id)) return {};
|
|
227
284
|
yield* callsAhead(calls, {
|
|
228
285
|
bucket: 1,
|
|
229
286
|
store: 0
|
|
230
287
|
}, input.request.haves.length === 0);
|
|
231
|
-
return {
|
|
288
|
+
return { opened: {
|
|
232
289
|
bytes: yield* bucketBody(bucket, packFiles(id).pack),
|
|
233
290
|
objects,
|
|
234
291
|
shallow
|
|
235
|
-
};
|
|
292
|
+
} };
|
|
236
293
|
});
|
|
237
294
|
/**
|
|
238
|
-
* The ready pack's answer to `input`, its bytes streamed from the bucket as they were written,
|
|
239
|
-
* `
|
|
240
|
-
*
|
|
241
|
-
*
|
|
295
|
+
* The ready pack's answer to `input`, its bytes streamed from the bucket as they were written, as
|
|
296
|
+
* `answer`; when it doesn't answer it exactly, and the fetch is planned, none, and with a clone at
|
|
297
|
+
* `depth`, the shallow pack's, the tip to ask one for, as `want`. Its bytes are read only as its
|
|
298
|
+
* reader pulls them, so bytes that are gone fail the stream. The fetch's one deadline, from
|
|
299
|
+
* `started`, holds the look-up and the stream, and the call's signal ends the stream, as each does
|
|
300
|
+
* a planned pack's. `calls` counts what the fetch made before.
|
|
242
301
|
*/
|
|
243
|
-
const
|
|
302
|
+
const readyLookup = /* @__PURE__ */ Effect.fnUntraced(function* (store, bucket, listed, input, started, depth, calls) {
|
|
303
|
+
if (!readyEligible(input.request)) return {};
|
|
244
304
|
const { limits } = input;
|
|
245
|
-
const opened = yield* readyOpened(store, bucket, listed, input, calls).pipe(Effect.timeoutOrElse({
|
|
305
|
+
const { opened, want } = yield* readyOpened(store, bucket, listed, input, depth, calls).pipe(Effect.timeoutOrElse({
|
|
246
306
|
duration: Math.max(0, yield* timeLeft(limits, started)),
|
|
247
307
|
orElse: () => Effect.fail(planTooSlow(limits))
|
|
248
308
|
}));
|
|
249
|
-
if (opened === void 0) return void 0;
|
|
309
|
+
if (opened === void 0) return want === void 0 ? {} : { want };
|
|
250
310
|
const left = yield* timeLeft(limits, started);
|
|
251
311
|
const pack = yield* untilEnded(opened.bytes, input.signal, left, limits);
|
|
252
|
-
return {
|
|
312
|
+
return { answer: {
|
|
253
313
|
shallow: opened.shallow,
|
|
254
314
|
unshallow: [],
|
|
255
315
|
objects: opened.objects,
|
|
256
316
|
pack
|
|
257
|
-
};
|
|
317
|
+
} };
|
|
258
318
|
});
|
|
259
319
|
const readyLimits = (shallow) => ({
|
|
260
320
|
objects: shallow.maxObjects,
|
|
@@ -345,19 +405,23 @@ const keepPack = /* @__PURE__ */ Effect.fnUntraced(function* (input, shallow, pl
|
|
|
345
405
|
/**
|
|
346
406
|
* `git.repack`'s step for the ready shallow pack, after clean-up's, as a change the core commits:
|
|
347
407
|
* - with the default branch's tip, its depth and its tags as the row says, nothing to do;
|
|
348
|
-
* - otherwise its pack is planned, and within its limits
|
|
349
|
-
* its `quarantine` row gone; past them, or at a tip
|
|
350
|
-
* put with no pack, so only a moved tip plans it
|
|
408
|
+
* - otherwise, with a clone's ask for that tip, its pack is planned, and within its limits
|
|
409
|
+
* written to the bucket and its row put, its `quarantine` row gone; past them, or at a tip
|
|
410
|
+
* naming an object the repo lacks, its row put with no pack, so only a moved tip plans it
|
|
411
|
+
* again;
|
|
412
|
+
* - without one, the row is deleted, its pack leaving, so a push no shallow clone follows costs
|
|
413
|
+
* no walk and no write, and the next clone that misses asks;
|
|
351
414
|
* - a pack the row named before leaves through a `leaving` row, so a clone still streaming it
|
|
352
415
|
* can finish, and clean-up ends its marker and bytes after: at prune's time, or a deleted
|
|
353
416
|
* repo's `leaveAt` when that's sooner;
|
|
354
417
|
* - with no tip, a deleted repo's or one whose default branch isn't there, or `shallow: false`,
|
|
355
|
-
* the row is deleted, its pack leaving
|
|
418
|
+
* the row is deleted, its pack leaving;
|
|
419
|
+
* - an ask is taken by whichever of these meets it, in the same change.
|
|
356
420
|
* `undefined` when there is nothing to do.
|
|
357
421
|
*/
|
|
358
422
|
const readyStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
359
423
|
const { shallow, tip, at, prune, leaveAt } = input;
|
|
360
|
-
const { ready, roots: rooted } = yield* readWithRoots(input.store, input.listed);
|
|
424
|
+
const { ready, roots: rooted, wanted } = yield* readWithRoots(input.store, input.listed);
|
|
361
425
|
const roots = [...rooted];
|
|
362
426
|
const tags = tagsDigest(input.tags);
|
|
363
427
|
const rootsAt = rootsDigest(roots);
|
|
@@ -370,22 +434,33 @@ const readyStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
370
434
|
...old,
|
|
371
435
|
id: old.id
|
|
372
436
|
}, due));
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
437
|
+
const asked = wanted === void 0 ? [] : [wantedKey];
|
|
438
|
+
const removed = () => {
|
|
439
|
+
if (ready === void 0 && wanted === void 0) return void 0;
|
|
440
|
+
const drops = [...ready === void 0 ? [] : [readyKey], ...asked];
|
|
441
|
+
const change = {
|
|
376
442
|
change: {
|
|
377
443
|
put,
|
|
378
|
-
delete:
|
|
444
|
+
delete: drops,
|
|
379
445
|
rows: noRows
|
|
380
446
|
},
|
|
381
447
|
more: false
|
|
382
448
|
};
|
|
383
|
-
return old === void 0 ?
|
|
384
|
-
...
|
|
449
|
+
return old === void 0 ? change : {
|
|
450
|
+
...change,
|
|
385
451
|
due
|
|
386
452
|
};
|
|
387
|
-
}
|
|
388
|
-
if (
|
|
453
|
+
};
|
|
454
|
+
if (shallow === false || tip === void 0) return removed();
|
|
455
|
+
if (ready?.tip === tip && ready.depth === shallow.depth && ready.tags === tags && ready.roots === rootsAt) return wanted === void 0 ? void 0 : {
|
|
456
|
+
change: {
|
|
457
|
+
put: [],
|
|
458
|
+
delete: asked,
|
|
459
|
+
rows: noRows
|
|
460
|
+
},
|
|
461
|
+
more: false
|
|
462
|
+
};
|
|
463
|
+
if (wanted?.tip !== tip) return removed();
|
|
389
464
|
const kept = yield* Effect.scoped(Effect.gen(function* () {
|
|
390
465
|
const build = {
|
|
391
466
|
...input,
|
|
@@ -403,6 +478,7 @@ const readyStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
403
478
|
tags,
|
|
404
479
|
roots: rootsAt
|
|
405
480
|
};
|
|
481
|
+
del.push(...asked);
|
|
406
482
|
if (kept !== void 0) {
|
|
407
483
|
value.pack = kept.pack;
|
|
408
484
|
del.push(kept.quarantine);
|
|
@@ -425,4 +501,4 @@ const readyStep = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
425
501
|
due
|
|
426
502
|
};
|
|
427
503
|
});
|
|
428
|
-
export { ReadyRow, defaultShallow,
|
|
504
|
+
export { ReadyRow, ReadyWanted, defaultShallow, readyAskMs, readyAskRoomMs, readyBytesMost, readyBytesOf, readyKey, readyLookup, readyRequest, readyShallowsMost, readyStep, tagsDigest, untilEnded, wantedKey, wantedRow };
|