@ref0/git 0.32.0 → 0.34.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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { bucketBodyIn, joined } from "./calls.mjs";
|
|
2
|
+
import { blockBytes } from "./pack-reads.mjs";
|
|
2
3
|
import { replayPieceBytes } from "./range-cache.mjs";
|
|
3
4
|
import * as Effect from "effect/Effect";
|
|
4
5
|
import * as Stream from "effect/Stream";
|
|
@@ -7,24 +8,38 @@ import * as Exit from "effect/Exit";
|
|
|
7
8
|
/**
|
|
8
9
|
* The most a repo's index build keeps of its index files between its steps, 16 MiB. svelte's
|
|
9
10
|
* first build, 91,275 objects, reads about 10 MiB of them over its 10 chained steps, and about
|
|
10
|
-
* 5 s of its wall went to reading them again (#596).
|
|
11
|
-
* about 150 MiB of those, past what a Durable Object's 128 MB could hold.
|
|
11
|
+
* 5 s of its wall went to reading them again (#596). A pack's whole body is never kept: the build
|
|
12
|
+
* reads about 150 MiB of those, past what a Durable Object's 128 MB could hold.
|
|
12
13
|
*/
|
|
13
14
|
const indexStepFilesMost = 16777216;
|
|
15
|
+
/**
|
|
16
|
+
* The most a repo's index build keeps of its packs' blocks between its steps: `blocksKept` blocks
|
|
17
|
+
* of `blockBytes`, about 8 MiB. svelte's first build reads 6 blocks twice over its read steps, for
|
|
18
|
+
* the bases outside each slice, and about 0.5–1.4 s of its wall went to the second reads (#596).
|
|
19
|
+
*/
|
|
20
|
+
const indexStepBlocksMost = 8 * (blockBytes + 320);
|
|
14
21
|
/** A pack's own index file, as `packFiles` names it: `packs/<ID>.idx` and its kin. */
|
|
15
22
|
const packIndexFile = /^packs\/[^/]+\.(?:idx|pos|rev|graph|types)$/;
|
|
23
|
+
/** A pack's bytes, as `packFiles` names them. */
|
|
24
|
+
const packBody = /^packs\/[^/]+\.pack$/;
|
|
16
25
|
/**
|
|
17
|
-
*
|
|
18
|
-
* `.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
26
|
+
* A build's index files: a put under `index/`, or of a pack's `.idx`, `.pos`, `.rev`, `.graph` or
|
|
27
|
+
* `.types`, as `packFiles` names them, and a read of a pack's. A file under `index/` is kept only as
|
|
28
|
+
* a step puts it: one it didn't, an earlier layer's, `PackIndexes` holds whole where it's read whole.
|
|
29
|
+
* Never a pack's bytes, nor a receive's keys under its pack's.
|
|
21
30
|
*/
|
|
22
|
-
const
|
|
31
|
+
const indexFileKeeps = {
|
|
32
|
+
put: (key) => key.startsWith("index/") || packIndexFile.test(key),
|
|
33
|
+
read: (key) => packIndexFile.test(key)
|
|
34
|
+
};
|
|
23
35
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
36
|
+
* A build's pack blocks: a read of one block of a pack's bytes, as `PackBlocks` reads it, from an
|
|
37
|
+
* offset `blockBytes` divides and no longer than it. Never a pack's whole body, nor a slice's range.
|
|
26
38
|
*/
|
|
27
|
-
const
|
|
39
|
+
const packBlockKeeps = {
|
|
40
|
+
put: () => false,
|
|
41
|
+
read: (key, range) => packBody.test(key) && range !== void 0 && range.offset % 1048576 === 0 && range.length <= 1048576
|
|
42
|
+
};
|
|
28
43
|
/**
|
|
29
44
|
* `kept`'s bytes from `from` to `to`, `replayPieceBytes` a piece, each its own copy read from them
|
|
30
45
|
* as it's pulled, so no reader changes another's. Bytes let go mid-way are no longer held here:
|
|
@@ -58,13 +73,14 @@ const replayed = (context, bucket, kept, from, to) => {
|
|
|
58
73
|
}, { highWaterMark: 0 });
|
|
59
74
|
};
|
|
60
75
|
/**
|
|
61
|
-
* The
|
|
62
|
-
* charged to `charge`: a server's per-instance room
|
|
63
|
-
* free and gives way first, so what it keeps never
|
|
76
|
+
* The files one repo's build reads and writes, or the blocks of its packs, as `keeps` says, kept
|
|
77
|
+
* between its steps within `most`, each charged to `charge`: a server's per-instance room
|
|
78
|
+
* (`instanceRoomOf`), which takes only what's free and gives way first, so what it keeps never
|
|
79
|
+
* holds back a live operation (#596).
|
|
64
80
|
*
|
|
65
81
|
* A step reads through `over`'s bucket. A read of a kept file, or of a range inside a kept one,
|
|
66
|
-
* answers from memory with no call. A put
|
|
67
|
-
*
|
|
82
|
+
* answers from memory with no call. A put `keeps` names is kept as it lands, and a read it names
|
|
83
|
+
* as its body is read to its end. The least recently used goes first past `most`,
|
|
68
84
|
* all of it when the room shrinks, and a removed key is let go. A step for another repo, or
|
|
69
85
|
* `clear`, lets everything go: the cache holds one build's files at a time.
|
|
70
86
|
*/
|
|
@@ -80,9 +96,12 @@ var IndexStepFiles = class {
|
|
|
80
96
|
/** Each fill under way, by what lets its copies go: everything let go lets them go too. */
|
|
81
97
|
#fills = /* @__PURE__ */ new Set();
|
|
82
98
|
#repo;
|
|
83
|
-
|
|
99
|
+
#keeps;
|
|
100
|
+
/** `keeps`: what it keeps, a build's index files unless it says. */
|
|
101
|
+
constructor(charge, most = indexStepFilesMost, keeps = indexFileKeeps) {
|
|
84
102
|
this.#charge = charge;
|
|
85
103
|
this.most = most;
|
|
104
|
+
this.#keeps = keeps;
|
|
86
105
|
charge.watch(() => this.#letGo(false));
|
|
87
106
|
}
|
|
88
107
|
/** What it holds now: kept entries and fills under way, as charged. */
|
|
@@ -98,14 +117,13 @@ var IndexStepFiles = class {
|
|
|
98
117
|
return {
|
|
99
118
|
...bucket,
|
|
100
119
|
read: (key, range) => Effect.suspend(() => {
|
|
101
|
-
if (!keepable(key)) return bucket.read(key, range);
|
|
102
120
|
const found = this.#replay(key, range);
|
|
103
121
|
if (found !== void 0) return Effect.map(Effect.context(), (context) => replayed(context, bucket, found.kept, found.from, found.to));
|
|
104
|
-
if (!
|
|
122
|
+
if (!this.#keeps.read(key, range)) return bucket.read(key, range);
|
|
105
123
|
return Effect.map(bucket.read(key, range), (body) => this.#teed(key, range, body));
|
|
106
124
|
}),
|
|
107
125
|
put: (key, body, options) => Effect.suspend(() => {
|
|
108
|
-
if (!
|
|
126
|
+
if (!this.#keeps.put(key)) return bucket.put(key, body, options);
|
|
109
127
|
const fill = this.#fill(options?.size);
|
|
110
128
|
if (fill === void 0) return bucket.put(key, body, options);
|
|
111
129
|
return bucket.put(key, Stream.map(body, fill.add), options).pipe(Effect.onExit((exit) => Effect.sync(() => Exit.isSuccess(exit) ? fill.end(key, void 0, exit.value.size) : fill.drop())));
|
|
@@ -283,4 +301,4 @@ var IndexStepFiles = class {
|
|
|
283
301
|
if (release && charged > 0) this.#charge.shrink(charged);
|
|
284
302
|
}
|
|
285
303
|
};
|
|
286
|
-
export { IndexStepFiles, indexStepFilesMost };
|
|
304
|
+
export { IndexStepFiles, indexFileKeeps, indexStepBlocksMost, indexStepFilesMost, packBlockKeeps };
|
package/dist/storage/merge.mjs
CHANGED
|
@@ -65,7 +65,7 @@ const packPutOptions = ({ length: size, atMost }) => size === void 0 && atMost =
|
|
|
65
65
|
*/
|
|
66
66
|
const startPut = (bucket, key, options) => Effect.acquireRelease(started(bucket, key, options), (put, exit) => Exit.isSuccess(exit) ? Effect.void : put.abort);
|
|
67
67
|
/**
|
|
68
|
-
* `startPut`'s put, started: its writes, its end and its abort, owned by no one yet. The body is
|
|
68
|
+
* `startPut`'s put, started: its writes, its end, its landing and its abort, owned by no one yet. The body is
|
|
69
69
|
* pulled a chunk at a time, and each pull is told: the first comes once the service has charged
|
|
70
70
|
* the put's start, and each after once it has charged the chunk before, so `started` returns, and
|
|
71
71
|
* each write, only past their charges, and a charge the bound refuses fails the call that made it.
|
|
@@ -80,9 +80,13 @@ const started = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, option
|
|
|
80
80
|
const abort = Effect.andThen(Effect.suspend(() => Queue.fail(queue, /* @__PURE__ */ new Error("The put stopped"))), Fiber.interrupt(put));
|
|
81
81
|
yield* Effect.onInterrupt(pulled, () => abort);
|
|
82
82
|
const write = (bytes) => Effect.suspend(() => put.pollUnsafe() === void 0 ? Effect.andThen(Effect.raceFirst(Queue.offer(queue, bytes), ended), pulled) : ended);
|
|
83
|
+
const end = Queue.end(queue);
|
|
84
|
+
const landed = Effect.asVoid(Fiber.join(put));
|
|
83
85
|
return {
|
|
84
86
|
write,
|
|
85
|
-
|
|
87
|
+
end,
|
|
88
|
+
landed,
|
|
89
|
+
finish: Effect.andThen(end, landed),
|
|
86
90
|
abort
|
|
87
91
|
};
|
|
88
92
|
});
|
|
@@ -250,7 +250,8 @@ const startUpload = (bucket, key, input) => Effect.map(startPut(bucket, key, pac
|
|
|
250
250
|
const tail = total - sent;
|
|
251
251
|
if (tail < 0 || tail > held.byteLength) return yield* Effect.die(/* @__PURE__ */ new Error(`the upload sent ${sent} of a ${total}-byte pack`));
|
|
252
252
|
if (tail > 0) yield* write(held.slice(0, tail));
|
|
253
|
-
yield* put.
|
|
253
|
+
yield* put.end;
|
|
254
|
+
return yield* Effect.cached(put.landed);
|
|
254
255
|
}),
|
|
255
256
|
abort: put.abort
|
|
256
257
|
};
|
|
@@ -263,7 +264,8 @@ const startUpload = (bucket, key, input) => Effect.map(startPut(bucket, key, pac
|
|
|
263
264
|
* but a shallow client's commit's parents, refused as `shallowRoot` when the repo lacks them. Each
|
|
264
265
|
* object named, the pack's or the repo's, is of the type its link says, as `repoTypes` reads the
|
|
265
266
|
* repo's. A delta whose base the indexer no longer holds is indexed again once the pack is stored.
|
|
266
|
-
* Its `.idx`, `.rev`, `.pos`, `.graph` and `.types` go
|
|
267
|
+
* Its `.idx`, `.rev`, `.pos`, `.graph` and `.types` go beside its put's landing, which any read of
|
|
268
|
+
* the stored pack waits for, then its row is read again, as
|
|
267
269
|
* `stillOpen` says. A refused pack's runs, then its marker, files and row, are deleted before the
|
|
268
270
|
* refusal, as `dropRefused` says. Runs it can't delete keep the row, so clean-up ends them at its
|
|
269
271
|
* `removeAt`.
|
|
@@ -354,6 +356,8 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
354
356
|
const reader = packReader(reading);
|
|
355
357
|
const counted = yield* requestCount;
|
|
356
358
|
const upload = step === void 0 ? yield* startUpload(bucket, files.pack, receive) : void 0;
|
|
359
|
+
let landed = Effect.void;
|
|
360
|
+
const storedEntry = (pack, offset, before) => Effect.andThen(landed, reader.blocks.entryAt(pack, offset, before));
|
|
357
361
|
const recordOf = (oid) => {
|
|
358
362
|
const slot = state.table?.find(oid);
|
|
359
363
|
return slot === void 0 || state.table?.awaitedAt(slot) !== void 0 ? void 0 : slot;
|
|
@@ -447,7 +451,8 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
447
451
|
entryAt: (offset, before) => {
|
|
448
452
|
if (state.stored === void 0 || state.sweepAt !== void 0 && offset !== state.sweepAt) return deferring;
|
|
449
453
|
const most = state.checksMost;
|
|
450
|
-
|
|
454
|
+
if (most !== void 0 && counted !== void 0 && !reader.blocks.keeps(state.stored, offset) && counted.made().bucket >= most.made) return Effect.fail(checksTooLarge(most.left));
|
|
455
|
+
return storedEntry(state.stored, offset, before);
|
|
451
456
|
},
|
|
452
457
|
offsetOf: (oid) => {
|
|
453
458
|
const slot = recordOf(oid);
|
|
@@ -801,7 +806,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
801
806
|
const indexed = Effect.gen(function* () {
|
|
802
807
|
const limits = step === void 0 ? receiveLimits : limited?.reader ?? stepLimits;
|
|
803
808
|
const read = yield* readPackFrom(teed, hasher, sink, limits, meter, resume).pipe(Effect.mapError((error) => error instanceof DeltaError ? malformedDelta(error) : readFailure(error)), Effect.ensuring(body.cancel));
|
|
804
|
-
if (upload !== void 0 && !("paused" in read)) yield* upload.finish(read.bytes);
|
|
809
|
+
if (upload !== void 0 && !("paused" in read)) landed = yield* upload.finish(read.bytes);
|
|
805
810
|
return read;
|
|
806
811
|
}).pipe(Effect.onError(() => upload?.abort ?? Effect.void));
|
|
807
812
|
/**
|
|
@@ -817,7 +822,7 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
817
822
|
state.stored = pack;
|
|
818
823
|
/** A deferred entry read again in a sweep: its header, its data, then its end as it streamed. */
|
|
819
824
|
const sweepEntry = Effect.fnUntraced(function* (row) {
|
|
820
|
-
const entry = yield*
|
|
825
|
+
const entry = yield* storedEntry(pack, row.offset, (each) => memory.outside(each.size));
|
|
821
826
|
if (entry === "too big") return yield* Effect.fail(refused(row.offset, "too big"));
|
|
822
827
|
const ended = {
|
|
823
828
|
...entry.entry,
|
|
@@ -1039,8 +1044,8 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
1039
1044
|
];
|
|
1040
1045
|
const putsHeld = putting.reduce((sum, [, bytes]) => sum + putHeldBytes(bucket.multipart, { size: bytes.byteLength }), 0);
|
|
1041
1046
|
yield* room.take(putsHeld) ?? Effect.void;
|
|
1042
|
-
yield* Effect.all(putting.map(([key, bytes]) => putFile(key, bytes)), {
|
|
1043
|
-
concurrency:
|
|
1047
|
+
yield* Effect.all([landed, ...putting.map(([key, bytes]) => putFile(key, bytes))], {
|
|
1048
|
+
concurrency: "unbounded",
|
|
1044
1049
|
discard: true
|
|
1045
1050
|
});
|
|
1046
1051
|
room.give(putsHeld);
|
package/dist/storage/packs.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import { defaultRemapCpuMost, indexHolds } from "./index-remap.mjs";
|
|
|
24
24
|
import { putHeldBytes } from "./put-holds.mjs";
|
|
25
25
|
import { indexRowKey, isPackId, packFiles, prunePassKey } from "./layout.mjs";
|
|
26
26
|
import { ReachCache, indexReach, reachCacheBytes, reachedRoots } from "./index-reach.mjs";
|
|
27
|
-
import { IndexStepFiles, indexStepFilesMost } from "./index-step-files.mjs";
|
|
27
|
+
import { IndexStepFiles, indexStepBlocksMost, indexStepFilesMost, packBlockKeeps } from "./index-step-files.mjs";
|
|
28
28
|
import { indexedVisible, setReachOf } from "./index-visible.mjs";
|
|
29
29
|
import { PackIndexes, packReader, seedBytes } from "./pack-reads.mjs";
|
|
30
30
|
import { maintainBatches, withBatchesDue } from "./batch-upkeep.mjs";
|
|
@@ -633,6 +633,8 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
633
633
|
const reaches = new ReachCache(instanceRoomOf(budget, reachCacheBytes));
|
|
634
634
|
/** The index files a build's chained steps read again, kept from one step to the next (#596). */
|
|
635
635
|
const stepFiles = new IndexStepFiles(instanceRoomOf(budget, indexStepFilesMost));
|
|
636
|
+
/** The blocks of its packs its read steps read again, for bases outside each slice (#596). */
|
|
637
|
+
const stepBlocks = new IndexStepFiles(instanceRoomOf(budget, indexStepBlocksMost), indexStepBlocksMost, packBlockKeeps);
|
|
636
638
|
/** What a reach on the index reads through: a want check's, and a visible set's. */
|
|
637
639
|
const reachParts = {
|
|
638
640
|
bucket,
|
|
@@ -1376,7 +1378,7 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
1376
1378
|
...visible === void 0 && { copyRows: (listed, input) => copyRowsPage(calls, listed, input) },
|
|
1377
1379
|
index: {
|
|
1378
1380
|
step: (listed, input) => {
|
|
1379
|
-
const kept = stepFiles.over(bucket, listed.repo);
|
|
1381
|
+
const kept = stepBlocks.over(stepFiles.over(bucket, listed.repo), listed.repo);
|
|
1380
1382
|
const raw = {
|
|
1381
1383
|
store: base.store,
|
|
1382
1384
|
bucket: kept
|
|
@@ -1402,7 +1404,10 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
1402
1404
|
return own === void 0 ? step : Effect.provideService(step, CallBudget, own);
|
|
1403
1405
|
};
|
|
1404
1406
|
const step = stepMost === void 0 ? counted(void 0) : Effect.flatMap(indexBudget(input, stepMost), counted);
|
|
1405
|
-
return Effect.onExit(step, (exit) => Exit.isSuccess(exit) && exit.value.kind === "more" ? Effect.void : Effect.sync(() =>
|
|
1407
|
+
return Effect.onExit(step, (exit) => Exit.isSuccess(exit) && exit.value.kind === "more" ? Effect.void : Effect.sync(() => {
|
|
1408
|
+
stepFiles.clear();
|
|
1409
|
+
stepBlocks.clear();
|
|
1410
|
+
}));
|
|
1406
1411
|
},
|
|
1407
1412
|
reach: (listed, input) => {
|
|
1408
1413
|
const built = indexReach(reachParts, listed, input);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ref0/git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Git hosting as a library: a server, a client and their merges",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@ref0/infra": "0.
|
|
54
|
+
"@ref0/infra": "0.34.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@effect/vitest": "4.1.7",
|
|
58
|
-
"@ref0/xdiff-wasm": "0.
|
|
58
|
+
"@ref0/xdiff-wasm": "0.34.0",
|
|
59
59
|
"effect": "4.1.7",
|
|
60
60
|
"vite-plus": "1.8.0",
|
|
61
61
|
"vitest": "5.1.1",
|