@ref0/git 0.14.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/access-jwt.mjs +2 -2
- package/dist/auth/authorize.mjs +3 -3
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.mjs +4 -4
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/token-cleanup.mjs +67 -0
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/token-text.mjs +9 -1
- package/dist/auth/tokens-base.d.mts +35 -0
- package/dist/auth/tokens-base.mjs +13 -0
- package/dist/auth/tokens-layer.d.mts +2 -27
- package/dist/auth/tokens-layer.mjs +6 -11
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -10
- package/dist/auth/tokens.mjs +9 -80
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +17 -7
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +9 -8
- package/dist/client/remote.mjs +8 -10
- package/dist/client/run-remote-helper.d.mts +1 -0
- package/dist/client/run-remote-helper.mjs +58 -24
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +105 -46
- package/dist/contracts/blobs.d.mts +55 -8
- package/dist/contracts/blobs.mjs +16 -2
- package/dist/contracts/call-allowance.d.mts +13 -0
- package/dist/contracts/call-allowance.mjs +44 -0
- package/dist/contracts/calls-spent.mjs +8 -3
- package/dist/contracts/client.d.mts +15 -16
- package/dist/contracts/commits.d.mts +24 -24
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +10 -10
- package/dist/contracts/forks.d.mts +17 -17
- package/dist/contracts/git-events.d.mts +29 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +21 -0
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -2
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +23 -25
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +26 -23
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +4 -1
- package/dist/contracts/repos.d.mts +29 -138
- package/dist/contracts/repos.mjs +5 -3
- package/dist/contracts/result.d.mts +35 -16
- package/dist/contracts/result.mjs +35 -7
- package/dist/contracts/server.d.mts +25 -50
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +11 -7
- package/dist/contracts/sync.mjs +12 -2
- package/dist/contracts/tags.d.mts +10 -10
- package/dist/contracts/time.d.mts +3 -0
- package/dist/contracts/{promises.mjs → time.mjs} +1 -1
- package/dist/contracts/tokens.d.mts +15 -17
- package/dist/contracts/tokens.mjs +3 -2
- package/dist/contracts/topics.d.mts +1 -1
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +24 -13
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +20 -9
- package/dist/core/ancestry.d.mts +1 -0
- package/dist/core/asked.mjs +1 -1
- package/dist/core/call-names.mjs +6 -1
- package/dist/core/call-services.mjs +11 -3
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +43 -36
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +928 -432
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +29 -23
- package/dist/core/index-job.mjs +122 -34
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/lines.mjs +2 -2
- package/dist/core/objects/merges.mjs +4 -1
- package/dist/core/objects/objects-layer.d.mts +1 -1
- package/dist/core/objects/objects-layer.mjs +3 -3
- package/dist/core/objects/reading.mjs +24 -13
- package/dist/core/objects/tags.mjs +4 -1
- package/dist/core/objects/trees.mjs +2 -2
- package/dist/core/objects/writing.mjs +2 -2
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +4 -5
- package/dist/core/parts.mjs +3 -8
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +287 -83
- package/dist/core/push-decide.mjs +2 -0
- package/dist/core/push-files.d.mts +1 -1
- package/dist/core/push.mjs +58 -47
- package/dist/core/receipts.mjs +8 -3
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +2 -2
- package/dist/core/refs.mjs +5 -5
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +36 -21
- package/dist/core/repo-info.mjs +3 -3
- package/dist/core/repos.mjs +21 -9
- package/dist/core/rules/commit-changes.d.mts +0 -1
- package/dist/core/saved-caller-views.d.mts +7 -2
- package/dist/core/saved-caller-views.mjs +2 -2
- package/dist/core/saved-callers.d.mts +19 -2
- package/dist/core/seam.d.mts +16 -26
- package/dist/core/seam.mjs +7 -28
- package/dist/core/tokens.mjs +1 -1
- package/dist/core/view.mjs +7 -15
- package/dist/core/work.mjs +59 -14
- package/dist/effect.d.mts +3 -12
- package/dist/effect.mjs +1 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +4 -4
- package/dist/event-streams/stream.d.mts +2 -2
- package/dist/event-streams/stream.mjs +37 -14
- package/dist/extend.d.mts +2 -3
- package/dist/extend.mjs +2 -1
- package/dist/http/answers.mjs +8 -5
- package/dist/http/core-parts.mjs +95 -79
- package/dist/http/handler.mjs +34 -7
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +56 -27
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +30 -26
- package/dist/http/push-uploads.mjs +36 -21
- package/dist/http/upload-pack.mjs +3 -3
- package/dist/index.d.mts +14 -14
- package/dist/index.mjs +2 -2
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +2 -0
- package/dist/lfs/base.mjs +25 -1
- package/dist/lfs/copy.d.mts +21 -7
- package/dist/lfs/copy.mjs +89 -6
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +24 -11
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +1 -0
- package/dist/lfs/objects.mjs +87 -17
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/streams.mjs +27 -1
- package/dist/protocol/diff/read.d.mts +4 -3
- package/dist/protocol/diff/read.mjs +8 -3
- package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
- package/dist/protocol/objects/lfs-pointer.mjs +1 -3
- package/dist/protocol/objects/links-raw.mjs +24 -10
- package/dist/protocol/objects/tag.d.mts +1 -1
- package/dist/protocol/objects/tree.mjs +23 -6
- package/dist/protocol/packs/delta.d.mts +6 -3
- package/dist/protocol/packs/delta.mjs +96 -32
- package/dist/protocol/packs/idx.d.mts +2 -1
- package/dist/protocol/packs/idx.mjs +22 -3
- package/dist/protocol/packs/parts.d.mts +4 -1
- package/dist/protocol/packs/parts.mjs +10 -7
- package/dist/protocol/packs/reader.d.mts +5 -0
- package/dist/protocol/packs/reader.mjs +3 -2
- package/dist/protocol/packs/writer.mjs +26 -8
- package/dist/queue/advance.mjs +21 -24
- package/dist/queue/base.d.mts +55 -0
- package/dist/queue/base.mjs +44 -0
- package/dist/queue/calls.mjs +51 -54
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +1 -15
- package/dist/queue/host.mjs +2 -7
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +10 -3
- package/dist/queue/limits.mjs +2 -0
- package/dist/queue/push-option.mjs +9 -24
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/state.mjs +2 -10
- package/dist/queue/trim.mjs +5 -3
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4271
- package/dist/rest/caller.mjs +4 -0
- package/dist/rest/client.d.mts +8 -5
- package/dist/rest/client.mjs +19 -2
- package/dist/rest/handlers.mjs +50 -5
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +5 -12
- package/dist/rest/me.d.mts +3 -432
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +11 -8
- package/dist/server/edge-node.mjs +9 -6
- package/dist/server/edge.d.mts +21 -7
- package/dist/server/edge.mjs +32 -11
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +5 -5
- package/dist/server/git-layer.mjs +28 -22
- package/dist/server/git-namespace.d.mts +4 -3
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +6 -18
- package/dist/server/joined.mjs +9 -36
- package/dist/server/lifecycle.mjs +18 -106
- package/dist/server/registry.mjs +24 -7
- package/dist/server/server.mjs +205 -346
- package/dist/signin/context.d.mts +1 -2
- package/dist/signin/layer.d.mts +1 -1
- package/dist/signin/layer.mjs +1 -1
- package/dist/storage/allotted.mjs +18 -3
- package/dist/storage/batch-upkeep.mjs +274 -0
- package/dist/storage/batches.d.mts +8 -0
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/calls.d.mts +1 -2
- package/dist/storage/calls.mjs +144 -158
- package/dist/storage/chunks.d.mts +9 -0
- package/dist/storage/chunks.mjs +297 -0
- package/dist/storage/clean-up.mjs +72 -9
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +287 -210
- package/dist/storage/host-bucket.mjs +1 -2
- package/dist/storage/id-mix.mjs +19 -5
- package/dist/storage/index-bitmaps.mjs +9 -2
- package/dist/storage/index-build.d.mts +0 -1
- package/dist/storage/index-build.mjs +80 -23
- package/dist/storage/index-fetch.mjs +113 -72
- package/dist/storage/index-files.d.mts +3 -0
- package/dist/storage/index-files.mjs +10 -5
- package/dist/storage/index-graph.mjs +72 -22
- package/dist/storage/index-remap.mjs +200 -64
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +1 -1
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +212 -67
- package/dist/storage/memory-budget.mjs +16 -4
- package/dist/storage/merge-plan.mjs +3 -2
- package/dist/storage/merge-row.mjs +7 -1
- package/dist/storage/merge-stream.mjs +164 -25
- package/dist/storage/merge-walk.mjs +8 -4
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +1 -0
- package/dist/storage/object-rows.mjs +385 -65
- package/dist/storage/oid-table.mjs +171 -0
- package/dist/storage/pack-order.mjs +8 -4
- package/dist/storage/pack-ranges.d.mts +1 -2
- package/dist/storage/pack-ranges.mjs +4 -5
- package/dist/storage/pack-reads.d.mts +2 -1
- package/dist/storage/pack-reads.mjs +158 -42
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +2 -2
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +136 -66
- package/dist/storage/placed-reads.mjs +1 -1
- package/dist/storage/plan-columns.d.mts +4 -0
- package/dist/storage/plan-columns.mjs +238 -0
- package/dist/storage/prune-keep.mjs +134 -41
- package/dist/storage/prune-walk.mjs +202 -62
- package/dist/storage/prune.mjs +194 -91
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +4 -4
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +8 -6
- package/dist/storage/receive-bounds.mjs +23 -8
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.mjs +195 -43
- package/dist/storage/send-list.d.mts +1 -0
- package/dist/storage/send-list.mjs +54 -10
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +127 -26
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +2 -2
- package/dist/storage/walk.mjs +192 -38
- package/dist/storage/wants.mjs +5 -5
- package/dist/store/bodies.mjs +38 -0
- package/dist/store/call-count.d.mts +8 -12
- package/dist/store/call-count.mjs +34 -46
- package/dist/store/catalogue.d.mts +2 -2
- package/dist/store/catalogue.mjs +145 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal.d.mts +1 -2
- package/dist/store/cursor-seal.mjs +16 -6
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +15 -33
- package/dist/store/git-store.mjs +25 -7
- package/dist/store/job-try.mjs +9 -32
- package/dist/store/list-job.mjs +44 -8
- package/dist/store/records.d.mts +3 -0
- package/dist/store/records.mjs +3 -0
- package/dist/store/repo-record.d.mts +1 -2
- package/dist/store/repo-record.mjs +32 -20
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +11 -0
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/github.mjs +3 -3
- package/dist/sync/import.mjs +31 -18
- package/dist/sync/lfs-batch.mjs +4 -5
- package/dist/sync/lfs-copy.mjs +17 -6
- package/dist/sync/mirror.mjs +34 -31
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/step.mjs +33 -25
- package/dist/sync/tries.mjs +9 -9
- package/dist/topics/advance.mjs +10 -11
- package/dist/topics/base.d.mts +15 -0
- package/dist/topics/base.mjs +8 -0
- package/dist/topics/host.mjs +1 -1
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +2 -3
- package/dist/topics/members.mjs +4 -4
- package/dist/topics/public.d.mts +2 -1
- package/dist/topics/topic.mjs +2 -2
- package/package.json +5 -4
- package/dist/contracts/promises.d.mts +0 -39
- package/dist/core/call-names.d.mts +0 -3
- package/dist/core/clock.mjs +0 -18
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -833
- package/dist/rest/commits.d.mts +0 -3543
- package/dist/rest/errors.d.mts +0 -2124
- package/dist/rest/events.d.mts +0 -426
- package/dist/rest/files.d.mts +0 -1342
- package/dist/rest/forks.d.mts +0 -2160
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -477
- package/dist/rest/queue.d.mts +0 -5917
- package/dist/rest/refs.d.mts +0 -2988
- package/dist/rest/repos.d.mts +0 -2567
- package/dist/rest/tags.d.mts +0 -1316
- package/dist/rest/tokens.d.mts +0 -2614
- package/dist/rest/topics.d.mts +0 -2224
- package/dist/rest/trees.d.mts +0 -1709
- package/dist/rest/work.d.mts +0 -1695
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
|
@@ -3,7 +3,6 @@ import { isServerClosed } from "../store/closed.mjs";
|
|
|
3
3
|
import { bucketFailed } from "./calls.mjs";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import { Unavailable } from "@ref0/infra";
|
|
6
|
-
import * as Stream from "effect/Stream";
|
|
7
6
|
// src/storage/host-bucket.ts
|
|
8
7
|
/**
|
|
9
8
|
* A host bucket's own defect as `Unavailable`, which `bucketDo` answers `UNAVAILABLE`, "The bucket
|
|
@@ -20,7 +19,7 @@ const hostFailure = (cause) => isServerClosed(cause) || spentAt(cause) !== void
|
|
|
20
19
|
const hostFailures = (bucket) => ({
|
|
21
20
|
...bucket,
|
|
22
21
|
put: (key, body, options) => Effect.catchDefect(bucket.put(key, body, options), hostFailure),
|
|
23
|
-
read: (key, range) =>
|
|
22
|
+
read: (key, range) => Effect.catchDefect(bucket.read(key, range), hostFailure),
|
|
24
23
|
remove: (key) => Effect.catchDefect(bucket.remove(key), hostFailure),
|
|
25
24
|
removeMany: (keys, options) => Effect.catchDefect(bucket.removeMany(keys, options), hostFailure),
|
|
26
25
|
list: (prefix, page) => Effect.catchDefect(bucket.list(prefix, page), hostFailure)
|
package/dist/storage/id-mix.mjs
CHANGED
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
* together: the receive's records table finds the pack's objects by it.
|
|
5
5
|
*/
|
|
6
6
|
const oidBytes = 20;
|
|
7
|
-
/**
|
|
8
|
-
const
|
|
7
|
+
/** Each character code's value as a lowercase hex digit, or -1 for any other. */
|
|
8
|
+
const digits = (() => {
|
|
9
|
+
const values = (/* @__PURE__ */ new Int8Array(128)).fill(-1);
|
|
10
|
+
for (let at = 0; at < 16; at += 1) values["0123456789abcdef".charCodeAt(at)] = at;
|
|
11
|
+
return values;
|
|
12
|
+
})();
|
|
9
13
|
/**
|
|
10
14
|
* A mix's draw from `crypto.getRandomValues`, each multiplier made odd, so a pusher can't choose
|
|
11
15
|
* IDs against a draw it knows.
|
|
@@ -18,11 +22,21 @@ const drawnMix = () => {
|
|
|
18
22
|
1 + (drawn[2] ?? 0) % 31
|
|
19
23
|
];
|
|
20
24
|
};
|
|
21
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* `oid`'s 20 bytes into `key`, or `false` when it isn't 40 lowercase hex digits, as `hexOf` writes
|
|
27
|
+
* them: a digit that isn't one sets the sign bit of `checked`, so the check takes no pass of its
|
|
28
|
+
* own.
|
|
29
|
+
*/
|
|
22
30
|
const keyed = (oid, key) => {
|
|
23
31
|
if (oid.length !== 40) return false;
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
let checked = 0;
|
|
33
|
+
for (let at = 0; at < oidBytes; at += 1) {
|
|
34
|
+
const high = digits[oid.charCodeAt(2 * at)] ?? -1;
|
|
35
|
+
const low = digits[oid.charCodeAt(2 * at + 1)] ?? -1;
|
|
36
|
+
checked |= high | low;
|
|
37
|
+
key[at] = high << 4 | low;
|
|
38
|
+
}
|
|
39
|
+
return checked >= 0;
|
|
26
40
|
};
|
|
27
41
|
/**
|
|
28
42
|
* Murmur3's last mix of 32 bits, one to one: each bit in moves about half of the bits out, so IDs
|
|
@@ -39,6 +39,13 @@ const lost = (message) => gitError("DATA_LOSS", message);
|
|
|
39
39
|
const mergeIncomplete = (message) => gitError("DATA_LOSS", message, { context: { reason: "merge-incomplete" } });
|
|
40
40
|
/** Whether `error` is `mergeIncomplete`'s. */
|
|
41
41
|
const isMergeIncomplete = (error) => error.code === "DATA_LOSS" && error.context?.reason === "merge-incomplete";
|
|
42
|
+
/**
|
|
43
|
+
* A prune merge's keep that the index's reach says isn't closed (#2196): a kept commit's bitmap
|
|
44
|
+
* sets, or its graph row names, an object the merge dropped. A remap over it declines.
|
|
45
|
+
*/
|
|
46
|
+
const keepUnclosed = (message) => gitError("FAILED_PRECONDITION", message, { context: { reason: "keep-unclosed" } });
|
|
47
|
+
/** Whether `error` is `keepUnclosed`'s. */
|
|
48
|
+
const isKeepUnclosed = (error) => error.code === "FAILED_PRECONDITION" && error.context?.reason === "keep-unclosed";
|
|
42
49
|
/** A bitmap whose commit its copy's move gives no position. */
|
|
43
50
|
const moved = (position) => mergeIncomplete(`The bitmap at ${position} has no position where it's copied to`);
|
|
44
51
|
const edgesMagic = [
|
|
@@ -594,7 +601,7 @@ const copyBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
594
601
|
if (position === void 0) return Effect.fail(moved(entry.position));
|
|
595
602
|
all.fill(0);
|
|
596
603
|
if (move === void 0) all.set(bits.subarray(0, words));
|
|
597
|
-
else move.bits(bits, all);
|
|
604
|
+
else if (!move.bits(bits, all)) return Effect.fail(keepUnclosed(`The bitmap at ${entry.position} sets an object the merge dropped`));
|
|
598
605
|
return put.add(position, numbers.get(entry.position) ?? 4294967295, ewahOf(all));
|
|
599
606
|
});
|
|
600
607
|
}
|
|
@@ -789,4 +796,4 @@ const storedBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key,
|
|
|
789
796
|
bytes: size
|
|
790
797
|
};
|
|
791
798
|
});
|
|
792
|
-
export { BitmapsPart, EdgeFiles, bitmapOrder, bitmapsMostBytes, bitmapsPut, copyBitmaps, copyHeldBytes, copyRunBytes, eachBitmapBytes, edgesBytesOf, edgesFileOf, ewahMostWords, isMergeIncomplete, mergeIncomplete, noBase, noNumber, openBitmaps, orderKey, partBitmaps, partBytesMost, runGapBytes, runsMost, storedBitmaps, storedSize, walkBytes, writeBitmaps };
|
|
799
|
+
export { BitmapsPart, EdgeFiles, bitmapOrder, bitmapsMostBytes, bitmapsPut, copyBitmaps, copyHeldBytes, copyRunBytes, eachBitmapBytes, edgesBytesOf, edgesFileOf, ewahMostWords, isKeepUnclosed, isMergeIncomplete, keepUnclosed, mergeIncomplete, noBase, noNumber, openBitmaps, orderKey, partBitmaps, partBytesMost, runGapBytes, runsMost, storedBitmaps, storedSize, walkBytes, writeBitmaps };
|
|
@@ -10,11 +10,11 @@ import { rawLinks } from "../protocol/objects/links-raw.mjs";
|
|
|
10
10
|
import { rootsDigest } from "../store/repo-record.mjs";
|
|
11
11
|
import { randomText } from "../store/random.mjs";
|
|
12
12
|
import { allottableOf, uploadPartBytes } from "./budget.mjs";
|
|
13
|
-
import { bucketDo, bucketPut, joined, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
|
|
13
|
+
import { bucketDo, bucketPut, joined, readEach, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
|
|
14
14
|
import { BitmapsPart, EdgeFiles, bitmapOrder, bitmapsMostBytes, bitmapsPut, copyBitmaps, copyHeldBytes, copyRunBytes, edgesBytesOf, edgesFileOf, ewahMostWords, noNumber, orderKey, partBitmaps, partBytesMost, runsMost, storedBitmaps, storedSize, writeBitmaps } from "./index-bitmaps.mjs";
|
|
15
15
|
import { BasesWriter, TypesWriter, indexBasesBytes, indexTypesBytes, openBases, openTypes, typeCodes } from "./index-files.mjs";
|
|
16
16
|
import { bitmapOf, bitmapWords, ewahOf, orEwah } from "./ewah.mjs";
|
|
17
|
-
import { graphChunk, indexGraphBytes, mergeHeldBytes, mergeIndexGraphs, openGraphLayers, openIndexGraph, writeIndexGraph } from "./index-graph.mjs";
|
|
17
|
+
import { absent, graphChunk, indexGraphBytes, keptIdsBytes, keptIdsOf, mergeHeldBytes, mergeIndexGraphs, openGraphLayers, openIndexGraph, writeIndexGraph } from "./index-graph.mjs";
|
|
18
18
|
import { hasBit, idsOf, lookupCalls, openLayerBitmaps, openLayout, orIntoBytes, reachOf } from "./index-layers.mjs";
|
|
19
19
|
import { indexFiles, indexPrefix, indexRowKey, isPackId, packFiles } from "./layout.mjs";
|
|
20
20
|
import { listedIds } from "./listed-ids.mjs";
|
|
@@ -25,14 +25,13 @@ import { eachPageAt, objectOfRow } from "./object-rows.mjs";
|
|
|
25
25
|
import { SliceLinks, SliceRefused, cutAtSpent, isSliceRefused, linksPastMemory, nothingSettled, readSlice, slicePackOf, sliceRefusal, spentOf } from "./pack-order.mjs";
|
|
26
26
|
import { PackBlocks, blocksHeld, packIndexerLimits } from "./pack-reads.mjs";
|
|
27
27
|
import { rangeRanks, readExactly } from "./pack-ranges.mjs";
|
|
28
|
-
import { rangeCached } from "./range-cache.mjs";
|
|
28
|
+
import { rangeCached, wholeCached } from "./range-cache.mjs";
|
|
29
29
|
import { compareIds } from "./raw-ids.mjs";
|
|
30
30
|
import * as Effect from "effect/Effect";
|
|
31
31
|
import * as Option from "effect/Option";
|
|
32
32
|
import * as Schema from "effect/Schema";
|
|
33
33
|
import * as Cause from "effect/Cause";
|
|
34
34
|
import * as Result from "effect/Result";
|
|
35
|
-
import * as Stream from "effect/Stream";
|
|
36
35
|
// src/storage/index-build.ts
|
|
37
36
|
/**
|
|
38
37
|
* The reachability index's first build, `git.index`'s steps, one a try: the region's rows read,
|
|
@@ -349,7 +348,7 @@ const wordsOf = (bytes) => {
|
|
|
349
348
|
*/
|
|
350
349
|
const keptReaches = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, words, allotment) {
|
|
351
350
|
const chunks = [];
|
|
352
|
-
yield* bucketDo(
|
|
351
|
+
yield* bucketDo(readEach(bucket, key, void 0, (chunk) => {
|
|
353
352
|
chunks.push(chunk);
|
|
354
353
|
return allotment.grow(chunk.byteLength);
|
|
355
354
|
}));
|
|
@@ -744,17 +743,20 @@ const rootsIn = (parts) => parts.roots ?? noRepoRoots;
|
|
|
744
743
|
* and a commit's entry and its ID as text, rounded up.
|
|
745
744
|
*/
|
|
746
745
|
const regionRowBytes = 256;
|
|
747
|
-
/** Each of `layers`' graphs, opened at its first graph number. */
|
|
748
|
-
const belowGraphs = (bucket, repo, layers) => Effect.forEach(layers, (layer) => openIndexGraph(bucket, indexFiles(repo, layer.build).graph, layer.graphFirst));
|
|
746
|
+
/** Each of `layers`' graphs, opened at its first graph number, its IDs kept in `kept`'s when given. */
|
|
747
|
+
const belowGraphs = (bucket, repo, layers, kept) => Effect.forEach(layers, (layer, at) => openIndexGraph(bucket, indexFiles(repo, layer.build).graph, layer.graphFirst, { kept: kept?.[at] }));
|
|
749
748
|
/** The graph step: every pack's `.graph` and the region's, merged. */
|
|
750
749
|
const graphStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, data, allotment) {
|
|
751
750
|
const files = indexFiles(listed.repo, data.build);
|
|
752
751
|
const graphs = data.packs.map((id) => isPackId(id) ? packFiles(id).graph : id);
|
|
753
752
|
if (data.rows > 0) graphs.push(files.regionGraph);
|
|
753
|
+
const sizes = graphSizesOf(listed, data);
|
|
754
|
+
const cached = yield* roomy(allotment, [...sizes.values()].reduce((total, size) => total + size + 320, 0), () => wholeCached(parts.bucket, sizes), (whole) => whole.clear());
|
|
755
|
+
const kept = yield* roomy(allotment, data.below.reduce((total, layer) => total + keptIdsBytes(layer.commits), 0), () => data.below.map(() => keptIdsOf()), (all) => all.forEach((ids) => ids.drop()));
|
|
754
756
|
const graphFirst = graphFirstOf(data.below);
|
|
755
|
-
const below = data.below.length === 0 ? void 0 : openGraphLayers(yield* belowGraphs(parts.bucket, listed.repo, data.below)).below(data.below.length);
|
|
757
|
+
const below = data.below.length === 0 ? void 0 : openGraphLayers(yield* belowGraphs(parts.bucket, listed.repo, data.below, kept)).below(data.below.length);
|
|
756
758
|
const graphInput = {
|
|
757
|
-
bucket: parts.bucket,
|
|
759
|
+
bucket: cached?.bucket ?? parts.bucket,
|
|
758
760
|
graphs,
|
|
759
761
|
key: files.graph,
|
|
760
762
|
allotment,
|
|
@@ -773,7 +775,15 @@ const graphStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, da
|
|
|
773
775
|
commits: written.commits,
|
|
774
776
|
step
|
|
775
777
|
};
|
|
776
|
-
});
|
|
778
|
+
}, Effect.scoped);
|
|
779
|
+
/**
|
|
780
|
+
* Each listed pack's `.graph` the step merges, by key, at the size its row records: a region's
|
|
781
|
+
* isn't listed, so it streams each pass.
|
|
782
|
+
*/
|
|
783
|
+
const graphSizesOf = (listed, data) => {
|
|
784
|
+
const merged = new Set(data.packs);
|
|
785
|
+
return new Map(listed.packs.flatMap(({ id, graphBytes }) => merged.has(id) && isPackId(id) && graphBytes > 0 ? [[packFiles(id).graph, graphBytes]] : []));
|
|
786
|
+
};
|
|
777
787
|
/**
|
|
778
788
|
* The type codes `slices` stored at positions of the pack whose order starts at repo position
|
|
779
789
|
* `base`: for each slice that holds any, one ranged read of its `.types` part, from the first it
|
|
@@ -838,7 +848,8 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, dat
|
|
|
838
848
|
offset: data.offset,
|
|
839
849
|
position: data.position
|
|
840
850
|
};
|
|
841
|
-
const
|
|
851
|
+
const joins = yield* roomyJoins(bucket, listed, data, allotment);
|
|
852
|
+
const opened = yield* Effect.result(cutAtSpent(joins === void 0 ? layoutOf(bucket, listed, data) : layoutOf(joins.bucket, listed, data, { cached: true })));
|
|
842
853
|
if (Result.isFailure(opened)) {
|
|
843
854
|
const spent = spentOf(opened.failure);
|
|
844
855
|
if (spent === void 0) return yield* Effect.fail(opened.failure);
|
|
@@ -1135,28 +1146,66 @@ const bitmapsJoinMost = 25165824;
|
|
|
1135
1146
|
* `bitmapsJoinMost`. It's what a join can read, from the counts alone, never what a try did.
|
|
1136
1147
|
*/
|
|
1137
1148
|
const bitmapsJoinHeld = (objects) => Math.min(bitmapsJoinMost, objects.reduce((sum, count) => sum + count * 24 + Math.ceil(count / rangeRanks) * 2 * 320, 0));
|
|
1149
|
+
/** What a step keeps of its layout's join ranges, `bitmapsJoinHeld` over the packs `data` covers. */
|
|
1150
|
+
const joinsHeldOf = (listed, data) => {
|
|
1151
|
+
const covered = new Set([...data.below, spanOf(data)].flatMap((layer) => layer.groups.flatMap((group) => group.packs)));
|
|
1152
|
+
return bitmapsJoinHeld(listed.packs.filter(({ id }) => covered.has(id)).map((pack) => pack.objects));
|
|
1153
|
+
};
|
|
1138
1154
|
/**
|
|
1139
1155
|
* The step's kept join ranges over `bucket`, charged at `bitmapsJoinHeld` before any read and let
|
|
1140
1156
|
* go as its scope ends, however the step ends: each walk below's batch joins every covered pack's
|
|
1141
1157
|
* ranges, which are read once a step this way, not once a batch.
|
|
1142
1158
|
*/
|
|
1143
1159
|
const keptJoins = (bucket, listed, data, allotment) => {
|
|
1144
|
-
const
|
|
1145
|
-
const held = bitmapsJoinHeld(listed.packs.filter(({ id }) => covered.has(id)).map((pack) => pack.objects));
|
|
1160
|
+
const held = joinsHeldOf(listed, data);
|
|
1146
1161
|
return Effect.acquireRelease(Effect.map(allotment.grow(held), () => rangeCached(bucket, held, { evict: false })), (ranges) => Effect.sync(() => {
|
|
1147
1162
|
ranges.clear();
|
|
1148
1163
|
allotment.shrink(held);
|
|
1149
1164
|
}));
|
|
1150
1165
|
};
|
|
1166
|
+
/**
|
|
1167
|
+
* What `make` makes, in a room of `allotment` that has `held` at once: none with no room at once,
|
|
1168
|
+
* and `drop`ped when the budget shrinks the room, the step's own grow or another's, or as the
|
|
1169
|
+
* scope ends. Its maker reads again what it would have kept: never a wait or a refusal (#2518).
|
|
1170
|
+
* `drop` lets go at once of all it holds, reads under way included, as the room's charge goes back.
|
|
1171
|
+
*/
|
|
1172
|
+
const roomy = (allotment, held, make, drop) => {
|
|
1173
|
+
const room = allotment.room(0, held);
|
|
1174
|
+
return Effect.acquireRelease(Effect.sync(() => {
|
|
1175
|
+
if (!room.grow(held)) return void 0;
|
|
1176
|
+
const made = make();
|
|
1177
|
+
room.watch((left) => {
|
|
1178
|
+
if (left < held) drop(made);
|
|
1179
|
+
});
|
|
1180
|
+
return made;
|
|
1181
|
+
}), (made) => Effect.sync(() => {
|
|
1182
|
+
if (made !== void 0) drop(made);
|
|
1183
|
+
allotment.endRoom(room);
|
|
1184
|
+
}));
|
|
1185
|
+
};
|
|
1186
|
+
/**
|
|
1187
|
+
* The step's join ranges kept as `keptJoins` keeps them, in a room, so the layout a step opens and
|
|
1188
|
+
* the join that reads it again read each range once a step (#2518).
|
|
1189
|
+
*/
|
|
1190
|
+
const roomyJoins = (bucket, listed, data, allotment) => {
|
|
1191
|
+
const held = joinsHeldOf(listed, data);
|
|
1192
|
+
return roomy(allotment, held, () => rangeCached(bucket, held, { evict: false }), (ranges) => ranges.clear());
|
|
1193
|
+
};
|
|
1194
|
+
/**
|
|
1195
|
+
* A first build's tips' numbers and then the numbers' IDs read the same chunk of the graph's IDs:
|
|
1196
|
+
* kept in a room of `keptIdsBytes`, so it's read once a step (#2518).
|
|
1197
|
+
*/
|
|
1198
|
+
const roomyIds = (data, allotment) => roomy(allotment, keptIdsBytes(data.commits), keptIdsOf, (kept) => kept.drop());
|
|
1151
1199
|
/** `bitmapsStep`'s reads and writes, through `lower` when given, each walk below in `walks`. */
|
|
1152
1200
|
const bitmapsWritten = /* @__PURE__ */ Effect.fnUntraced(function* (parts, lower, listed, data, input, allotment, walks) {
|
|
1153
1201
|
const bucket = lower?.bucket ?? parts.bucket;
|
|
1154
1202
|
const files = indexFiles(listed.repo, data.build);
|
|
1155
|
-
const joins = data.below.length === 0 ?
|
|
1203
|
+
const joins = data.below.length === 0 ? yield* roomyJoins(bucket, listed, data, allotment) : yield* keptJoins(bucket, listed, data, allotment);
|
|
1156
1204
|
const { layout, first } = joins === void 0 ? yield* layoutOf(bucket, listed, data) : yield* layoutOf(joins.bucket, listed, data, { cached: true });
|
|
1157
1205
|
const { positions } = layout;
|
|
1158
1206
|
const graphFirst = graphFirstOf(data.below);
|
|
1159
|
-
const
|
|
1207
|
+
const kept = data.below.length === 0 ? yield* roomyIds(data, allotment) : void 0;
|
|
1208
|
+
const own = yield* openIndexGraph(bucket, files.graph, graphFirst, { kept });
|
|
1160
1209
|
const graph = openGraphLayers([...yield* belowGraphs(bucket, listed.repo, data.below), own]);
|
|
1161
1210
|
yield* allotment.grow(own.commits * 12);
|
|
1162
1211
|
const rows = yield* own.rows;
|
|
@@ -1546,20 +1595,28 @@ const liveBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (layout, stored,
|
|
|
1546
1595
|
yield* stored.orInto(bitmapped, live);
|
|
1547
1596
|
return stored.entries.filter(({ entry }) => hasBit(live, entry.position));
|
|
1548
1597
|
});
|
|
1598
|
+
/** `numbered`'s bitmaps' numbers in the merged graph at `key`, read by their IDs in `graphs`. */
|
|
1599
|
+
const numbersIn = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, graphs, numbered) {
|
|
1600
|
+
const merged = yield* openIndexGraph(bucket, key);
|
|
1601
|
+
const ids = yield* openGraphLayers(graphs).idsAt(numbered.map(({ entry }) => entry.number));
|
|
1602
|
+
return yield* merged.numbersOf(ids, numbered.length);
|
|
1603
|
+
});
|
|
1549
1604
|
/**
|
|
1550
1605
|
* `kept`'s bitmaps copied to `files.bitmaps` over `positions`, each numbered again by the merged
|
|
1551
|
-
* graph at `files.graph`, which `graphs` were merged into
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1606
|
+
* graph at `files.graph`, which `graphs` were merged into, or by `renumbered`, the merge's own
|
|
1607
|
+
* numbering, while that file isn't finished: its bits and its position as `move` moves them, or
|
|
1608
|
+
* where they were. A file a try that died already put is kept. Its caller charges the bitmaps'
|
|
1609
|
+
* entries, `mergeEntryBytes` each; the copy charges its own.
|
|
1554
1610
|
*/
|
|
1555
1611
|
const copyMergedBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
1556
|
-
const { bucket, files, positions, kept } = input;
|
|
1612
|
+
const { bucket, files, positions, kept, renumbered } = input;
|
|
1557
1613
|
const stored = yield* storedSize(bucket, files.bitmaps);
|
|
1558
1614
|
if (stored !== void 0) return yield* storedBitmaps(bucket, files.bitmaps, positions, stored);
|
|
1559
1615
|
const numbered = kept.filter(({ entry }) => entry.number !== noNumber);
|
|
1560
|
-
const
|
|
1561
|
-
|
|
1562
|
-
|
|
1616
|
+
const numbers = renumbered === void 0 ? yield* numbersIn(bucket, files.graph, input.graphs, numbered) : numbered.map(({ entry }) => {
|
|
1617
|
+
const number = renumbered(entry.number);
|
|
1618
|
+
return number === 2147483647 ? absent : number;
|
|
1619
|
+
});
|
|
1563
1620
|
const copied = [];
|
|
1564
1621
|
let place = 0;
|
|
1565
1622
|
for (const { from, entry } of kept) {
|
|
@@ -2110,4 +2167,4 @@ const indexTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, limits, lis
|
|
|
2110
2167
|
data: ended.data
|
|
2111
2168
|
};
|
|
2112
2169
|
});
|
|
2113
|
-
export { BitmapsCut, BuiltIndex, IndexBounds, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, bitmapsJoinHeld, bitmapsJoinMost, boundsOf, builtIndexOf, builtOver, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, denseBelow, denseBelowReads, edgesMost, entriesHeld, floors, graphMostOf, indexBitmapsCallsAfter, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, limitsOf, lostIndexRow, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, reachesBytes, reachesOf, readFurther, rootsKeyOf, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };
|
|
2170
|
+
export { BitmapsCut, BuiltIndex, IndexBounds, IndexData, IndexGroup, IndexLayer, IndexRefusal, IndexRow, IndexSlice, IndexTries, Narrowed, RefusedIndex, ReplacedBuild, belowGraphs, bitmapsJoinHeld, bitmapsJoinMost, boundsOf, builtIndexOf, builtOver, chooseCommits, copyMergedBitmaps, coveredPacks, coversAll, decodeIndexValue, denseBelow, denseBelowReads, edgesMost, entriesHeld, floors, graphMostOf, indexBitmapsCallsAfter, indexReadCallsAfter, indexRowOf, indexSaves, indexStatus, indexStep, indexSteps, indexTry, limitsOf, lostIndexRow, madeMost, mergeCallsAfterOpen, mergeChunk, mergeHeldMost, narrowedAfter, newBuildId, positionOrder, pruneBuilds, putOnce, reachesBytes, reachesOf, readFurther, roomy, rootsKeyOf, rowsOfLayer, sliceBounds, storedTypesOf, triesWait, triesWaitMost, triesWaitOf, wordsOf };
|
|
@@ -7,17 +7,19 @@ import { anySet, bitCount, clearBit, isSet, nextSet, setBit } from "./bits.mjs";
|
|
|
7
7
|
import { bitmapWords } from "./ewah.mjs";
|
|
8
8
|
import { ewahMostWords } from "./index-bitmaps.mjs";
|
|
9
9
|
import { builtIndexOf, builtOver, coveredPacks, coversAll, decodeIndexValue } from "./index-build.mjs";
|
|
10
|
-
import { openTypes, typeOfCode } from "./index-files.mjs";
|
|
10
|
+
import { openBases, openTypes, typeOfCode } from "./index-files.mjs";
|
|
11
11
|
import { indexShallow, numberIn, numbersIn } from "./index-shallow.mjs";
|
|
12
|
+
import { oidTable } from "./oid-table.mjs";
|
|
12
13
|
import { listOf } from "./send-list.mjs";
|
|
13
|
-
import { ByGeneration, graphChunk, graphRows, openGraphLayers, openIndexGraph } from "./index-graph.mjs";
|
|
14
|
+
import { ByGeneration, graphChunk, graphRows, keptIdsBytes, openGraphLayers, openIndexGraph } from "./index-graph.mjs";
|
|
14
15
|
import { openLayerBitmaps, openLayout, orWords } from "./index-layers.mjs";
|
|
15
16
|
import { indexFiles, indexRowKey, isPackId, packFiles } from "./layout.mjs";
|
|
17
|
+
import { heldFiles, indexFilesOf, wholeFiles } from "./index-whole.mjs";
|
|
16
18
|
import { rangeCached, rangeEntriesBytes } from "./range-cache.mjs";
|
|
17
19
|
import { joinBytes, missing } from "./link-join.mjs";
|
|
18
20
|
import { placedReads } from "./placed-reads.mjs";
|
|
19
21
|
import { withRootsSent } from "./shallow.mjs";
|
|
20
|
-
import { lost, notHeld } from "./walk.mjs";
|
|
22
|
+
import { idsIn, lost, notHeld } from "./walk.mjs";
|
|
21
23
|
import * as Effect from "effect/Effect";
|
|
22
24
|
import * as Data from "effect/Data";
|
|
23
25
|
// src/storage/index-fetch.ts
|
|
@@ -48,6 +50,16 @@ const rangeCacheMost = 16777216;
|
|
|
48
50
|
*/
|
|
49
51
|
const rankBytes = 8;
|
|
50
52
|
/**
|
|
53
|
+
* The largest `.idx` ID window a pack adds to the walk's range allowance, 1 MiB: a pack of 52,428
|
|
54
|
+
* objects or fewer, whose joins then read the window once, not once a level (#2523). Past it, #522
|
|
55
|
+
* stands: a larger pack adds no ID window, as holding its IDs would hold most of what loading its
|
|
56
|
+
* `.idx` holds. It sizes the fetch's one allowance, which every pack's ranges share: it doesn't
|
|
57
|
+
* choose whose windows stay, so a larger pack's may stay in a smaller one's share.
|
|
58
|
+
*/
|
|
59
|
+
const keptIdWindowMost = 1048576;
|
|
60
|
+
/** What a pack of `objects` adds to the walk's range allowance: its `.pos` places, and its ID window under the bound. */
|
|
61
|
+
const keptRangeBytes = (objects) => objects * rankBytes + (objects * 20 <= keptIdWindowMost ? objects * 20 : 0) + rangeEntriesBytes;
|
|
62
|
+
/**
|
|
51
63
|
* What one stored bitmap holds once its layer's bitmaps are open: its table row as read and its
|
|
52
64
|
* words copied, its entry, and its places in `openLayerBitmaps`' maps and `numberAt`. Measured on
|
|
53
65
|
* Node 26 at 268–282 B a bitmap over 1,000 to 100,000 of them; 320 leaves room.
|
|
@@ -91,12 +103,13 @@ const rowsOf = (layer) => layer.groups.reduce((sum, group) => sum + group.rows,
|
|
|
91
103
|
/**
|
|
92
104
|
* The most bucket calls opening an index's layers for a fetch makes: each layer's `.graph`'s two
|
|
93
105
|
* (head and fanout, tail), its `.bitmaps`' three when it has any (head, table, tail), its
|
|
94
|
-
* `.types` header's one, its region's one when it has rows,
|
|
95
|
-
*
|
|
96
|
-
*
|
|
106
|
+
* `.types` header's one, its region's one when it has rows, its `.bases`' two when it has deltas
|
|
107
|
+
* (head, block index, #2523), and each of its packs' `.idx` head and fanout and `.pos` header. No
|
|
108
|
+
* covered pack's `.idx` and `.rev` are loaded whole: the layout and the send list read them by
|
|
109
|
+
* range. The row's own read is the one store call before it (#522).
|
|
97
110
|
*/
|
|
98
111
|
const fetchOpenCalls = (layers) => ({
|
|
99
|
-
bucket: layers.reduce((sum, layer) => sum + 2 + (layer.bitmaps > 0 ? 3 : 0) + 1 + (rowsOf(layer) > 0 ? 1 : 0) + 2 * packsOf(layer), 0),
|
|
112
|
+
bucket: layers.reduce((sum, layer) => sum + 2 + (layer.bitmaps > 0 ? 3 : 0) + 1 + (rowsOf(layer) > 0 ? 1 : 0) + (layer.deltas > 0 ? 2 : 0) + 2 * packsOf(layer), 0),
|
|
100
113
|
store: 0
|
|
101
114
|
});
|
|
102
115
|
/**
|
|
@@ -109,6 +122,27 @@ const regionBytes = (layers) => {
|
|
|
109
122
|
return rows * 24 + (runs > 1 ? rows * 84 : 0);
|
|
110
123
|
};
|
|
111
124
|
/**
|
|
125
|
+
* `source`'s bucket with the index's files held, when they're small: each read whole, at once, one
|
|
126
|
+
* call each, so the walk and the send list wait on one round, not one a range (#2523). The least
|
|
127
|
+
* they can be, from the row and the listing, is checked first. Then `wholeMost` is charged before
|
|
128
|
+
* any read, the reads stop there, and what the files don't hold goes back. `undefined` when they'd
|
|
129
|
+
* pass it, or did, so the index is read by range as before.
|
|
130
|
+
*/
|
|
131
|
+
const heldIndex = /* @__PURE__ */ Effect.fnUntraced(function* (source, row, covered, ahead, read) {
|
|
132
|
+
const most = source.wholeMost ?? 1048576;
|
|
133
|
+
const packs = source.listed.packs.filter(({ id }) => covered.has(id));
|
|
134
|
+
const files = indexFilesOf(source.listed.repo, row.layers, packs);
|
|
135
|
+
if (files === void 0 || files.reduce((sum, file) => sum + file.least, 0) > most) return void 0;
|
|
136
|
+
yield* ahead({
|
|
137
|
+
bucket: files.length,
|
|
138
|
+
store: 0
|
|
139
|
+
});
|
|
140
|
+
yield* read.hold(most);
|
|
141
|
+
const whole = yield* wholeFiles(source.bucket, files, most);
|
|
142
|
+
yield* read.release(most - (whole?.bytes ?? 0));
|
|
143
|
+
return whole === void 0 ? void 0 : heldFiles(source.bucket, whole.files);
|
|
144
|
+
});
|
|
145
|
+
/**
|
|
112
146
|
* The repo's index, opened: its row read through the request's store, 1 call, then its layers'
|
|
113
147
|
* files, `fetchOpenCalls` gets, forecast before any is made. `undefined` when there's no row, a
|
|
114
148
|
* refused one, or one whose layers don't cover `listed`, as when a row newer than it names a
|
|
@@ -116,7 +150,7 @@ const regionBytes = (layers) => {
|
|
|
116
150
|
*/
|
|
117
151
|
const openFetchIndex = /* @__PURE__ */ Effect.fnUntraced(function* (source, ahead, read) {
|
|
118
152
|
const { hold } = read;
|
|
119
|
-
const { store,
|
|
153
|
+
const { store, listed } = source;
|
|
120
154
|
yield* ahead({
|
|
121
155
|
bucket: 0,
|
|
122
156
|
store: 1
|
|
@@ -128,32 +162,39 @@ const openFetchIndex = /* @__PURE__ */ Effect.fnUntraced(function* (source, ahea
|
|
|
128
162
|
const row = builtIndexOf(decodeIndexValue(snapshot.results[0]?.[0]?.value));
|
|
129
163
|
if (row === void 0 || !builtOver(row, read.roots) || !coversAll(row.layers, listed)) return void 0;
|
|
130
164
|
if (source.opened !== void 0) source.opened.opened = true;
|
|
131
|
-
yield* ahead(fetchOpenCalls(row.layers));
|
|
132
|
-
yield* hold(regionBytes(row.layers));
|
|
133
|
-
const graphs = [];
|
|
134
|
-
let first = 0;
|
|
135
|
-
for (const layer of row.layers) {
|
|
136
|
-
const key = indexFiles(listed.repo, layer.build).graph;
|
|
137
|
-
const graph = yield* openIndexGraph(bucket, key, layer.graphFirst);
|
|
138
|
-
if (layer.graphFirst !== first || graph.commits !== layer.commits) return yield* Effect.fail(loss(`${key} holds ${graph.commits} from ${layer.graphFirst}, its row ${layer.commits}, where the layers below end at ${first}`));
|
|
139
|
-
graphs.push(graph);
|
|
140
|
-
first += graph.commits;
|
|
141
|
-
}
|
|
142
165
|
const covered = coveredPacks(row.layers);
|
|
166
|
+
const held = yield* heldIndex(source, row, covered, ahead, read);
|
|
167
|
+
const bucket = held ?? source.bucket;
|
|
168
|
+
yield* ahead(held === void 0 ? fetchOpenCalls(row.layers) : noCalls);
|
|
169
|
+
yield* hold(regionBytes(row.layers));
|
|
143
170
|
yield* hold(openedBitmapBytes * row.layers.reduce((sum, layer) => sum + layer.bitmaps, 0));
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
const rangeBytes = Math.min(rangeCacheMost, listed.packs.filter(({ id }) => covered.has(id)).reduce((sum, pack) => sum + pack.objects
|
|
171
|
+
const keepIds = held === void 0;
|
|
172
|
+
if (keepIds) yield* hold(row.layers.reduce((sum, layer) => sum + keptIdsBytes(layer.commits), 0));
|
|
173
|
+
const rangeBytes = held !== void 0 ? 0 : Math.min(rangeCacheMost, listed.packs.filter(({ id }) => covered.has(id)).reduce((sum, pack) => sum + keptRangeBytes(pack.objects), 0));
|
|
147
174
|
yield* hold(rangeBytes);
|
|
148
175
|
const ranges = rangeCached(bucket, rangeBytes, { evict: false });
|
|
149
176
|
const told = read.onLoading?.((id) => {
|
|
150
177
|
if (isPackId(id)) ranges.forget(packFiles(id).idx);
|
|
151
178
|
});
|
|
152
179
|
const { loadedOf } = read;
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
180
|
+
const deltaLayers = row.layers.filter((layer) => layer.deltas > 0);
|
|
181
|
+
const [graphs, bitmaps, types, layout, opened] = yield* Effect.all([
|
|
182
|
+
Effect.forEach(row.layers, (layer) => openIndexGraph(bucket, indexFiles(listed.repo, layer.build).graph, layer.graphFirst, { keepIds }), { concurrency: "unbounded" }),
|
|
183
|
+
openLayerBitmaps(bucket, listed.repo, row.layers),
|
|
184
|
+
Effect.forEach(row.layers, (layer) => openTypes(bucket, indexFiles(listed.repo, layer.build).types, layer.positions), { concurrency: "unbounded" }),
|
|
185
|
+
openLayout(ranges.bucket, listed, row.layers, void 0, loadedOf === void 0 ? { cached: true } : {
|
|
186
|
+
cached: true,
|
|
187
|
+
loadedOf
|
|
188
|
+
}),
|
|
189
|
+
Effect.forEach(deltaLayers, (layer) => openBases(bucket, indexFiles(listed.repo, layer.build).bases, layer.first + layer.positions, layer.deltas), { concurrency: "unbounded" })
|
|
190
|
+
], { concurrency: "unbounded" });
|
|
191
|
+
const bases = new Map(deltaLayers.map((layer, at) => [layer, opened[at]]));
|
|
192
|
+
let first = 0;
|
|
193
|
+
for (const [at, layer] of row.layers.entries()) {
|
|
194
|
+
const graph = graphs[at];
|
|
195
|
+
if (graph === void 0 || layer.graphFirst !== first || graph.commits !== layer.commits) return yield* Effect.fail(loss(`${indexFiles(listed.repo, layer.build).graph} holds ${graph?.commits} from ${layer.graphFirst}, its row ${layer.commits}, where the layers below end at ${first}`));
|
|
196
|
+
first += graph.commits;
|
|
197
|
+
}
|
|
157
198
|
const letRangesGo = Effect.andThen(Effect.sync(() => {
|
|
158
199
|
told?.();
|
|
159
200
|
ranges.clear();
|
|
@@ -172,50 +213,41 @@ const openFetchIndex = /* @__PURE__ */ Effect.fnUntraced(function* (source, ahea
|
|
|
172
213
|
types,
|
|
173
214
|
layout,
|
|
174
215
|
numberAt,
|
|
175
|
-
letRangesGo
|
|
216
|
+
letRangesGo,
|
|
217
|
+
bucket,
|
|
218
|
+
bases,
|
|
219
|
+
held: held !== void 0
|
|
176
220
|
};
|
|
177
221
|
});
|
|
178
222
|
/**
|
|
179
|
-
* IDs,
|
|
180
|
-
*
|
|
181
|
-
*
|
|
223
|
+
* A level's IDs, each kept once in an ID table, and a kind for each by its ordinal, grown as the
|
|
224
|
+
* level's trees name them: so a level holds what's distinct in it, not every snapshot's entries
|
|
225
|
+
* (#1702). Both double together when the table is full, its slots twice its capacity.
|
|
182
226
|
*/
|
|
183
227
|
var Frontier = class {
|
|
184
|
-
|
|
228
|
+
table = oidTable(64);
|
|
185
229
|
kinds = /* @__PURE__ */ new Uint8Array(64);
|
|
186
|
-
|
|
187
|
-
|
|
230
|
+
get count() {
|
|
231
|
+
return this.table.size;
|
|
232
|
+
}
|
|
233
|
+
/** Its IDs end to end, as a pack index's join reads them. */
|
|
234
|
+
get ids() {
|
|
235
|
+
return this.table.ids;
|
|
236
|
+
}
|
|
188
237
|
add(id, kind) {
|
|
189
|
-
if (this.
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const kinds = new Uint8Array(this.kinds.length * 2);
|
|
238
|
+
if (this.table.size === this.table.capacity) {
|
|
239
|
+
const capacity = this.table.capacity * 2;
|
|
240
|
+
this.table.grow(capacity);
|
|
241
|
+
const kinds = new Uint8Array(capacity);
|
|
194
242
|
kinds.set(this.kinds);
|
|
195
243
|
this.kinds = kinds;
|
|
196
|
-
this.slots = new Uint32Array(this.slots.length * 2);
|
|
197
|
-
for (let at = 0; at < this.count; at += 1) this.slots[this.free(this.ids, at * 20)] = at + 1;
|
|
198
244
|
}
|
|
199
|
-
const
|
|
200
|
-
if (this.
|
|
201
|
-
this.ids.set(id, this.count * 20);
|
|
202
|
-
this.kinds[this.count] = kind;
|
|
203
|
-
this.count += 1;
|
|
204
|
-
this.slots[slot] = this.count;
|
|
245
|
+
const next = this.table.size;
|
|
246
|
+
if (this.table.addBytes(id) === next) this.kinds[next] = kind;
|
|
205
247
|
}
|
|
206
|
-
/** The
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
let slot = ((bytes[from] ?? 0) | (bytes[from + 1] ?? 0) << 8 | (bytes[from + 2] ?? 0) << 16 | (bytes[from + 3] ?? 0) << 24) & mask;
|
|
210
|
-
for (;;) {
|
|
211
|
-
const held = this.slots[slot] ?? 0;
|
|
212
|
-
if (held === 0 || this.same(held - 1, bytes, from)) return slot;
|
|
213
|
-
slot = slot + 1 & mask;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
same(at, bytes, from) {
|
|
217
|
-
for (let byte = 0; byte < 20; byte += 1) if (this.ids[at * 20 + byte] !== bytes[from + byte]) return false;
|
|
218
|
-
return true;
|
|
248
|
+
/** The ID at `at`, in hex. */
|
|
249
|
+
oidAt(at) {
|
|
250
|
+
return this.table.oidAt(at);
|
|
219
251
|
}
|
|
220
252
|
/** What it holds at most, grown twice over: `fetchRootFrontierBytes` an ID. */
|
|
221
253
|
static bytes(count) {
|
|
@@ -229,6 +261,11 @@ const blobKind = 2;
|
|
|
229
261
|
* today's walk does. See the file's comment for how; the bounds are `shape-2.md`'s §6.
|
|
230
262
|
*/
|
|
231
263
|
const indexSendSet = (input) => indexSendSetOrNot(input).pipe(Effect.catchTag("Unindexed", () => Effect.succeed(void 0)));
|
|
264
|
+
/** The index path over `source`. */
|
|
265
|
+
const indexPath = (source) => ({
|
|
266
|
+
source,
|
|
267
|
+
send: indexSendSet
|
|
268
|
+
});
|
|
232
269
|
const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
233
270
|
const { source, read, request, ahead } = input;
|
|
234
271
|
const { indexed, sizesAt, heldAt, unplaced: unplacedOf } = read;
|
|
@@ -242,12 +279,13 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
242
279
|
ranges: layout.ranges,
|
|
243
280
|
layers: row.layers,
|
|
244
281
|
listed: source.listed,
|
|
245
|
-
bucket:
|
|
282
|
+
bucket: index.bucket,
|
|
246
283
|
read,
|
|
247
284
|
indexed,
|
|
248
285
|
heldAt,
|
|
249
286
|
outside,
|
|
250
|
-
ahead
|
|
287
|
+
ahead,
|
|
288
|
+
bases: index.bases
|
|
251
289
|
});
|
|
252
290
|
/** `placed`'s objects read at their positions, and `beside`'s, which the index doesn't place, past it. */
|
|
253
291
|
const readSplit = Effect.fnUntraced(function* (placed, beside, newLevel = true) {
|
|
@@ -344,13 +382,13 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
344
382
|
const position = positions[at] ?? 4294967295;
|
|
345
383
|
if (level < 0) {
|
|
346
384
|
if (reads) {
|
|
347
|
-
reading.push(
|
|
385
|
+
reading.push(frontier.oidAt(at));
|
|
348
386
|
placed.push(position);
|
|
349
387
|
}
|
|
350
388
|
continue;
|
|
351
389
|
}
|
|
352
390
|
if (position === 4294967295) {
|
|
353
|
-
const oid =
|
|
391
|
+
const oid = frontier.oidAt(at);
|
|
354
392
|
if (heldExtras.has(oid) || side === "wanted" && sentExtras.has(oid)) continue;
|
|
355
393
|
if (side === "held") {
|
|
356
394
|
yield* read.hold(heldExtraBytes);
|
|
@@ -368,7 +406,7 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
368
406
|
if (blocked(side, position)) continue;
|
|
369
407
|
setBit(bits, position);
|
|
370
408
|
if (kind === "tree" && reads) {
|
|
371
|
-
reading.push(
|
|
409
|
+
reading.push(frontier.oidAt(at));
|
|
372
410
|
placed.push(position);
|
|
373
411
|
}
|
|
374
412
|
}
|
|
@@ -401,10 +439,11 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
401
439
|
if (tree.type !== "tree" || tree.entries === void 0) return yield* Effect.fail(loss(`${oid}, named as a tree, is a ${tree.type}`));
|
|
402
440
|
const extra = side === "wanted" && position === 4294967295 ? sentExtras.get(oid) : void 0;
|
|
403
441
|
if (extra !== void 0) extra.size = tree.size;
|
|
404
|
-
const
|
|
442
|
+
const { trees, blobs } = tree.entries;
|
|
443
|
+
const growing = next.count + idsIn(trees) + idsIn(blobs);
|
|
405
444
|
yield* holdStep(Frontier.bytes(frontier.count) + frontier.count * 4 + Frontier.bytes(growing));
|
|
406
|
-
for (
|
|
407
|
-
for (
|
|
445
|
+
for (let at = 0; at < trees.length; at += 20) next.add(trees.subarray(at, at + 20), treeKind);
|
|
446
|
+
for (let at = 0; at < blobs.length; at += 20) next.add(blobs.subarray(at, at + 20), blobKind);
|
|
408
447
|
read.letGo(tree);
|
|
409
448
|
}
|
|
410
449
|
yield* read.letGoReads(asked.length);
|
|
@@ -673,7 +712,7 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
673
712
|
const rootsAt = row.layers.flatMap((layer) => (layer.roots ?? []).filter((position) => isSet(send, position)));
|
|
674
713
|
const packed = rootsAt.filter((position) => layout.ranges.some((pack) => position >= pack.base && position < pack.base + pack.count));
|
|
675
714
|
if (packed.length > 0) yield* ahead({
|
|
676
|
-
bucket: 2 * packed.length,
|
|
715
|
+
bucket: index.held ? packed.length : 2 * packed.length,
|
|
677
716
|
store: 0
|
|
678
717
|
});
|
|
679
718
|
for (const position of rootsAt) {
|
|
@@ -698,7 +737,7 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
698
737
|
}
|
|
699
738
|
}
|
|
700
739
|
yield* ahead({
|
|
701
|
-
bucket: windows.length,
|
|
740
|
+
bucket: index.held ? 0 : windows.length,
|
|
702
741
|
store: 0
|
|
703
742
|
});
|
|
704
743
|
let sending = 0;
|
|
@@ -736,9 +775,11 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
736
775
|
ranges,
|
|
737
776
|
layers: row.layers,
|
|
738
777
|
listed: source.listed,
|
|
739
|
-
bucket:
|
|
778
|
+
bucket: index.bucket,
|
|
740
779
|
read,
|
|
741
|
-
ahead
|
|
780
|
+
ahead,
|
|
781
|
+
bases: index.bases,
|
|
782
|
+
indexHeld: index.held
|
|
742
783
|
};
|
|
743
784
|
if (filter?.kind === "blob:limit") {
|
|
744
785
|
listInput.blobsUnder = filter.bytes;
|
|
@@ -793,4 +834,4 @@ const indexSendSetOrNot = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
793
834
|
deepened: withRootsSent(deepened, rootsSent)
|
|
794
835
|
};
|
|
795
836
|
});
|
|
796
|
-
export { fetchOpenCalls, indexEligible, indexSendSet };
|
|
837
|
+
export { fetchOpenCalls, indexEligible, indexPath, indexSendSet, keptRangeBytes };
|