@ref0/git 0.26.0 → 0.29.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/client/git-http.mjs +29 -12
- package/dist/client/push-upload.mjs +13 -12
- package/dist/client/remote-helper.mjs +1 -1
- package/dist/client/remote.mjs +1 -1
- package/dist/client/run-remote-helper.mjs +7 -14
- package/dist/client/slice-push.d.mts +13 -9
- package/dist/client/slice-push.mjs +16 -5
- package/dist/client/slice-report.mjs +6 -8
- package/dist/client/transport.mjs +27 -5
- package/dist/contracts/git.d.mts +17 -2
- package/dist/contracts/store.d.mts +1 -1
- package/dist/core/forks.mjs +1 -1
- package/dist/core/purge.mjs +1 -1
- package/dist/http/push-uploads.mjs +10 -15
- package/dist/lfs/copy.d.mts +4 -1
- package/dist/lfs/copy.mjs +7 -6
- package/dist/lfs/layer.mjs +1 -1
- package/dist/lfs/objects.mjs +127 -8
- package/dist/lfs/upload-most.mjs +19 -3
- package/dist/merges/merges.d.mts +3 -2
- package/dist/protocol/bytes/buffers.mjs +26 -1
- package/dist/protocol/bytes/crc32.mjs +39 -6
- package/dist/protocol/bytes/deflate.d.mts +11 -31
- package/dist/protocol/bytes/deflate.mjs +133 -72
- package/dist/protocol/bytes/inflate.d.mts +11 -6
- package/dist/protocol/bytes/inflate.mjs +184 -119
- package/dist/protocol/bytes/sha1-hasher.mjs +12 -12
- package/dist/protocol/bytes/zlib-ng/LICENSE.md +19 -0
- package/dist/protocol/bytes/zlib-ng/README.md +132 -0
- package/dist/protocol/bytes/zlib-ng/bundled.d.mts +5 -0
- package/dist/protocol/bytes/zlib-ng/bundled.mjs +8 -0
- package/dist/protocol/bytes/zlib-ng/compile.d.mts +9 -0
- package/dist/protocol/bytes/zlib-ng/compile.mjs +19 -0
- package/dist/protocol/bytes/zlib-ng/embedded.mjs +4 -0
- package/dist/protocol/bytes/zlib-ng/instance.d.mts +1 -0
- package/dist/protocol/bytes/zlib-ng/instance.mjs +111 -0
- package/dist/protocol/bytes/zlib-ng/zlib-ng.wasm +0 -0
- package/dist/protocol/objects/fsck-names.mjs +27 -7
- package/dist/protocol/objects/fsck.mjs +100 -88
- package/dist/protocol/objects/object-rules.d.mts +1 -0
- package/dist/protocol/objects/tree.d.mts +1 -0
- package/dist/protocol/objects/tree.mjs +55 -6
- package/dist/protocol/packs/reader.mjs +35 -30
- package/dist/protocol/wire/push-uploads.mjs +12 -1
- package/dist/server/registry.mjs +12 -0
- package/dist/server/server.mjs +7 -1
- package/dist/storage/budget.d.mts +2 -0
- package/dist/storage/budget.mjs +26 -24
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +4 -2
- package/dist/storage/host-bucket.mjs +15 -5
- package/dist/storage/index-bitmaps.d.mts +1 -0
- package/dist/storage/index-bitmaps.mjs +15 -14
- package/dist/storage/index-build.d.mts +2 -1
- package/dist/storage/index-build.mjs +14 -15
- package/dist/storage/index-files.mjs +3 -3
- package/dist/storage/index-graph.mjs +3 -3
- package/dist/storage/index-remap.mjs +6 -7
- package/dist/storage/links.mjs +34 -2
- package/dist/storage/loose.mjs +2 -1
- package/dist/storage/memory-budget.d.mts +1 -0
- package/dist/storage/memory-budget.mjs +12 -3
- package/dist/storage/merge-most.mjs +2 -1
- package/dist/storage/merge-stream.mjs +4 -3
- package/dist/storage/merge-write.mjs +2 -2
- package/dist/storage/pack-reads.mjs +1 -1
- package/dist/storage/pack-receive.mjs +24 -8
- package/dist/storage/packs-memory.mjs +2 -1
- package/dist/storage/packs.d.mts +3 -1
- package/dist/storage/packs.mjs +34 -11
- package/dist/storage/put-holds.d.mts +1 -0
- package/dist/storage/put-holds.mjs +20 -0
- package/dist/storage/ready.mjs +4 -2
- package/dist/storage/receive-bounds.d.mts +1 -1
- package/dist/storage/receive-bounds.mjs +4 -4
- package/dist/storage/receive-links.mjs +31 -15
- package/dist/storage/receive-steps.mjs +21 -1
- package/dist/storage/runs.d.mts +1 -1
- package/dist/storage/runs.mjs +7 -5
- package/dist/store/door.mjs +9 -1
- package/dist/store/job-try.mjs +5 -5
- package/dist/store/repo-record.mjs +1 -1
- package/dist/sync/step.mjs +3 -4
- package/package.json +12 -9
- package/dist/http/node.d.mts +0 -62
- package/dist/http/node.mjs +0 -212
- package/dist/node.d.mts +0 -3
- package/dist/node.mjs +0 -1
- package/dist/server/edge-node.d.mts +0 -19
- package/dist/server/edge-node.mjs +0 -20
package/dist/storage/budget.mjs
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
|
+
import { allottableOf, defaultMemory, headroomBytes, idleHeapBytes } from "../protocol/bytes/buffers.mjs";
|
|
1
2
|
import { receiveCheckedBytes } from "./fsck.mjs";
|
|
2
3
|
import { receiveIndexHeldOf, receiveRoomAdmitted } from "./receive-admission.mjs";
|
|
3
4
|
import { receiveTableMost } from "./receive-bounds.mjs";
|
|
5
|
+
import { putHeldBytes, uploadPartBytes } from "./put-holds.mjs";
|
|
4
6
|
import { blockBytes, blockHeld, blocksHeld, packIndexerLimits, readCacheBytes } from "./pack-reads.mjs";
|
|
5
7
|
// src/storage/budget.ts
|
|
6
8
|
const mib = 1048576;
|
|
7
|
-
/** A Worker isolate's 128 MB, read as decimal: the memory `packs()` runs in unless told. */
|
|
8
|
-
const defaultMemory = 128e6;
|
|
9
|
-
/**
|
|
10
|
-
* What an `examples/git-worker` isolate holds outside any allotment, so the allotted and the
|
|
11
|
-
* headroom fit the most a request's work holds on Workers before the isolate is replaced:
|
|
12
|
-
* 128,000,000 less 120,061,952, read in SJC at 3795e0349 on a3ac998ae (Q893, 25 Nov 2026). That's
|
|
13
|
-
* a cold isolate's lowest fill of JS heap, 123,207,680, less the 3,145,728 a Git request's or a
|
|
14
|
-
* `git.repack` try's own state keeps on top. ArrayBuffers aren't counted at once, so nothing is
|
|
15
|
-
* sized from their fills.
|
|
16
|
-
*/
|
|
17
|
-
const idleHeapBytes = 7938048;
|
|
18
|
-
/** What `packs()` leaves free of `memory`, for what no allotment counts. */
|
|
19
|
-
const headroomBytes = 16 * mib;
|
|
20
|
-
/** The part a bucket's upload holds, R2's for a push of unknown size: 8 MiB. */
|
|
21
|
-
const uploadPartBytes = 8 * mib;
|
|
22
|
-
/** What operations are allotted of `memory`: all of it but an idle heap and the headroom. */
|
|
23
|
-
const allottableOf = (memory) => memory - idleHeapBytes - headroomBytes;
|
|
24
9
|
/** A reader's floors: a read cache of 2 MiB and one block. */
|
|
25
10
|
const readerFloors = {
|
|
26
11
|
cache: 2 * mib,
|
|
@@ -34,10 +19,20 @@ const readerMost = {
|
|
|
34
19
|
blocks: 8 * blockHeld(blockBytes)
|
|
35
20
|
};
|
|
36
21
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
22
|
+
* What a staged receive's step puts of its pack: none. Its pack was staged whole before it, and a
|
|
23
|
+
* step reads it back from the bucket, so it holds no part of it on any bucket, whatever its length.
|
|
24
|
+
* The index files it puts are charged where they're put, in `receivePack`'s room (#3096).
|
|
39
25
|
*/
|
|
40
|
-
const
|
|
26
|
+
const stagedPuts = {
|
|
27
|
+
partSize: uploadPartBytes,
|
|
28
|
+
buffersMost: 0,
|
|
29
|
+
wholeMost: Number.POSITIVE_INFINITY
|
|
30
|
+
};
|
|
31
|
+
/** The parts a push's put holds, its pack told its `length` when known: `putHeldBytes`. */
|
|
32
|
+
const pushPartBytes = (size) => putHeldBytes(size.multipart, {
|
|
33
|
+
size: size.length,
|
|
34
|
+
atMost: size.atMost
|
|
35
|
+
});
|
|
41
36
|
/**
|
|
42
37
|
* A push's floors, scaled to it, each capped at what push-90mib's receive took no more CPU at: a
|
|
43
38
|
* base cache of `min(4 MiB, objects × 32 KiB)` and its pack's first two blocks as `blocksHeld`
|
|
@@ -98,10 +93,11 @@ const pushAdmissionOf = (size) => pushFixedOf(size) + receiveRoomAdmitted(size.o
|
|
|
98
93
|
/**
|
|
99
94
|
* The most objects a push of `size`'s length takes in a `packs()` instance of `memory`, at most
|
|
100
95
|
* `receiveTableMost`: the most whose admission fits beside the read reserve, and whose index files
|
|
101
|
-
* fit beside it too as they're made. In a Worker's 128 MB,
|
|
102
|
-
*
|
|
96
|
+
* fit beside it too as they're made. In a Worker's 128 MB, 641,583 for a chunked push to R2 or
|
|
97
|
+
* Blob, whose put holds four 8 MiB parts, and 1,215,694 to the memory bucket, which holds one. What
|
|
98
|
+
* a push takes is the less of it and what a prune walk holds an index of, `pushObjectsMostOf`.
|
|
103
99
|
*/
|
|
104
|
-
const receiveObjectsMostOf = (memory, size
|
|
100
|
+
const receiveObjectsMostOf = (memory, size) => {
|
|
105
101
|
const room = allottableOf(memory) - readReserveBytes;
|
|
106
102
|
let low = 0;
|
|
107
103
|
let high = receiveTableMost;
|
|
@@ -141,6 +137,12 @@ const unpackInflatedMost = 16 * mib;
|
|
|
141
137
|
*/
|
|
142
138
|
const readReserveBytes = fetchFloorBytes;
|
|
143
139
|
/**
|
|
140
|
+
* The least memory whose upkeep share, all of it but the idle heap, the headroom and the read
|
|
141
|
+
* reserve, holds one put to a bucket of `multipart` alone, all a put of any body holds
|
|
142
|
+
* (`putHeldBytes`): what a server's objects take beside its bucket, as its puts are charged there.
|
|
143
|
+
*/
|
|
144
|
+
const putMemoryLeast = (multipart) => idleHeapBytes + headroomBytes + readReserveBytes + putHeldBytes(multipart);
|
|
145
|
+
/**
|
|
144
146
|
* The most decoded/base64 object-row bytes one fetch request's row cache keeps between `heldHaves`,
|
|
145
147
|
* `planFetch`, and `rowsFirst` (#2899). Inline rows that fit both this byte cap and
|
|
146
148
|
* `fetchRowCacheEntries` are reused across those phases without re-reading the store; rows past
|
|
@@ -148,4 +150,4 @@ const readReserveBytes = fetchFloorBytes;
|
|
|
148
150
|
* pack streaming starts.
|
|
149
151
|
*/
|
|
150
152
|
const fetchRowCacheBytes = 524288;
|
|
151
|
-
export { allottableOf, defaultMemory, fetchFloorBytes, fetchRowCacheBytes, headroomBytes, idleHeapBytes, openTreeBytes, openTreesFloorBytes, pushAdmissionOf, pushFloorsOf, pushPartBytes, pushReaderFloorsOf, pushRulesOf, readReserveBytes, readerFloorBytes, readerFloors, readerMost, receiveObjectsMostOf, unpackInflatedMost, uploadPartBytes };
|
|
153
|
+
export { allottableOf, defaultMemory, fetchFloorBytes, fetchRowCacheBytes, headroomBytes, idleHeapBytes, openTreeBytes, openTreesFloorBytes, pushAdmissionOf, pushFloorsOf, pushPartBytes, pushReaderFloorsOf, pushRulesOf, putHeldBytes, putMemoryLeast, readReserveBytes, readerFloorBytes, readerFloors, readerMost, receiveObjectsMostOf, stagedPuts, unpackInflatedMost, uploadPartBytes };
|
package/dist/storage/calls.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { Allotment, GitObject, ObjectHeader, ObjectHeadersInput, ObjectHeldInput
|
|
|
3
3
|
import { GitError } from "../contracts/result.mjs";
|
|
4
4
|
import { Listed } from "../contracts/store.mjs";
|
|
5
5
|
import "../store/call-count.mjs";
|
|
6
|
-
import "@ref0/infra";
|
|
6
|
+
import { Multipart } from "@ref0/infra";
|
|
7
7
|
import * as Effect from "effect/Effect";
|
|
8
8
|
import "effect/Context";
|
|
9
9
|
import "effect/Scope";
|
package/dist/storage/calls.mjs
CHANGED
|
@@ -392,12 +392,14 @@ const deleteCharge = (batch, keys) => {
|
|
|
392
392
|
const bucketDeleteMany = (bucket, keys) => bucketDo(bucket.removeMany(keys));
|
|
393
393
|
/**
|
|
394
394
|
* Why `multipart` can't count a put, or `undefined`: a part size above 0, a whole most, whole
|
|
395
|
-
* calls, and at least one for a put sent whole, since one that sends anything makes a call
|
|
395
|
+
* calls, and at least one for a put sent whole, since one that sends anything makes a call, and at
|
|
396
|
+
* least one part held, since a put in parts holds the one it fills.
|
|
396
397
|
*/
|
|
397
|
-
const uncountable = ({ partSize, begin, end, wholeMost, wholeCalls }) => {
|
|
398
|
+
const uncountable = ({ partSize, begin, end, wholeMost, wholeCalls, buffersMost }) => {
|
|
398
399
|
if (partSize !== Number.POSITIVE_INFINITY && !(Number.isSafeInteger(partSize) && partSize > 0)) return `A bucket's multipart.partSize is a whole number of bytes above 0, not ${partSize}`;
|
|
399
400
|
if (wholeMost !== Number.POSITIVE_INFINITY && !(Number.isSafeInteger(wholeMost) && wholeMost >= 0)) return `A bucket's multipart.wholeMost is a whole number of bytes, not ${wholeMost}`;
|
|
400
401
|
if (!(Number.isSafeInteger(wholeCalls) && wholeCalls >= 1)) return `A bucket's multipart.wholeCalls is a whole number of calls above 0, not ${wholeCalls}`;
|
|
402
|
+
if (!(Number.isSafeInteger(buffersMost) && buffersMost >= 1)) return `A bucket's multipart.buffersMost is a whole number of buffers above 0, not ${buffersMost}`;
|
|
401
403
|
return [begin, end].every((calls) => Number.isSafeInteger(calls) && calls >= 0) ? void 0 : `A bucket's multipart.begin and end are whole numbers of calls, not ${begin} and ${end}`;
|
|
402
404
|
};
|
|
403
405
|
/** `multipart`'s refusal as a defect when it can't count a put: a bucket's, never a caller's. */
|
|
@@ -30,11 +30,21 @@ const hostFailures = (bucket) => ({
|
|
|
30
30
|
abortPut: (key, token) => Effect.catchDefect(bucket.abortPut(key, token), hostFailure)
|
|
31
31
|
});
|
|
32
32
|
/** The host's links, each call's defect a failure, as `hostFailures` says. */
|
|
33
|
-
const hostLinks = (links) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
const hostLinks = (links) => {
|
|
34
|
+
const calls = {
|
|
35
|
+
url: (key, options) => Effect.catchDefect(links.url(key, options), hostFailure),
|
|
36
|
+
putUrl: (key, options) => Effect.catchDefect(links.putUrl(key, options), hostFailure),
|
|
37
|
+
head: (key) => Effect.catchDefect(links.head(key), hostFailure)
|
|
38
|
+
};
|
|
39
|
+
return links.puts === "checked" ? {
|
|
40
|
+
puts: "checked",
|
|
41
|
+
...calls
|
|
42
|
+
} : {
|
|
43
|
+
puts: "unchecked",
|
|
44
|
+
...calls,
|
|
45
|
+
copy: (from, to) => Effect.catchDefect(links.copy(from, to), hostFailure)
|
|
46
|
+
};
|
|
47
|
+
};
|
|
38
48
|
/** The host's uploads, each call's defect a failure, as `hostFailures` says. */
|
|
39
49
|
const hostUploads = (uploads) => ({
|
|
40
50
|
maxParts: uploads.maxParts,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { sha1Now, sha1NowHasher } from "../protocol/bytes/sha1-hasher.mjs";
|
|
3
3
|
import { bucketDo, bucketReading, bucketTry, readWhole } from "./calls.mjs";
|
|
4
4
|
import { bitmapOf, bitmapWords, ewahExtent, ewahOf, mostDirty, orEwah } from "./ewah.mjs";
|
|
5
5
|
import "./link-join.mjs";
|
|
6
|
-
import { uploadPartBytes } from "./
|
|
6
|
+
import { putHeldBytes, uploadPartBytes } from "./put-holds.mjs";
|
|
7
7
|
import { startPut } from "./merge.mjs";
|
|
8
8
|
import { readExactly } from "./pack-ranges.mjs";
|
|
9
9
|
import * as Effect from "effect/Effect";
|
|
@@ -303,9 +303,7 @@ const orderKey = (order) => {
|
|
|
303
303
|
view.setUint32(at * 8, position);
|
|
304
304
|
view.setUint32(at * 8 + 4, number);
|
|
305
305
|
}
|
|
306
|
-
|
|
307
|
-
sha.update(bytes);
|
|
308
|
-
return [...sha.digest()].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
306
|
+
return [...sha1Now([bytes])].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
309
307
|
};
|
|
310
308
|
/** The most bytes one part of a whole build's bitmaps holds: one upload part. */
|
|
311
309
|
const partBytesMost = uploadPartBytes;
|
|
@@ -619,7 +617,7 @@ const walkBytes = (positions) => {
|
|
|
619
617
|
*/
|
|
620
618
|
const bitmapsPut = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, positions, count) {
|
|
621
619
|
const put = yield* startPut(bucket, key, { atMost: bitmapsMostBytes(positions, count) });
|
|
622
|
-
const sha =
|
|
620
|
+
const sha = sha1NowHasher();
|
|
623
621
|
const entries = [];
|
|
624
622
|
let offset = 0;
|
|
625
623
|
const write = (bytes) => {
|
|
@@ -691,12 +689,14 @@ const bitmapsPut = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, pos
|
|
|
691
689
|
});
|
|
692
690
|
/**
|
|
693
691
|
* What `writeBitmaps` grows its allotment by before walking: the walk's buffers (`walkBytes`),
|
|
694
|
-
* the bitmaps it keeps in `made` (`kept`), the streaming put
|
|
695
|
-
* directly
|
|
692
|
+
* the bitmaps it keeps in `made` (`kept`), the streaming put's parts when writing `.bitmaps`
|
|
693
|
+
* directly, on a bucket of `put`'s multipart, and none for a part, and
|
|
694
|
+
* the layer-below arrays when updating.
|
|
696
695
|
*/
|
|
697
696
|
const bitmapsWalkBytes = (positions, kept, options) => {
|
|
698
697
|
const words = bitmapWords(positions);
|
|
699
|
-
|
|
698
|
+
const put = options?.put;
|
|
699
|
+
return walkBytes(positions) + kept + (put === void 0 ? 0 : putHeldBytes(put, { atMost: bitmapsMostBytes(positions, options?.count ?? 0) })) + (options?.below === true ? words * 12 : 0);
|
|
700
700
|
};
|
|
701
701
|
/**
|
|
702
702
|
* A bitmap for each of `input.chosen`, oldest first, each the set of positions its object
|
|
@@ -713,7 +713,7 @@ const writeBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
713
713
|
const order = bitmapOrder(input.chosen);
|
|
714
714
|
const count = order.length;
|
|
715
715
|
const held = input.walkReserved === true ? 0 : bitmapsWalkBytes(positions, input.kept, {
|
|
716
|
-
part
|
|
716
|
+
...part === void 0 && { put: input.bucket.multipart },
|
|
717
717
|
below: below !== void 0,
|
|
718
718
|
count
|
|
719
719
|
});
|
|
@@ -835,12 +835,13 @@ const copyRunBytes = 1048576;
|
|
|
835
835
|
/**
|
|
836
836
|
* What `copyBitmaps` holds to copy `count` bitmaps over `positions` from files of `from`'s
|
|
837
837
|
* positions: what `eachBitmap` holds of one file, the merged words and their EWAH, the piece it
|
|
838
|
-
* writes through and
|
|
838
|
+
* writes through and what its put holds on a bucket of `multipart`. Its lists of the bitmaps are
|
|
839
|
+
* its caller's to charge.
|
|
839
840
|
*/
|
|
840
|
-
const copyHeldBytes = (positions, count, from) => {
|
|
841
|
+
const copyHeldBytes = (positions, count, from, multipart) => {
|
|
841
842
|
const words = bitmapWords(positions);
|
|
842
843
|
const reading = Math.max(0, ...from.map((each) => eachBitmapBytes(each, copyRunBytes)));
|
|
843
|
-
const part =
|
|
844
|
+
const part = putHeldBytes(multipart, { atMost: bitmapsMostBytes(positions, count) });
|
|
844
845
|
return reading + words * 4 + ewahMostWords(words) * 4 + pieceBytes + part;
|
|
845
846
|
};
|
|
846
847
|
/**
|
|
@@ -860,7 +861,7 @@ const copyBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
860
861
|
of.push(each);
|
|
861
862
|
byFile.set(each.from, of);
|
|
862
863
|
}
|
|
863
|
-
const held = copyHeldBytes(positions, copied.length, [...byFile.keys()].map((from) => from.positions));
|
|
864
|
+
const held = copyHeldBytes(positions, copied.length, [...byFile.keys()].map((from) => from.positions), input.bucket.multipart);
|
|
864
865
|
yield* input.allotment.grow(held);
|
|
865
866
|
const put = yield* bitmapsPut(input.bucket, input.key, positions, copied.length);
|
|
866
867
|
const all = new Uint32Array(words);
|
|
@@ -6,12 +6,13 @@ import "../contracts/store.mjs";
|
|
|
6
6
|
import "../protocol/objects/commit.mjs";
|
|
7
7
|
import "../store/call-count.mjs";
|
|
8
8
|
import "./fetch.mjs";
|
|
9
|
+
import "./budget.mjs";
|
|
9
10
|
import "./index-graph.mjs";
|
|
10
11
|
import "./index-layers.mjs";
|
|
11
12
|
import "./layout.mjs";
|
|
12
13
|
import "./memory-budget.mjs";
|
|
13
14
|
import "./pack-order.mjs";
|
|
14
|
-
import { Moment, Row } from "@ref0/infra";
|
|
15
|
+
import { Moment, Multipart, Row } from "@ref0/infra";
|
|
15
16
|
import "effect/Schema";
|
|
16
17
|
import "effect/Effect";
|
|
17
18
|
import "effect/Option";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spentIn } from "../contracts/calls-spent.mjs";
|
|
2
2
|
import { gitError } from "../contracts/result.mjs";
|
|
3
3
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { sha1Now } from "../protocol/bytes/sha1-hasher.mjs";
|
|
5
5
|
import { writeCommitGraph } from "../protocol/packs/graph.mjs";
|
|
6
6
|
import { IndexerCache } from "../protocol/packs/indexer.mjs";
|
|
7
7
|
import { indexHeadBytes, oidBytes, tablesOf } from "../protocol/packs/idx.mjs";
|
|
@@ -9,7 +9,8 @@ import { noRepoRoots } from "../protocol/objects/commit.mjs";
|
|
|
9
9
|
import { rawLinks } from "../protocol/objects/links-raw.mjs";
|
|
10
10
|
import { rootsDigest } from "../store/repo-record.mjs";
|
|
11
11
|
import { randomText } from "../store/random.mjs";
|
|
12
|
-
import { allottableOf
|
|
12
|
+
import { allottableOf } from "../protocol/bytes/buffers.mjs";
|
|
13
|
+
import { putHeldBytes, uploadPartBytes } from "./put-holds.mjs";
|
|
13
14
|
import { bucketDeleteMany, bucketDo, bucketPut, joined, readEach, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
|
|
14
15
|
import { BitmapsPart, EdgeFiles, PriorParts, bitmapOrder, bitmapsMostBytes, bitmapsPut, bitmapsWalkBytes, copyBitmaps, copyHeldBytes, copyRunBytes, edgesBytesOf, edgesFileOf, ewahMostWords, noNumber, orderKey, partBitmaps, partBytesMost, priorFootersMost, priorPartsRoom, runsMost, storedBitmaps, storedSize, writeBitmaps } from "./index-bitmaps.mjs";
|
|
15
16
|
import { BasesWriter, TypesWriter, indexBasesBytes, indexTypesBytes, openBases, openTypes, typeCodes } from "./index-files.mjs";
|
|
@@ -669,12 +670,11 @@ const readRegion = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, e
|
|
|
669
670
|
return true;
|
|
670
671
|
}), void 0, regionPageRows);
|
|
671
672
|
if (whole !== "done") return whole;
|
|
672
|
-
const
|
|
673
|
-
sha.update(ids.subarray(0, rows * 20));
|
|
673
|
+
const kept = ids.subarray(0, rows * 20);
|
|
674
674
|
return {
|
|
675
|
-
ids:
|
|
675
|
+
ids: kept,
|
|
676
676
|
rows,
|
|
677
|
-
digest: hexOf(
|
|
677
|
+
digest: hexOf(sha1Now([kept]))
|
|
678
678
|
};
|
|
679
679
|
});
|
|
680
680
|
/**
|
|
@@ -1493,7 +1493,7 @@ const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files,
|
|
|
1493
1493
|
};
|
|
1494
1494
|
}
|
|
1495
1495
|
const into = new BitmapsPart(partBytesMost);
|
|
1496
|
-
const walkHeld = bitmapsWalkBytes(input.positions, input.kept
|
|
1496
|
+
const walkHeld = bitmapsWalkBytes(input.positions, input.kept);
|
|
1497
1497
|
yield* allotment.grow(walkHeld);
|
|
1498
1498
|
let priorCharged = 0;
|
|
1499
1499
|
const made = yield* Effect.ensuring(Effect.gen(function* () {
|
|
@@ -1532,7 +1532,7 @@ const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files,
|
|
|
1532
1532
|
const { counted } = parts;
|
|
1533
1533
|
const madeCalls = counted?.made();
|
|
1534
1534
|
const callsFit = counted === void 0 || madeCalls === void 0 || directNeeds <= counted.most.bucket - madeCalls.bucket && directNeeds <= counted.most.subrequests - madeCalls.subrequests;
|
|
1535
|
-
const putBuffer =
|
|
1535
|
+
const putBuffer = putHeldBytes(parts.bucket.multipart, { atMost });
|
|
1536
1536
|
if (callsFit && (putBuffer === 0 || allotment.tryGrow(putBuffer))) return yield* Effect.ensuring(Effect.gen(function* () {
|
|
1537
1537
|
const already = yield* storedSize(parts.bucket, files.bitmaps);
|
|
1538
1538
|
const written = already === void 0 ? yield* Effect.scoped(Effect.gen(function* () {
|
|
@@ -1602,7 +1602,7 @@ const bitmapsJoined = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files,
|
|
|
1602
1602
|
if (counted !== void 0 && needs > counted.most.bucket - counted.made().bucket) return yield* Effect.fail(bitmapsUnjoined(needs, counted.most.bucket));
|
|
1603
1603
|
const already = yield* storedSize(bucket, files.bitmaps);
|
|
1604
1604
|
const written = already === void 0 ? yield* Effect.scoped(Effect.gen(function* () {
|
|
1605
|
-
yield* allotment.grow(partBytesMost +
|
|
1605
|
+
yield* allotment.grow(partBytesMost + putHeldBytes(bucket.multipart, { atMost }));
|
|
1606
1606
|
const put = yield* bitmapsPut(bucket, files.bitmaps, positions, cut.done);
|
|
1607
1607
|
for (const [number, held] of cut.parts.entries()) {
|
|
1608
1608
|
const key = files.bitmapsPart(cut.order, number);
|
|
@@ -1744,7 +1744,7 @@ const liveHeldBytes = (words, tips, rows) => words * 4 + orIntoBytes(words) + ti
|
|
|
1744
1744
|
* the layout's rows; the copy's; or `.types` and `.bases`' chunks. Each phase's go before the
|
|
1745
1745
|
* next's, and the bitmaps' entries stay through the union and the copy, `mergeEntryBytes` each.
|
|
1746
1746
|
*/
|
|
1747
|
-
const mergeHeldMost = (merging) => {
|
|
1747
|
+
const mergeHeldMost = (merging, multipart) => {
|
|
1748
1748
|
const { layers, tips } = merging;
|
|
1749
1749
|
const positions = firstOf(layers);
|
|
1750
1750
|
const words = bitmapWords(positions);
|
|
@@ -1756,7 +1756,7 @@ const mergeHeldMost = (merging) => {
|
|
|
1756
1756
|
rows * 40,
|
|
1757
1757
|
commits * 4 + mergeHeldBytes(layers.length),
|
|
1758
1758
|
liveHeldBytes(words, tips, rows),
|
|
1759
|
-
copyHeldBytes(positions, bitmaps, files),
|
|
1759
|
+
copyHeldBytes(positions, bitmaps, files, multipart),
|
|
1760
1760
|
mergeFilesBytes
|
|
1761
1761
|
];
|
|
1762
1762
|
return Math.max(...phases) + bitmaps * 640;
|
|
@@ -1787,10 +1787,9 @@ const mergedRegion = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, repo,
|
|
|
1787
1787
|
region.set(ids, at);
|
|
1788
1788
|
at += ids.byteLength;
|
|
1789
1789
|
}
|
|
1790
|
-
const
|
|
1791
|
-
sha.update(region);
|
|
1790
|
+
const digest = hexOf(sha1Now([region]));
|
|
1792
1791
|
if (region.byteLength > 0) yield* putOnce(bucket, key, region);
|
|
1793
|
-
return
|
|
1792
|
+
return digest;
|
|
1794
1793
|
});
|
|
1795
1794
|
/**
|
|
1796
1795
|
* The stored bitmaps a merge keeps: those a current tip's stored bitmap reaches, ORed through
|
|
@@ -1889,7 +1888,7 @@ const mergeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, listed, da
|
|
|
1889
1888
|
};
|
|
1890
1889
|
const past = callsPast(parts, mergeCallsAfterOpen(merging, bucket.multipart));
|
|
1891
1890
|
if (past !== void 0) return yield* Effect.fail(past);
|
|
1892
|
-
const held = mergeHeldMost(merging);
|
|
1891
|
+
const held = mergeHeldMost(merging, bucket.multipart);
|
|
1893
1892
|
const most = parts.budget.mostOf(true);
|
|
1894
1893
|
const tooLarge = mergePast(held, "bytes", most, "Raise `PacksOptions.memory`.");
|
|
1895
1894
|
yield* allotment.grow(held, tooLarge);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { sha1NowHasher } from "../protocol/bytes/sha1-hasher.mjs";
|
|
3
3
|
import { readExactly } from "./pack-ranges.mjs";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
// src/storage/index-files.ts
|
|
@@ -70,7 +70,7 @@ const broken = (message) => Effect.die(new Error(message));
|
|
|
70
70
|
*/
|
|
71
71
|
var TypesWriter = class {
|
|
72
72
|
positions;
|
|
73
|
-
#sha =
|
|
73
|
+
#sha = sha1NowHasher();
|
|
74
74
|
#carry = 0;
|
|
75
75
|
#written = 0;
|
|
76
76
|
constructor(positions) {
|
|
@@ -121,7 +121,7 @@ var TypesWriter = class {
|
|
|
121
121
|
var BasesWriter = class {
|
|
122
122
|
positions;
|
|
123
123
|
deltas;
|
|
124
|
-
#sha =
|
|
124
|
+
#sha = sha1NowHasher();
|
|
125
125
|
#blocks;
|
|
126
126
|
#block = 0;
|
|
127
127
|
#rows = 0;
|
|
@@ -3,7 +3,7 @@ import { BufferError, BufferMeter } from "../protocol/bytes/buffers.mjs";
|
|
|
3
3
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
4
4
|
import { noRepoRoots } from "../protocol/objects/commit.mjs";
|
|
5
5
|
import { mostParents } from "../protocol/objects/object-rules.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { sha1NowHasher } from "../protocol/bytes/sha1-hasher.mjs";
|
|
7
7
|
import { graphMagic } from "../protocol/packs/graph.mjs";
|
|
8
8
|
import { PackTransportError, boundedSource, packReadBytes } from "../protocol/packs/reader.mjs";
|
|
9
9
|
import { bucketStream } from "./calls.mjs";
|
|
@@ -84,7 +84,7 @@ const asIs = (value) => value;
|
|
|
84
84
|
const indexGraphBytes = (commits, octopus) => 1040 + commits * 32 + octopus * 4 + 20;
|
|
85
85
|
/** A file's bytes from one streamed read, taken a few at a time, hashed as they're taken. */
|
|
86
86
|
const taker = (read) => {
|
|
87
|
-
const sha =
|
|
87
|
+
const sha = sha1NowHasher();
|
|
88
88
|
let piece = /* @__PURE__ */ new Uint8Array(0);
|
|
89
89
|
let at = 0;
|
|
90
90
|
return {
|
|
@@ -293,7 +293,7 @@ const firstSlot = (commit) => commit * 2;
|
|
|
293
293
|
const octopusTarget = (entry) => (octopusFlag | entry) >>> 0;
|
|
294
294
|
/** Bytes gathered into writes of `writeBytes`, each hashed. */
|
|
295
295
|
const gathered = (write) => {
|
|
296
|
-
const sha =
|
|
296
|
+
const sha = sha1NowHasher();
|
|
297
297
|
let buffer = new Uint8Array(writeBytes);
|
|
298
298
|
let filled = 0;
|
|
299
299
|
const flush = Effect.suspend(() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { sha1Now } from "../protocol/bytes/sha1-hasher.mjs";
|
|
4
4
|
import { answerSpent, pastCallLimit } from "../store/errors.mjs";
|
|
5
5
|
import { copyHeldBytes, isKeepUnclosed, isMergeIncomplete, mergeIncomplete } from "./index-bitmaps.mjs";
|
|
6
6
|
import { belowGraphs, copyMergedBitmaps, coveredPacks, indexRowOf, mergeCallsAfterOpen, mergeChunk, newBuildId, putOnce, wordsOf } from "./index-build.mjs";
|
|
@@ -93,7 +93,7 @@ const keptRowBytes = 64;
|
|
|
93
93
|
* beside the tail's and then beside the graph merge's, and the bitmaps' copy beside both, since
|
|
94
94
|
* it runs before the graph's file finishes.
|
|
95
95
|
*/
|
|
96
|
-
const remapHeldMost = (plan, layers, objects, keeps = false) => {
|
|
96
|
+
const remapHeldMost = (plan, layers, objects, multipart, keeps = false) => {
|
|
97
97
|
const tail = plan.positions - plan.prefix;
|
|
98
98
|
const positions = plan.prefix + tail + objects;
|
|
99
99
|
const commits = layers.reduce((sum, layer) => sum + layer.commits, 0);
|
|
@@ -105,7 +105,7 @@ const remapHeldMost = (plan, layers, objects, keeps = false) => {
|
|
|
105
105
|
const dropped = keeps ? Math.max(0, taken - objects) : 0;
|
|
106
106
|
const ids = map + tail * 20 + joinBytes(tail) + plan.rows * keptRowBytes;
|
|
107
107
|
const graph = commits * 4 + mergeHeldBytes(layers.length);
|
|
108
|
-
const copy = bitmaps * 640 + copyHeldBytes(positions, bitmaps, files);
|
|
108
|
+
const copy = bitmaps * 640 + copyHeldBytes(positions, bitmaps, files, multipart);
|
|
109
109
|
const phases = [
|
|
110
110
|
ids + goneBuildBytes(dropped),
|
|
111
111
|
map + goneHeldBytes(dropped) + graph,
|
|
@@ -220,7 +220,7 @@ const remapPast = (input) => {
|
|
|
220
220
|
if (remapCpuPast(remapUnits(plan, layers), input.cpuMost)) return "cpu";
|
|
221
221
|
if (input.lease !== void 0 && input.lease >= input.grace) return "lease";
|
|
222
222
|
if (pastCallsLeft(input.calls, remapCallsMost(plan, layers, mergedObjects(merged), input.bucket.multipart))) return "calls";
|
|
223
|
-
const held = remapHeldMost(plan, layers, mergedObjects(merged), input.keeps !== void 0);
|
|
223
|
+
const held = remapHeldMost(plan, layers, mergedObjects(merged), input.bucket.multipart, input.keeps !== void 0);
|
|
224
224
|
if (!input.allotment.tryGrow(held)) return "memory";
|
|
225
225
|
input.allotment.shrink(held);
|
|
226
226
|
};
|
|
@@ -589,8 +589,7 @@ const remapIndex = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
589
589
|
yield* Effect.scoped(types);
|
|
590
590
|
yield* Effect.scoped(bases);
|
|
591
591
|
allotment.shrink(filesBytes + entries + map4);
|
|
592
|
-
const
|
|
593
|
-
sha.update(regionIds);
|
|
592
|
+
const regionDigest = sha1Now([regionIds]);
|
|
594
593
|
if (regionIds.byteLength > 0) yield* putOnce(bucket, files.region, regionIds);
|
|
595
594
|
const layer = {
|
|
596
595
|
build,
|
|
@@ -602,7 +601,7 @@ const remapIndex = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
602
601
|
],
|
|
603
602
|
rows: read.kept.length
|
|
604
603
|
}],
|
|
605
|
-
region: hexOf(
|
|
604
|
+
region: hexOf(regionDigest),
|
|
606
605
|
first: 0,
|
|
607
606
|
positions,
|
|
608
607
|
graphFirst: 0,
|
package/dist/storage/links.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { readCommit } from "../protocol/objects/commit.mjs";
|
|
3
3
|
import { readTag } from "../protocol/objects/tag.mjs";
|
|
4
|
-
import { treeReader } from "../protocol/objects/tree.mjs";
|
|
4
|
+
import { TreeEntries, treeReader } from "../protocol/objects/tree.mjs";
|
|
5
5
|
import { receiveBoundaryMost, receiveCutParentsMost } from "./receive-bounds.mjs";
|
|
6
6
|
import * as Schema from "effect/Schema";
|
|
7
7
|
import * as Result from "effect/Result";
|
|
@@ -52,6 +52,38 @@ const linkReader = (object) => {
|
|
|
52
52
|
let at = 0;
|
|
53
53
|
return () => Result.succeed(links.success[at++]);
|
|
54
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* A checked tree's links, read in place: `linkReader`'s links of a tree `fsckObject` passed, one
|
|
57
|
+
* at a time, each ID left where the tree holds it, at `idAt`, so a caller that keeps IDs as bytes
|
|
58
|
+
* makes no text of them and nothing an entry. Its bytes are entries to their end, in Git's order,
|
|
59
|
+
* as fsck passed them, so it reads each with no check of its own; bytes that aren't one end it.
|
|
60
|
+
*/
|
|
61
|
+
var TreeLinks = class {
|
|
62
|
+
/** Where the link's 20-byte ID starts in the tree's bytes. */
|
|
63
|
+
idAt = 0;
|
|
64
|
+
/** The type the link says: a folder's is a tree, a file's or a symlink's a blob. */
|
|
65
|
+
type = "blob";
|
|
66
|
+
#entries;
|
|
67
|
+
#at = 0;
|
|
68
|
+
bytes;
|
|
69
|
+
constructor(bytes) {
|
|
70
|
+
this.bytes = bytes;
|
|
71
|
+
this.#entries = new TreeEntries(bytes);
|
|
72
|
+
}
|
|
73
|
+
/** Moves to the next link, past each submodule, or `false` past the last. */
|
|
74
|
+
next() {
|
|
75
|
+
const entries = this.#entries;
|
|
76
|
+
while (this.#at < this.bytes.length && entries.read(this.#at)) {
|
|
77
|
+
this.#at = entries.end();
|
|
78
|
+
if (entries.kind === "gitlink") continue;
|
|
79
|
+
this.idAt = entries.nul + 1;
|
|
80
|
+
this.type = entries.kind === "tree" ? "tree" : "blob";
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
this.#at = this.bytes.length;
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
55
87
|
/** The links of an object that isn't a tree, which are few: a commit's tree and parents, a tag's object. */
|
|
56
88
|
const fewLinks = (object) => {
|
|
57
89
|
switch (object.type) {
|
|
@@ -187,4 +219,4 @@ const shallowRoot = () => gitError("FAILED_PRECONDITION", "shallow update not al
|
|
|
187
219
|
context: { reason: "shallow-root" }
|
|
188
220
|
});
|
|
189
221
|
const isShallowRoot = (error) => error.code === "FAILED_PRECONDITION" && error.context?.reason === "shallow-root";
|
|
190
|
-
export { CutCarry, boundaryNotInPack, folder, gitlink, isShallowRoot, linkReader, linksOf, mistyped, objectMissing, segmentCut, segmentTooLarge, shallowLinks, shallowRoot, tagTargetMissing, wrongType };
|
|
222
|
+
export { CutCarry, TreeLinks, boundaryNotInPack, folder, gitlink, isShallowRoot, linkReader, linksOf, mistyped, objectMissing, segmentCut, segmentTooLarge, shallowLinks, shallowRoot, tagTargetMissing, wrongType };
|
package/dist/storage/loose.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { handingOn } from "../protocol/packs/writer.mjs";
|
|
|
2
2
|
import { newChangeId } from "../store/scopes.mjs";
|
|
3
3
|
import { callScope } from "../store/call-count.mjs";
|
|
4
4
|
import { cancelsBody, objectReader } from "./calls.mjs";
|
|
5
|
+
import { allottableOf, defaultMemory } from "../protocol/bytes/buffers.mjs";
|
|
5
6
|
import { fetchPack } from "./fetch.mjs";
|
|
6
7
|
import { pushedCommitsPage } from "./pushed-commits.mjs";
|
|
7
8
|
import { copyRowsPage, eachHeldRow, gitObjectOf, heldRows, readStagedRows, readsOwnChunks, rowAt, rowHeaders, rowSizes, rowsStartingWith, startingOf } from "./object-rows.mjs";
|
|
@@ -9,7 +10,7 @@ import { allotmentWithin } from "../contracts/object-values.mjs";
|
|
|
9
10
|
import { allottedRows } from "./allotted.mjs";
|
|
10
11
|
import { looseUpkeep } from "./batch-upkeep.mjs";
|
|
11
12
|
import { abandonBatch, batchStager, fastPath, openBatch, stageBytes, streamedChange } from "./batches.mjs";
|
|
12
|
-
import {
|
|
13
|
+
import { readReserveBytes } from "./budget.mjs";
|
|
13
14
|
import { ChunkReader, chunkPageBytes, chunkRawBytes, chunkStream, chunkedRow, fitsRow, stageChunk } from "./chunks.mjs";
|
|
14
15
|
import { MemoryBudget, withMemoryBudget } from "./memory-budget.mjs";
|
|
15
16
|
import { baseLruBytes, pendingHeldMost, roundReadBytes, unpackObjects } from "./unpack.mjs";
|
|
@@ -75,6 +75,14 @@ const readBusy = /* @__PURE__ */ gitError("UNAVAILABLE", "The server is busy: tr
|
|
|
75
75
|
context: { reason: "busy" }
|
|
76
76
|
});
|
|
77
77
|
/**
|
|
78
|
+
* A put's charge's refusal, `Registration.putCharge`'s, when no room came within upkeep's wait: a
|
|
79
|
+
* job's put, whose try ends and comes again.
|
|
80
|
+
*/
|
|
81
|
+
const putBusy = /* @__PURE__ */ gitError("UNAVAILABLE", "The server's memory had no room for a put to the bucket", {
|
|
82
|
+
hint: "The job tries again",
|
|
83
|
+
context: { reason: "busy" }
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
78
86
|
* Maintenance's refusal when what one of its steps holds at once is past all it may hold, the
|
|
79
87
|
* budget less the read reserve, which no wait would make room for. Past only what's free while others hold the rest, the step waits
|
|
80
88
|
* as `readBusy` and comes back later (Q879's split, as Q888 asks of maintenance).
|
|
@@ -1046,9 +1054,10 @@ const pruneIndexObjectsMost = Math.floor((pruneIndexFloor - indexBytes({
|
|
|
1046
1054
|
* The most objects one push of `size`'s length takes in a `packs()` instance of `memory`: what its
|
|
1047
1055
|
* memory takes, `receiveObjectsMostOf`, and no more than `pruneIndexObjectsMost`, so a prune walk
|
|
1048
1056
|
* holds its pack's index, which no merge cuts while it's alone. Past it, a push is refused before
|
|
1049
|
-
* it waits, by the most. In a Worker's 128 MB, 1,048,528
|
|
1057
|
+
* it waits, by the most. In a Worker's 128 MB on R2 or Blob, 1,048,528 for a push told a length
|
|
1058
|
+
* its bucket sends whole, and 641,583 for a chunked one, whose put holds four 8 MiB parts.
|
|
1050
1059
|
*/
|
|
1051
|
-
const pushObjectsMostOf = (memory, size
|
|
1060
|
+
const pushObjectsMostOf = (memory, size) => Math.min(receiveObjectsMostOf(memory, size), pruneIndexObjectsMost);
|
|
1052
1061
|
/**
|
|
1053
1062
|
* What a prune walk's seen set holds (#2019): a bit for each object of each of `packs`, at its rank,
|
|
1054
1063
|
* and for each of `outside` objects no listed pack holds, its ID, at `fetchEntryBytes`. A part's
|
|
@@ -1339,4 +1348,4 @@ const budgetOfObjects = (objects) => {
|
|
|
1339
1348
|
const found = objects[objectBudget];
|
|
1340
1349
|
return found instanceof MemoryBudget ? found : void 0;
|
|
1341
1350
|
};
|
|
1342
|
-
export { AllottedPointers, MemoryAllotment, MemoryBudget, allotmentCacheCharge, allottedWithin, budgetOfObjects, cacheRoomCharge, fetchBusy, growWaitMs, headStuckMs, instanceRoomOf, joinRoomOf, outsideOn, pruneIndexFloor, pruneIndexObjectsMost, pruneSeenBytes, pushBusy, pushEntryTooLarge, pushIndexTooLarge, pushMemoryOf, pushObjectsMostOf, pushTooLarge, pushWaitMs, readBusy, readerMemoryOf, requestBudgetOf, requestRoomOf, rowCacheRoomOf, upkeepMemoryOf, upkeepRuns, upkeepTooLarge, withMemoryBudget };
|
|
1351
|
+
export { AllottedPointers, MemoryAllotment, MemoryBudget, allotmentCacheCharge, allottedWithin, budgetOfObjects, cacheRoomCharge, fetchBusy, growWaitMs, headStuckMs, instanceRoomOf, joinRoomOf, outsideOn, pruneIndexFloor, pruneIndexObjectsMost, pruneSeenBytes, pushBusy, pushEntryTooLarge, pushIndexTooLarge, pushMemoryOf, pushObjectsMostOf, pushTooLarge, pushWaitMs, putBusy, readBusy, readerMemoryOf, requestBudgetOf, requestRoomOf, rowCacheRoomOf, upkeepMemoryOf, upkeepRuns, upkeepTooLarge, withMemoryBudget };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { allottableOf, defaultMemory } from "../protocol/bytes/buffers.mjs";
|
|
1
2
|
import { fanoutBytes, indexHeadBytes } from "../protocol/packs/idx.mjs";
|
|
2
|
-
import {
|
|
3
|
+
import { readerFloors } from "./budget.mjs";
|
|
3
4
|
import { runKey } from "./layout.mjs";
|
|
4
5
|
import { upkeepRuns } from "./memory-budget.mjs";
|
|
5
6
|
import { chooseHeld, chosenMost, foldedRows } from "./merge-choose.mjs";
|
|
@@ -9,6 +9,7 @@ import { linksOf } from "./links.mjs";
|
|
|
9
9
|
import { outsideOn, upkeepRuns, upkeepTooLarge } from "./memory-budget.mjs";
|
|
10
10
|
import { choose, chooseCalls, chooseHeld, chosenFirstCalls } from "./merge-choose.mjs";
|
|
11
11
|
import { passObjectsMost, unresolvable, writeCallsOf } from "./merge-cut.mjs";
|
|
12
|
+
import { putHeldBytes } from "./put-holds.mjs";
|
|
12
13
|
import { fencedStep, lossFence } from "./merge-fence.mjs";
|
|
13
14
|
import { mergeBlocksRoom, mergeInputsMost, writingHeld } from "./merge-most.mjs";
|
|
14
15
|
import { indexCalls, indexHeld, indexPack } from "./merge-index.mjs";
|
|
@@ -254,12 +255,12 @@ const goOn = /* @__PURE__ */ Effect.fnUntraced(function* (passes, from, resumed,
|
|
|
254
255
|
};
|
|
255
256
|
});
|
|
256
257
|
/**
|
|
257
|
-
* The
|
|
258
|
-
* puts any pack a merge writes in one call, else
|
|
258
|
+
* The parts a merge's pack put holds, each put told its pack's size (#1670): none on a bucket that
|
|
259
|
+
* puts any pack a merge writes in one call, else its `buffersMost` buffers, as Blob's puts in parts hold. A
|
|
259
260
|
* pack can pass `maxPackSize`, as an entry past it alone goes in a pack of its own, but never
|
|
260
261
|
* `maxPackSizeMost`, so that's the size it's compared with.
|
|
261
262
|
*/
|
|
262
|
-
const putPartHeld = (multipart) => multipart
|
|
263
|
+
const putPartHeld = (multipart) => putHeldBytes(multipart, { size: maxPackSizeMost });
|
|
263
264
|
/** The hold of a merge of `inputs`, charged to the step's allotment while its scope is open. */
|
|
264
265
|
const charged = (input, inputs) => {
|
|
265
266
|
const held = streamHeld(inputs) + putPartHeld(input.bucket.multipart);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sha1NowHasher } from "../protocol/bytes/sha1-hasher.mjs";
|
|
2
2
|
import { randomText } from "../store/random.mjs";
|
|
3
3
|
import { packFiles } from "./layout.mjs";
|
|
4
4
|
import { upkeepRuns } from "./memory-budget.mjs";
|
|
@@ -37,7 +37,7 @@ const writePack = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
37
37
|
tag: 0
|
|
38
38
|
};
|
|
39
39
|
const upload = yield* startPut(bucket, packFiles(input.pack).pack, { size: planned.bytes });
|
|
40
|
-
const sha =
|
|
40
|
+
const sha = sha1NowHasher();
|
|
41
41
|
const pack = openPack(input.readers, planned.objects);
|
|
42
42
|
let offset = 0;
|
|
43
43
|
let chunk = new Uint8Array(writeChunkBytes);
|
|
@@ -169,7 +169,7 @@ var PackBlocks = class {
|
|
|
169
169
|
else this.#releaseEntryReader();
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
/** Releases the reused entry reader's
|
|
172
|
+
/** Releases the reused entry reader's buffers and meter allotments once idle. */
|
|
173
173
|
close() {
|
|
174
174
|
if (this.#entryReaderInUse) {
|
|
175
175
|
this.#closeReaderOnFinish = true;
|