@ref0/git 0.31.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.
|
@@ -1537,14 +1537,15 @@ const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files,
|
|
|
1537
1537
|
const callsFit = counted === void 0 || madeCalls === void 0 || directNeeds <= counted.most.bucket - madeCalls.bucket && directNeeds <= counted.most.subrequests - madeCalls.subrequests;
|
|
1538
1538
|
const putBuffer = putHeldBytes(parts.bucket.multipart, { atMost });
|
|
1539
1539
|
if (callsFit && (putBuffer === 0 || allotment.tryGrow(putBuffer))) return yield* Effect.ensuring(Effect.gen(function* () {
|
|
1540
|
-
const already = yield* storedSize(parts.bucket, files.bitmaps);
|
|
1540
|
+
const already = chained ? void 0 : yield* storedSize(parts.bucket, files.bitmaps);
|
|
1541
1541
|
const written = already === void 0 ? yield* Effect.scoped(Effect.gen(function* () {
|
|
1542
1542
|
const bitmaps = partBitmaps(into.finish());
|
|
1543
1543
|
if (bitmaps?.length !== into.count) return yield* Effect.fail(lost(`${files.bitmaps} part buffer is unreadable`));
|
|
1544
1544
|
const put = yield* bitmapsPut(parts.bucket, files.bitmaps, input.positions, into.count);
|
|
1545
1545
|
for (const bitmap of bitmaps) yield* put.addBytes(bitmap.position, bitmap.number, bitmap.bytes);
|
|
1546
1546
|
return yield* put.finish;
|
|
1547
|
-
})) : yield* storedBitmaps(parts.bucket, files.bitmaps, input.positions, already);
|
|
1547
|
+
})).pipe(Effect.catchIf(alreadyThere, () => Effect.succeed(void 0))) : yield* storedBitmaps(parts.bucket, files.bitmaps, input.positions, already);
|
|
1548
|
+
if (written === void 0) return data;
|
|
1548
1549
|
const { bitmapsCut: _, ...rest } = data;
|
|
1549
1550
|
return {
|
|
1550
1551
|
...rest,
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { bucketBodyIn, joined } from "./calls.mjs";
|
|
2
|
+
import { blockBytes } from "./pack-reads.mjs";
|
|
3
|
+
import { replayPieceBytes } from "./range-cache.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Stream from "effect/Stream";
|
|
6
|
+
import * as Exit from "effect/Exit";
|
|
7
|
+
// src/storage/index-step-files.ts
|
|
8
|
+
/**
|
|
9
|
+
* The most a repo's index build keeps of its index files between its steps, 16 MiB. svelte's
|
|
10
|
+
* first build, 91,275 objects, reads about 10 MiB of them over its 10 chained steps, and about
|
|
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.
|
|
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);
|
|
21
|
+
/** A pack's own index file, as `packFiles` names it: `packs/<ID>.idx` and its kin. */
|
|
22
|
+
const packIndexFile = /^packs\/[^/]+\.(?:idx|pos|rev|graph|types)$/;
|
|
23
|
+
/** A pack's bytes, as `packFiles` names them. */
|
|
24
|
+
const packBody = /^packs\/[^/]+\.pack$/;
|
|
25
|
+
/**
|
|
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.
|
|
30
|
+
*/
|
|
31
|
+
const indexFileKeeps = {
|
|
32
|
+
put: (key) => key.startsWith("index/") || packIndexFile.test(key),
|
|
33
|
+
read: (key) => packIndexFile.test(key)
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
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.
|
|
38
|
+
*/
|
|
39
|
+
const packBlockKeeps = {
|
|
40
|
+
put: () => false,
|
|
41
|
+
read: (key, range) => packBody.test(key) && range !== void 0 && range.offset % 1048576 === 0 && range.length <= 1048576
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* `kept`'s bytes from `from` to `to`, `replayPieceBytes` a piece, each its own copy read from them
|
|
45
|
+
* as it's pulled, so no reader changes another's. Bytes let go mid-way are no longer held here:
|
|
46
|
+
* the rest comes from `bucket`, read in `context` once pulled.
|
|
47
|
+
*/
|
|
48
|
+
const replayed = (context, bucket, kept, from, to) => {
|
|
49
|
+
let at = from;
|
|
50
|
+
let rest;
|
|
51
|
+
return new ReadableStream({
|
|
52
|
+
pull: async (controller) => {
|
|
53
|
+
if (rest === void 0) {
|
|
54
|
+
const { bytes } = kept;
|
|
55
|
+
if (at === to) return controller.close();
|
|
56
|
+
if (bytes !== void 0) {
|
|
57
|
+
const end = Math.min(at + replayPieceBytes, to);
|
|
58
|
+
controller.enqueue(bytes.slice(at, end));
|
|
59
|
+
at = end;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const range = {
|
|
63
|
+
offset: kept.offset + at,
|
|
64
|
+
length: to - at
|
|
65
|
+
};
|
|
66
|
+
rest = bucketBodyIn(context, bucket, kept.key, range).getReader();
|
|
67
|
+
}
|
|
68
|
+
const next = await rest.read();
|
|
69
|
+
if (next.done) controller.close();
|
|
70
|
+
else controller.enqueue(next.value);
|
|
71
|
+
},
|
|
72
|
+
cancel: (reason) => rest?.cancel(reason)
|
|
73
|
+
}, { highWaterMark: 0 });
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
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).
|
|
80
|
+
*
|
|
81
|
+
* A step reads through `over`'s bucket. A read of a kept file, or of a range inside a kept one,
|
|
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`,
|
|
84
|
+
* all of it when the room shrinks, and a removed key is let go. A step for another repo, or
|
|
85
|
+
* `clear`, lets everything go: the cache holds one build's files at a time.
|
|
86
|
+
*/
|
|
87
|
+
var IndexStepFiles = class {
|
|
88
|
+
#charge;
|
|
89
|
+
most;
|
|
90
|
+
/** Least recently used first. */
|
|
91
|
+
#kept = /* @__PURE__ */ new Map();
|
|
92
|
+
#byKey = /* @__PURE__ */ new Map();
|
|
93
|
+
/** What kept entries are charged, and reads and puts under way that may keep theirs. */
|
|
94
|
+
#held = 0;
|
|
95
|
+
#filling = 0;
|
|
96
|
+
/** Each fill under way, by what lets its copies go: everything let go lets them go too. */
|
|
97
|
+
#fills = /* @__PURE__ */ new Set();
|
|
98
|
+
#repo;
|
|
99
|
+
#keeps;
|
|
100
|
+
/** `keeps`: what it keeps, a build's index files unless it says. */
|
|
101
|
+
constructor(charge, most = indexStepFilesMost, keeps = indexFileKeeps) {
|
|
102
|
+
this.#charge = charge;
|
|
103
|
+
this.most = most;
|
|
104
|
+
this.#keeps = keeps;
|
|
105
|
+
charge.watch(() => this.#letGo(false));
|
|
106
|
+
}
|
|
107
|
+
/** What it holds now: kept entries and fills under way, as charged. */
|
|
108
|
+
get held() {
|
|
109
|
+
return this.#held + this.#filling;
|
|
110
|
+
}
|
|
111
|
+
/** `bucket`, for a step of `repo`'s build: a step of another repo's lets the last one's go. */
|
|
112
|
+
over(bucket, repo) {
|
|
113
|
+
if (this.#repo !== repo) {
|
|
114
|
+
this.#letGo(true);
|
|
115
|
+
this.#repo = repo;
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
...bucket,
|
|
119
|
+
read: (key, range) => Effect.suspend(() => {
|
|
120
|
+
const found = this.#replay(key, range);
|
|
121
|
+
if (found !== void 0) return Effect.map(Effect.context(), (context) => replayed(context, bucket, found.kept, found.from, found.to));
|
|
122
|
+
if (!this.#keeps.read(key, range)) return bucket.read(key, range);
|
|
123
|
+
return Effect.map(bucket.read(key, range), (body) => this.#teed(key, range, body));
|
|
124
|
+
}),
|
|
125
|
+
put: (key, body, options) => Effect.suspend(() => {
|
|
126
|
+
if (!this.#keeps.put(key)) return bucket.put(key, body, options);
|
|
127
|
+
const fill = this.#fill(options?.size);
|
|
128
|
+
if (fill === void 0) return bucket.put(key, body, options);
|
|
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())));
|
|
130
|
+
}),
|
|
131
|
+
remove: (key) => Effect.andThen(Effect.sync(() => this.#forget(key)), bucket.remove(key)),
|
|
132
|
+
removeMany: (keys, options) => Effect.andThen(Effect.sync(() => keys.forEach((key) => this.#forget(key))), bucket.removeMany(keys, options))
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/** Lets every kept file go, its charge given back: the build's end. */
|
|
136
|
+
clear() {
|
|
137
|
+
this.#letGo(true);
|
|
138
|
+
this.#repo = void 0;
|
|
139
|
+
}
|
|
140
|
+
/** The kept entry answering `range` of `key`, made the most recent, and where in it, or `undefined`. */
|
|
141
|
+
#replay(key, range) {
|
|
142
|
+
for (const kept of this.#byKey.get(key) ?? []) {
|
|
143
|
+
const from = (range?.offset ?? 0) - kept.offset;
|
|
144
|
+
const to = range === void 0 ? kept.size : from + range.length;
|
|
145
|
+
if (!(range === void 0 ? kept.whole : from >= 0 && to <= kept.size)) continue;
|
|
146
|
+
this.#kept.delete(kept.id);
|
|
147
|
+
this.#kept.set(kept.id, kept);
|
|
148
|
+
return {
|
|
149
|
+
kept,
|
|
150
|
+
from,
|
|
151
|
+
to
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** `body`, read through: kept once it ends at `range`'s length, or whole for no range. */
|
|
156
|
+
#teed(key, range, body) {
|
|
157
|
+
const fill = this.#fill(range?.length);
|
|
158
|
+
if (fill === void 0) return body;
|
|
159
|
+
const reader = body.getReader();
|
|
160
|
+
return new ReadableStream({
|
|
161
|
+
pull: async (controller) => {
|
|
162
|
+
const next = await reader.read().catch((cause) => {
|
|
163
|
+
fill.drop();
|
|
164
|
+
throw cause;
|
|
165
|
+
});
|
|
166
|
+
if (next.done) {
|
|
167
|
+
fill.end(key, range?.offset, range?.length);
|
|
168
|
+
return controller.close();
|
|
169
|
+
}
|
|
170
|
+
controller.enqueue(fill.add(next.value));
|
|
171
|
+
},
|
|
172
|
+
cancel: (reason) => {
|
|
173
|
+
fill.drop();
|
|
174
|
+
return reader.cancel(reason);
|
|
175
|
+
}
|
|
176
|
+
}, { highWaterMark: 0 });
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* One read's or put's bytes as they pass, charged as they come, or at once for a known `size`:
|
|
180
|
+
* `undefined` when even that doesn't fit. `add` copies each piece while it fits, into one block of
|
|
181
|
+
* a known `size`, `end` keeps them when they came to `size`, and `drop` lets them go. One that
|
|
182
|
+
* everything let go under keeps nothing, its copies gone at once and its charge given back with
|
|
183
|
+
* the rest.
|
|
184
|
+
*/
|
|
185
|
+
#fill(size) {
|
|
186
|
+
let charged = 0;
|
|
187
|
+
let open = true;
|
|
188
|
+
let block;
|
|
189
|
+
let pieces;
|
|
190
|
+
let got = 0;
|
|
191
|
+
const abandon = () => {
|
|
192
|
+
open = false;
|
|
193
|
+
block = void 0;
|
|
194
|
+
pieces = void 0;
|
|
195
|
+
};
|
|
196
|
+
const charge = (bytes) => {
|
|
197
|
+
if (!this.#reserve(bytes)) return false;
|
|
198
|
+
charged += bytes;
|
|
199
|
+
return true;
|
|
200
|
+
};
|
|
201
|
+
const drop = () => {
|
|
202
|
+
if (!open) return;
|
|
203
|
+
abandon();
|
|
204
|
+
this.#fills.delete(abandon);
|
|
205
|
+
this.#filling -= charged;
|
|
206
|
+
this.#charge.shrink(charged);
|
|
207
|
+
};
|
|
208
|
+
if (!charge(320 + (size ?? 0))) return void 0;
|
|
209
|
+
if (size === void 0) pieces = [];
|
|
210
|
+
else block = new Uint8Array(size);
|
|
211
|
+
this.#fills.add(abandon);
|
|
212
|
+
return {
|
|
213
|
+
add: (piece) => {
|
|
214
|
+
if (!open) return piece;
|
|
215
|
+
const at = got;
|
|
216
|
+
got += piece.byteLength;
|
|
217
|
+
if (block !== void 0) {
|
|
218
|
+
if (got > block.byteLength) drop();
|
|
219
|
+
else block.set(piece, at);
|
|
220
|
+
} else if (!charge(piece.byteLength)) drop();
|
|
221
|
+
else pieces?.push(piece.slice());
|
|
222
|
+
return piece;
|
|
223
|
+
},
|
|
224
|
+
drop,
|
|
225
|
+
end: (key, offset, length) => {
|
|
226
|
+
if (!open) return;
|
|
227
|
+
if (length !== void 0 && got !== length || size !== void 0 && got !== size) return drop();
|
|
228
|
+
let bytes = block;
|
|
229
|
+
if (bytes === void 0) {
|
|
230
|
+
if (!charge(got)) return drop();
|
|
231
|
+
bytes = joined(pieces ?? []);
|
|
232
|
+
pieces = void 0;
|
|
233
|
+
charged -= got;
|
|
234
|
+
this.#filling -= got;
|
|
235
|
+
this.#charge.shrink(got);
|
|
236
|
+
}
|
|
237
|
+
abandon();
|
|
238
|
+
this.#fills.delete(abandon);
|
|
239
|
+
this.#filling -= charged;
|
|
240
|
+
this.#keep({
|
|
241
|
+
id: `${key}@${offset ?? "whole"}+${got}`,
|
|
242
|
+
key,
|
|
243
|
+
offset: offset ?? 0,
|
|
244
|
+
bytes,
|
|
245
|
+
size: got,
|
|
246
|
+
whole: offset === void 0,
|
|
247
|
+
cost: charged
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Room for `bytes` more within `most`, the least recent let go first, then the charge's grow. What
|
|
254
|
+
* fills now can't make room, so bytes past `most` with it let nothing go.
|
|
255
|
+
*/
|
|
256
|
+
#reserve(bytes) {
|
|
257
|
+
if (this.#filling + bytes > this.most) return false;
|
|
258
|
+
for (const [, oldest] of this.#kept) {
|
|
259
|
+
if (this.#held + this.#filling + bytes <= this.most) break;
|
|
260
|
+
this.#remove(oldest, true);
|
|
261
|
+
}
|
|
262
|
+
if (this.#held + this.#filling + bytes > this.most || !this.#charge.tryGrow(bytes)) return false;
|
|
263
|
+
this.#filling += bytes;
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
/** `kept`, its charge moved from filling to held: one already there with its ID is let go. */
|
|
267
|
+
#keep(kept) {
|
|
268
|
+
const prior = this.#kept.get(kept.id);
|
|
269
|
+
if (prior !== void 0) this.#remove(prior, true);
|
|
270
|
+
this.#kept.set(kept.id, kept);
|
|
271
|
+
this.#byKey.set(kept.key, [...this.#byKey.get(kept.key) ?? [], kept]);
|
|
272
|
+
this.#held += kept.cost;
|
|
273
|
+
}
|
|
274
|
+
/** `kept` let go: a replay of it under way reads the rest from the bucket. */
|
|
275
|
+
#remove(kept, release) {
|
|
276
|
+
if (!this.#kept.delete(kept.id)) return;
|
|
277
|
+
kept.bytes = void 0;
|
|
278
|
+
this.#held -= kept.cost;
|
|
279
|
+
if (release) this.#charge.shrink(kept.cost);
|
|
280
|
+
const left = (this.#byKey.get(kept.key) ?? []).filter((each) => each !== kept);
|
|
281
|
+
if (left.length === 0) this.#byKey.delete(kept.key);
|
|
282
|
+
else this.#byKey.set(kept.key, left);
|
|
283
|
+
}
|
|
284
|
+
/** `key`'s kept bytes let go, for a removed file. */
|
|
285
|
+
#forget(key) {
|
|
286
|
+
for (const kept of this.#byKey.get(key) ?? []) this.#remove(kept, true);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Everything let go, kept and filling, a fill's copies and a replay's bytes included, its charge
|
|
290
|
+
* given back unless a shrink took it.
|
|
291
|
+
*/
|
|
292
|
+
#letGo(release) {
|
|
293
|
+
const charged = this.#held + this.#filling;
|
|
294
|
+
for (const abandon of this.#fills) abandon();
|
|
295
|
+
for (const kept of this.#kept.values()) kept.bytes = void 0;
|
|
296
|
+
this.#fills.clear();
|
|
297
|
+
this.#kept.clear();
|
|
298
|
+
this.#byKey.clear();
|
|
299
|
+
this.#held = 0;
|
|
300
|
+
this.#filling = 0;
|
|
301
|
+
if (release && charged > 0) this.#charge.shrink(charged);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
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,6 +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, indexStepBlocksMost, indexStepFilesMost, packBlockKeeps } from "./index-step-files.mjs";
|
|
27
28
|
import { indexedVisible, setReachOf } from "./index-visible.mjs";
|
|
28
29
|
import { PackIndexes, packReader, seedBytes } from "./pack-reads.mjs";
|
|
29
30
|
import { maintainBatches, withBatchesDue } from "./batch-upkeep.mjs";
|
|
@@ -628,11 +629,17 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
628
629
|
* with the scope.
|
|
629
630
|
*/
|
|
630
631
|
const objectsAt = (listed, on, handles) => Effect.map(Effect.acquireRelease(openReader(listed, on, void 0, void 0, handles), (reader) => Effect.sync(() => reader.close())), (reader) => (oid) => reader.read({ oid }));
|
|
632
|
+
/** The tips' reaches a read walked, for tips with no stored bitmap yet. */
|
|
633
|
+
const reaches = new ReachCache(instanceRoomOf(budget, reachCacheBytes));
|
|
634
|
+
/** The index files a build's chained steps read again, kept from one step to the next (#596). */
|
|
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);
|
|
631
638
|
/** What a reach on the index reads through: a want check's, and a visible set's. */
|
|
632
639
|
const reachParts = {
|
|
633
640
|
bucket,
|
|
634
641
|
budget,
|
|
635
|
-
cache:
|
|
642
|
+
cache: reaches,
|
|
636
643
|
objects: (listed) => objectsAt(listed, { read: true }),
|
|
637
644
|
indexes
|
|
638
645
|
};
|
|
@@ -1371,12 +1378,13 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
1371
1378
|
...visible === void 0 && { copyRows: (listed, input) => copyRowsPage(calls, listed, input) },
|
|
1372
1379
|
index: {
|
|
1373
1380
|
step: (listed, input) => {
|
|
1381
|
+
const kept = stepBlocks.over(stepFiles.over(bucket, listed.repo), listed.repo);
|
|
1374
1382
|
const raw = {
|
|
1375
1383
|
store: base.store,
|
|
1376
|
-
bucket
|
|
1384
|
+
bucket: kept
|
|
1377
1385
|
};
|
|
1378
1386
|
const unbounded = {
|
|
1379
|
-
bucket,
|
|
1387
|
+
bucket: kept,
|
|
1380
1388
|
store: base.store,
|
|
1381
1389
|
budget,
|
|
1382
1390
|
objects: (at, allotment, handles) => objectsAt(at, { upkeep: allotment }, handles)
|
|
@@ -1395,7 +1403,11 @@ const packsWith = (options = {}, inner = {}) => {
|
|
|
1395
1403
|
}, listed, input).pipe(Effect.tap((answer) => answer.kind === "moved" && own !== void 0 ? countInto(own, "store", 1) : Effect.void));
|
|
1396
1404
|
return own === void 0 ? step : Effect.provideService(step, CallBudget, own);
|
|
1397
1405
|
};
|
|
1398
|
-
|
|
1406
|
+
const step = stepMost === void 0 ? counted(void 0) : Effect.flatMap(indexBudget(input, stepMost), counted);
|
|
1407
|
+
return Effect.onExit(step, (exit) => Exit.isSuccess(exit) && exit.value.kind === "more" ? Effect.void : Effect.sync(() => {
|
|
1408
|
+
stepFiles.clear();
|
|
1409
|
+
stepBlocks.clear();
|
|
1410
|
+
}));
|
|
1399
1411
|
},
|
|
1400
1412
|
reach: (listed, input) => {
|
|
1401
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",
|