@ref0/git 0.25.0 → 0.27.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/contracts/objects.d.mts +10 -1
- package/dist/contracts/rules.d.mts +11 -10
- package/dist/core/push.mjs +20 -4
- package/dist/core/rules/commit-changes.mjs +113 -45
- package/dist/protocol/bytes/buffers.mjs +26 -1
- package/dist/protocol/bytes/inflate.d.mts +11 -6
- package/dist/protocol/bytes/inflate.mjs +184 -119
- package/dist/protocol/bytes/zlib-ng/LICENSE.md +19 -0
- package/dist/protocol/bytes/zlib-ng/README.md +105 -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 +8 -0
- package/dist/protocol/bytes/zlib-ng/compile.mjs +18 -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 +105 -0
- package/dist/protocol/bytes/zlib-ng/zlib-ng.wasm +0 -0
- package/dist/protocol/packs/reader.mjs +35 -30
- package/dist/storage/budget.d.mts +1 -0
- package/dist/storage/budget.mjs +1 -15
- package/dist/storage/held-types.mjs +13 -4
- package/dist/storage/index-bitmaps.mjs +263 -16
- package/dist/storage/index-build.mjs +28 -9
- package/dist/storage/loose.mjs +2 -1
- package/dist/storage/memory-budget.d.mts +1 -0
- package/dist/storage/merge-most.mjs +2 -1
- package/dist/storage/pack-reads.mjs +1 -1
- package/dist/storage/pack-receive.mjs +3 -1
- package/dist/storage/packs-memory.mjs +2 -1
- package/dist/storage/packs.mjs +2 -1
- package/package.json +12 -3
|
@@ -312,6 +312,225 @@ const partBytesMost = uploadPartBytes;
|
|
|
312
312
|
/** A bitmap's entry in a part: its position, its number and its EWAH's bytes. */
|
|
313
313
|
const partEntryBytes = 12;
|
|
314
314
|
/**
|
|
315
|
+
* Preferred byte budget for earlier bitmaps-part footer tables held at once by `PriorParts` in a
|
|
316
|
+
* multi-part whole build: each entry takes 16 bytes (12-byte footer entry plus 4-byte offset), so
|
|
317
|
+
* 1 MiB holds about 65,000 entries (~40 full 8 MiB parts). `room` is
|
|
318
|
+
* `min(totalFooters, max(priorFootersMost, largestFooter))`, so `room` can exceed 1 MiB up to the
|
|
319
|
+
* single largest part's footer (strictly below `partBytesMost`, 8 MiB, since each entry needs 12
|
|
320
|
+
* footer bytes plus at least 4 payload bytes, bounding `n <= floor((8 MiB - 4) / 16)` and
|
|
321
|
+
* `16n + 4 < 8 MiB`), and is always charged alongside `priorLookupBytes` before allocation.
|
|
322
|
+
*/
|
|
323
|
+
const priorFootersMost = 1048576;
|
|
324
|
+
/** Bytes `PriorParts` holds for one part's footer table: raw entries + count, plus prefix offsets. */
|
|
325
|
+
const priorFooterBytes = (count) => count * 16 + 4;
|
|
326
|
+
/**
|
|
327
|
+
* Bytes `PriorParts` holds for its sorted position lookup (`Uint32Array` positions and order
|
|
328
|
+
* indices, 8 bytes per completed bitmap) plus cumulative part counts (`Uint32Array`, 4 bytes per
|
|
329
|
+
* earlier part). For 2,157 bitmaps across 2 parts that is ~17 KiB; even if all 1,000,000 objects
|
|
330
|
+
* in a 1,000,000-object repo were chosen across 128 parts, it is 8,000,512 bytes (~7.63 MiB),
|
|
331
|
+
* computed and charged before allocation and released on exit.
|
|
332
|
+
*/
|
|
333
|
+
const priorLookupBytes = (parts, bitmaps) => bitmaps * 8 + parts * 4;
|
|
334
|
+
/** Memory reservation `PriorParts` needs before construction: lookup tables plus footer LRU room. */
|
|
335
|
+
const priorPartsRoom = (parts, most) => {
|
|
336
|
+
if (parts.length === 0) return {
|
|
337
|
+
lookup: 0,
|
|
338
|
+
footers: 0,
|
|
339
|
+
total: 0
|
|
340
|
+
};
|
|
341
|
+
let bitmaps = 0;
|
|
342
|
+
let totalFooters = 0;
|
|
343
|
+
let largestFooter = 0;
|
|
344
|
+
for (const part of parts) {
|
|
345
|
+
bitmaps += part.count;
|
|
346
|
+
const footerSize = priorFooterBytes(part.count);
|
|
347
|
+
totalFooters += footerSize;
|
|
348
|
+
largestFooter = Math.max(largestFooter, footerSize);
|
|
349
|
+
}
|
|
350
|
+
const lookup = priorLookupBytes(parts.length, bitmaps);
|
|
351
|
+
const footers = Math.min(totalFooters, Math.max(most, largestFooter));
|
|
352
|
+
return {
|
|
353
|
+
lookup,
|
|
354
|
+
footers,
|
|
355
|
+
total: lookup + footers
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
/** Sorts parallel `keys` and `values` ascending by `keys` in place with O(1) extra space. */
|
|
359
|
+
const sortPairs = (keys, values) => {
|
|
360
|
+
const length = keys.length;
|
|
361
|
+
const swap = (a, b) => {
|
|
362
|
+
const key = keys[a] ?? 0;
|
|
363
|
+
keys[a] = keys[b] ?? 0;
|
|
364
|
+
keys[b] = key;
|
|
365
|
+
const value = values[a] ?? 0;
|
|
366
|
+
values[a] = values[b] ?? 0;
|
|
367
|
+
values[b] = value;
|
|
368
|
+
};
|
|
369
|
+
const siftDown = (start, end) => {
|
|
370
|
+
let root = start;
|
|
371
|
+
while (root * 2 + 1 < end) {
|
|
372
|
+
const left = root * 2 + 1;
|
|
373
|
+
const right = left + 1;
|
|
374
|
+
let largest = root;
|
|
375
|
+
if ((keys[left] ?? 0) > (keys[largest] ?? 0)) largest = left;
|
|
376
|
+
if (right < end && (keys[right] ?? 0) > (keys[largest] ?? 0)) largest = right;
|
|
377
|
+
if (largest === root) return;
|
|
378
|
+
swap(root, largest);
|
|
379
|
+
root = largest;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
for (let start = Math.floor(length / 2) - 1; start >= 0; start -= 1) siftDown(start, length);
|
|
383
|
+
for (let end = length - 1; end > 0; end -= 1) {
|
|
384
|
+
swap(0, end);
|
|
385
|
+
siftDown(0, end);
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* Reads bitmaps written by earlier parts of a multi-part whole build on demand, holding at most
|
|
390
|
+
* `room` bytes of part footer tables in LRU order (`room` can exceed `most`, up to the single
|
|
391
|
+
* largest part's footer, strictly below `partBytesMost`) and `lookupBytes` of typed lookup tables.
|
|
392
|
+
* Each part's footer is read once per cache residency (one size lookup plus one suffix range read;
|
|
393
|
+
* eviction permits rereads) and each needed bitmap takes one small range read, avoiding a full
|
|
394
|
+
* graph re-walk through all edges files on every later part.
|
|
395
|
+
*/
|
|
396
|
+
var PriorParts = class {
|
|
397
|
+
#bucket;
|
|
398
|
+
#parts;
|
|
399
|
+
#positions;
|
|
400
|
+
#orderIndices;
|
|
401
|
+
#partEnds;
|
|
402
|
+
#held = /* @__PURE__ */ new Map();
|
|
403
|
+
#bytes = 0;
|
|
404
|
+
/** The bytes held by the typed position lookup and cumulative part-count arrays. */
|
|
405
|
+
lookupBytes;
|
|
406
|
+
/** The most bytes of footer tables it holds at once (may exceed `most`, up to largest footer). */
|
|
407
|
+
room;
|
|
408
|
+
/** Part footers read, for tests to count. */
|
|
409
|
+
footerReads = 0;
|
|
410
|
+
/** Individual bitmaps range-read from earlier parts, for tests to count. */
|
|
411
|
+
bitmapReads = 0;
|
|
412
|
+
constructor(bucket, parts, order, most) {
|
|
413
|
+
this.#bucket = bucket;
|
|
414
|
+
this.#parts = parts;
|
|
415
|
+
const plan = priorPartsRoom(parts, most);
|
|
416
|
+
this.lookupBytes = plan.lookup;
|
|
417
|
+
this.room = plan.footers;
|
|
418
|
+
this.#partEnds = new Uint32Array(parts.length);
|
|
419
|
+
let at = 0;
|
|
420
|
+
for (const [partNumber, part] of parts.entries()) {
|
|
421
|
+
at += part.count;
|
|
422
|
+
this.#partEnds[partNumber] = at;
|
|
423
|
+
}
|
|
424
|
+
const count = Math.min(at, order.length);
|
|
425
|
+
this.#positions = new Uint32Array(count);
|
|
426
|
+
this.#orderIndices = new Uint32Array(count);
|
|
427
|
+
for (let ord = 0; ord < count; ord += 1) {
|
|
428
|
+
this.#positions[ord] = order[ord]?.position ?? 0;
|
|
429
|
+
this.#orderIndices[ord] = ord;
|
|
430
|
+
}
|
|
431
|
+
sortPairs(this.#positions, this.#orderIndices);
|
|
432
|
+
}
|
|
433
|
+
/** The bytes of footer tables held now, for tests to check against `room`. */
|
|
434
|
+
get held() {
|
|
435
|
+
return this.#bytes;
|
|
436
|
+
}
|
|
437
|
+
#orderIndexOf(position) {
|
|
438
|
+
let low = 0;
|
|
439
|
+
let high = this.#positions.length - 1;
|
|
440
|
+
while (low <= high) {
|
|
441
|
+
const mid = low + high >>> 1;
|
|
442
|
+
const value = this.#positions[mid] ?? 0;
|
|
443
|
+
if (value === position) return this.#orderIndices[mid] ?? 0;
|
|
444
|
+
if (value < position) low = mid + 1;
|
|
445
|
+
else high = mid - 1;
|
|
446
|
+
}
|
|
447
|
+
return -1;
|
|
448
|
+
}
|
|
449
|
+
#locate(position) {
|
|
450
|
+
const ord = this.#orderIndexOf(position);
|
|
451
|
+
if (ord === -1) return void 0;
|
|
452
|
+
let low = 0;
|
|
453
|
+
let high = this.#partEnds.length - 1;
|
|
454
|
+
while (low < high) {
|
|
455
|
+
const mid = low + high >>> 1;
|
|
456
|
+
if ((this.#partEnds[mid] ?? 0) <= ord) low = mid + 1;
|
|
457
|
+
else high = mid;
|
|
458
|
+
}
|
|
459
|
+
const start = low === 0 ? 0 : this.#partEnds[low - 1] ?? 0;
|
|
460
|
+
return {
|
|
461
|
+
part: low,
|
|
462
|
+
index: ord - start
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
has(position) {
|
|
466
|
+
return this.#orderIndexOf(position) !== -1;
|
|
467
|
+
}
|
|
468
|
+
read(position) {
|
|
469
|
+
return Effect.suspend(() => {
|
|
470
|
+
const location = this.#locate(position);
|
|
471
|
+
const part = location === void 0 ? void 0 : this.#parts[location.part];
|
|
472
|
+
if (location === void 0 || part === void 0) return Effect.fail(lost(`No prior part holds bitmap position ${position}`));
|
|
473
|
+
return Effect.flatMap(this.#footerOf(location.part, part), (footer) => {
|
|
474
|
+
const entry = location.index * partEntryBytes;
|
|
475
|
+
const storedPosition = footer.view.getUint32(entry);
|
|
476
|
+
if (storedPosition !== position) return Effect.fail(lost(`${part.key}'s entry ${location.index} is position ${storedPosition}, not ${position}`));
|
|
477
|
+
const length = footer.view.getUint32(entry + 8);
|
|
478
|
+
const offset = footer.offsets[location.index] ?? 0;
|
|
479
|
+
return Effect.map(readExactly(this.#bucket, part.key, offset, length), (raw) => {
|
|
480
|
+
this.bitmapReads += 1;
|
|
481
|
+
const ewah = new Uint32Array(length / 4);
|
|
482
|
+
const rawView = new DataView(raw.buffer, raw.byteOffset, raw.byteLength);
|
|
483
|
+
for (let word = 0; word < ewah.length; word += 1) ewah[word] = rawView.getUint32(word * 4);
|
|
484
|
+
return ewah;
|
|
485
|
+
});
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
#footerOf(partNumber, part) {
|
|
490
|
+
return Effect.suspend(() => {
|
|
491
|
+
const cached = this.#held.get(partNumber);
|
|
492
|
+
if (cached !== void 0) {
|
|
493
|
+
this.#held.delete(partNumber);
|
|
494
|
+
this.#held.set(partNumber, cached);
|
|
495
|
+
return Effect.succeed(cached);
|
|
496
|
+
}
|
|
497
|
+
const needed = priorFooterBytes(part.count);
|
|
498
|
+
for (const [heldPart, kept] of this.#held) {
|
|
499
|
+
if (this.#bytes + needed <= this.room) break;
|
|
500
|
+
this.#held.delete(heldPart);
|
|
501
|
+
this.#bytes -= kept.bytes;
|
|
502
|
+
}
|
|
503
|
+
const rawFooterBytes = part.count * partEntryBytes + 4;
|
|
504
|
+
return Effect.flatMap(storedSize(this.#bucket, part.key), (size) => {
|
|
505
|
+
if (size === void 0 || size < rawFooterBytes) return Effect.fail(lost(`${part.key} is missing or cut short`));
|
|
506
|
+
return Effect.flatMap(readExactly(this.#bucket, part.key, size - rawFooterBytes, rawFooterBytes), (bytes) => {
|
|
507
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
508
|
+
const count = view.getUint32(bytes.byteLength - 4);
|
|
509
|
+
if (count !== part.count) return Effect.fail(lost(`${part.key} holds ${count} bitmaps, not ${part.count}`));
|
|
510
|
+
const offsets = new Uint32Array(count);
|
|
511
|
+
let offset = 0;
|
|
512
|
+
for (let at = 0; at < count; at += 1) {
|
|
513
|
+
const length = view.getUint32(at * partEntryBytes + 8);
|
|
514
|
+
if (length % 4 !== 0) return Effect.fail(lost(`${part.key}'s bitmap ${at} has unaligned length`));
|
|
515
|
+
offsets[at] = offset;
|
|
516
|
+
offset += length;
|
|
517
|
+
}
|
|
518
|
+
if (offset !== size - rawFooterBytes) return Effect.fail(lost(`${part.key}'s entries don't fill its bytes`));
|
|
519
|
+
this.footerReads += 1;
|
|
520
|
+
const footer = {
|
|
521
|
+
view,
|
|
522
|
+
offsets,
|
|
523
|
+
bytes: needed
|
|
524
|
+
};
|
|
525
|
+
this.#held.set(partNumber, footer);
|
|
526
|
+
this.#bytes += needed;
|
|
527
|
+
return Effect.succeed(footer);
|
|
528
|
+
});
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
/**
|
|
315
534
|
* One try's part of a whole build's bitmaps, held until it's put: each bitmap's EWAH words,
|
|
316
535
|
* big-endian, as a `.bitmaps` holds them, then each one's position, number and length, then
|
|
317
536
|
* their count. At most `most` bytes.
|
|
@@ -471,6 +690,15 @@ const bitmapsPut = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, pos
|
|
|
471
690
|
};
|
|
472
691
|
});
|
|
473
692
|
/**
|
|
693
|
+
* What `writeBitmaps` grows its allotment by before walking: the walk's buffers (`walkBytes`),
|
|
694
|
+
* the bitmaps it keeps in `made` (`kept`), the streaming put buffer when writing `.bitmaps`
|
|
695
|
+
* directly (not a part), and the layer-below arrays when updating.
|
|
696
|
+
*/
|
|
697
|
+
const bitmapsWalkBytes = (positions, kept, options) => {
|
|
698
|
+
const words = bitmapWords(positions);
|
|
699
|
+
return walkBytes(positions) + kept + (options?.part === true ? 0 : Math.min(bitmapsMostBytes(positions, options?.count ?? 0), uploadPartBytes)) + (options?.below === true ? words * 12 : 0);
|
|
700
|
+
};
|
|
701
|
+
/**
|
|
474
702
|
* A bitmap for each of `input.chosen`, oldest first, each the set of positions its object
|
|
475
703
|
* reaches: forward sweeps over the positions, each taking the links of every set position not
|
|
476
704
|
* yet taken, until one sets nothing behind it. A position with a bitmap already made is ORed
|
|
@@ -480,13 +708,16 @@ const bitmapsPut = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key, pos
|
|
|
480
708
|
* bucket as they're made, the table after them.
|
|
481
709
|
*/
|
|
482
710
|
const writeBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
483
|
-
const { edges, positions, below, part } = input;
|
|
711
|
+
const { edges, positions, below, part, prior } = input;
|
|
484
712
|
const words = bitmapWords(positions);
|
|
485
713
|
const order = bitmapOrder(input.chosen);
|
|
486
714
|
const count = order.length;
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
715
|
+
const held = input.walkReserved === true ? 0 : bitmapsWalkBytes(positions, input.kept, {
|
|
716
|
+
part: part !== void 0,
|
|
717
|
+
below: below !== void 0,
|
|
718
|
+
count
|
|
719
|
+
});
|
|
720
|
+
if (held > 0) yield* input.allotment.grow(held);
|
|
490
721
|
const put = part === void 0 ? yield* bitmapsPut(input.bucket, input.key, positions, count) : void 0;
|
|
491
722
|
const reached = new Uint32Array(words);
|
|
492
723
|
const taken = new Uint32Array(words);
|
|
@@ -501,6 +732,21 @@ const writeBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
501
732
|
let madeBytes = 0;
|
|
502
733
|
let again = false;
|
|
503
734
|
let word = 0;
|
|
735
|
+
const keepMade = (position, ewah) => {
|
|
736
|
+
if (ewah.byteLength > input.kept) return;
|
|
737
|
+
const existing = made.get(position);
|
|
738
|
+
if (existing !== void 0) {
|
|
739
|
+
made.delete(position);
|
|
740
|
+
madeBytes -= existing.byteLength;
|
|
741
|
+
}
|
|
742
|
+
made.set(position, ewah);
|
|
743
|
+
madeBytes += ewah.byteLength;
|
|
744
|
+
for (const [keptPosition, kept] of made) {
|
|
745
|
+
if (madeBytes <= input.kept) break;
|
|
746
|
+
made.delete(keptPosition);
|
|
747
|
+
madeBytes -= kept.byteLength;
|
|
748
|
+
}
|
|
749
|
+
};
|
|
504
750
|
const reach = (target) => {
|
|
505
751
|
const at = target >>> 5;
|
|
506
752
|
const bit = 1 << (target & 31);
|
|
@@ -527,8 +773,15 @@ const writeBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
527
773
|
const closed = yield* below.ready(position);
|
|
528
774
|
if (closed === void 0) waiting[word] = (waiting[word] ?? 0) | 1 << bit;
|
|
529
775
|
else for (const into of closing) orInto(closed, into);
|
|
530
|
-
} else if (stored !== void 0)
|
|
531
|
-
|
|
776
|
+
} else if (stored !== void 0) {
|
|
777
|
+
made.delete(position);
|
|
778
|
+
made.set(position, stored);
|
|
779
|
+
for (const into of closing) orEwah(stored, into);
|
|
780
|
+
} else if (position !== chosen.position && prior?.has(position) === true) {
|
|
781
|
+
const ewah = yield* prior.read(position);
|
|
782
|
+
for (const into of closing) if (!orEwah(ewah, into)) return yield* Effect.fail(lost(`The prior bitmap at ${position} is unreadable`));
|
|
783
|
+
keepMade(position, ewah);
|
|
784
|
+
} else if (!edges.links(position, reach)) {
|
|
532
785
|
yield* edges.load;
|
|
533
786
|
continue;
|
|
534
787
|
}
|
|
@@ -561,26 +814,20 @@ const writeBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
561
814
|
}
|
|
562
815
|
if (!closedAll) {
|
|
563
816
|
if (put !== void 0) yield* put.abort;
|
|
564
|
-
input.allotment.shrink(held);
|
|
817
|
+
if (held > 0) input.allotment.shrink(held);
|
|
565
818
|
return;
|
|
566
819
|
}
|
|
567
820
|
const ewah = ewahOf(reached);
|
|
568
821
|
if (put === void 0) part?.into.add(chosen.position, chosen.number, ewah);
|
|
569
822
|
else yield* put.add(chosen.position, chosen.number, ewah);
|
|
570
|
-
|
|
571
|
-
madeBytes += ewah.byteLength;
|
|
572
|
-
for (const [position, kept] of made) {
|
|
573
|
-
if (madeBytes <= input.kept) break;
|
|
574
|
-
made.delete(position);
|
|
575
|
-
madeBytes -= kept.byteLength;
|
|
576
|
-
}
|
|
823
|
+
keepMade(chosen.position, ewah);
|
|
577
824
|
}
|
|
578
825
|
const written = put === void 0 ? {
|
|
579
826
|
count: part?.into.count ?? 0,
|
|
580
827
|
table: 0,
|
|
581
828
|
bytes: 0
|
|
582
829
|
} : yield* put.finish;
|
|
583
|
-
input.allotment.shrink(held);
|
|
830
|
+
if (held > 0) input.allotment.shrink(held);
|
|
584
831
|
return written;
|
|
585
832
|
}, Effect.scoped);
|
|
586
833
|
/** How many bytes of a layer's `.bitmaps` a merge reads as one range, an entry past it alone. */
|
|
@@ -824,4 +1071,4 @@ const storedBitmaps = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, key,
|
|
|
824
1071
|
bytes: size
|
|
825
1072
|
};
|
|
826
1073
|
});
|
|
827
|
-
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 };
|
|
1074
|
+
export { BitmapsPart, EdgeFiles, PriorParts, bitmapOrder, bitmapsMostBytes, bitmapsPut, bitmapsWalkBytes, copyBitmaps, copyHeldBytes, copyRunBytes, eachBitmapBytes, edgesBytesOf, edgesFileOf, ewahMostWords, isKeepUnclosed, isMergeIncomplete, keepUnclosed, mergeIncomplete, noBase, noNumber, openBitmaps, orderKey, partBitmaps, partBytesMost, priorFooterBytes, priorFootersMost, priorLookupBytes, priorPartsRoom, runGapBytes, runsMost, storedBitmaps, storedSize, walkBytes, writeBitmaps };
|
|
@@ -5,13 +5,14 @@ import { Sha1 } from "../protocol/bytes/sha1.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";
|
|
8
|
+
import { allottableOf } from "../protocol/bytes/buffers.mjs";
|
|
8
9
|
import { noRepoRoots } from "../protocol/objects/commit.mjs";
|
|
9
10
|
import { rawLinks } from "../protocol/objects/links-raw.mjs";
|
|
10
11
|
import { rootsDigest } from "../store/repo-record.mjs";
|
|
11
12
|
import { randomText } from "../store/random.mjs";
|
|
12
|
-
import {
|
|
13
|
+
import { uploadPartBytes } from "./budget.mjs";
|
|
13
14
|
import { bucketDeleteMany, bucketDo, bucketPut, joined, readEach, readWhole, sizedPutCalls, streamedPutCalls } from "./calls.mjs";
|
|
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
|
+
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";
|
|
16
17
|
import { bitmapOf, bitmapWords, ewahOf, orEwah } from "./ewah.mjs";
|
|
17
18
|
import { absent, graphChunk, indexGraphBytes, keptIdsBytes, keptIdsOf, mergeHeldBytes, mergeIndexGraphs, openGraphLayers, openIndexGraph, writeIndexGraph } from "./index-graph.mjs";
|
|
@@ -1493,13 +1494,31 @@ const bitmapsCutTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, files,
|
|
|
1493
1494
|
};
|
|
1494
1495
|
}
|
|
1495
1496
|
const into = new BitmapsPart(partBytesMost);
|
|
1496
|
-
const
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1497
|
+
const walkHeld = bitmapsWalkBytes(input.positions, input.kept, { part: true });
|
|
1498
|
+
yield* allotment.grow(walkHeld);
|
|
1499
|
+
let priorCharged = 0;
|
|
1500
|
+
const made = yield* Effect.ensuring(Effect.gen(function* () {
|
|
1501
|
+
const priorParts = cut.parts.map((held, number) => ({
|
|
1502
|
+
key: files.bitmapsPart(cut.order, number),
|
|
1503
|
+
count: held
|
|
1504
|
+
}));
|
|
1505
|
+
const priorPlan = priorPartsRoom(priorParts, priorFootersMost);
|
|
1506
|
+
if (priorPlan.total > 0 && allotment.tryGrow(priorPlan.total)) priorCharged = priorPlan.total;
|
|
1507
|
+
const prior = priorCharged > 0 ? new PriorParts(input.bucket, priorParts, order, priorFootersMost) : void 0;
|
|
1508
|
+
const writeInput = {
|
|
1509
|
+
...input,
|
|
1510
|
+
part: {
|
|
1511
|
+
from: cut.done,
|
|
1512
|
+
into
|
|
1513
|
+
},
|
|
1514
|
+
walkReserved: true
|
|
1515
|
+
};
|
|
1516
|
+
if (prior !== void 0) writeInput.prior = prior;
|
|
1517
|
+
return yield* Effect.result(cutAtSpent(writeBitmaps(writeInput)));
|
|
1518
|
+
}), Effect.sync(() => {
|
|
1519
|
+
if (priorCharged > 0) allotment.shrink(priorCharged);
|
|
1520
|
+
allotment.shrink(walkHeld);
|
|
1521
|
+
}));
|
|
1503
1522
|
if (Result.isFailure(made)) {
|
|
1504
1523
|
const spent = spentOf(made.failure);
|
|
1505
1524
|
if (spent === void 0) return yield* Effect.fail(made.failure);
|
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";
|
|
@@ -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";
|
|
@@ -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;
|
|
@@ -410,10 +410,12 @@ const storePack = /* @__PURE__ */ Effect.fnUntraced(function* (input, opened, st
|
|
|
410
410
|
const boundary = new Set(joining === void 0 ? receive.boundary : []);
|
|
411
411
|
yield* room.take(boundary.size * 120) ?? Effect.void;
|
|
412
412
|
const named = !partial && new Set(receive.boundary).size === 0;
|
|
413
|
+
const looseRows = receive.hasLooseRows === false ? { hasLooseRows: false } : {};
|
|
413
414
|
const typesHeld = repoTypes({
|
|
414
415
|
...reading,
|
|
415
416
|
memory: memory.join,
|
|
416
|
-
reader
|
|
417
|
+
reader,
|
|
418
|
+
...looseRows
|
|
417
419
|
});
|
|
418
420
|
const linkedTypes = (there) => {
|
|
419
421
|
const types = /* @__PURE__ */ new Map();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { allottableOf, defaultMemory
|
|
1
|
+
import { allottableOf, defaultMemory } from "../protocol/bytes/buffers.mjs";
|
|
2
|
+
import { readReserveBytes } from "./budget.mjs";
|
|
2
3
|
import { MemoryBudget } from "./memory-budget.mjs";
|
|
3
4
|
// src/storage/packs-memory.ts
|
|
4
5
|
let budgetOf;
|
package/dist/storage/packs.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { decodeStats, repoStats } from "../store/repo-record.mjs";
|
|
|
8
8
|
import { collections, newChangeId, repoScope, selfKey } from "../store/scopes.mjs";
|
|
9
9
|
import { CallBudget, RequestCalls, callScope, checkedLimits, countInto, countedAs, heldCall, inCallScope, noScope, readScope, requestCount, stepBudget, withBound } from "../store/call-count.mjs";
|
|
10
10
|
import { forkIn, noCall } from "../store/crossing.mjs";
|
|
11
|
+
import { headroomBytes, idleHeapBytes } from "../protocol/bytes/buffers.mjs";
|
|
11
12
|
import { jobCallLimitsOf } from "../store/job-try.mjs";
|
|
12
13
|
import { RequestSnapshot } from "../store/request-snapshot.mjs";
|
|
13
14
|
import { bestEffort } from "../store/errors.mjs";
|
|
@@ -47,7 +48,7 @@ import { defaultPrune, deletedLeaveAt, pruneWait, quarantineKey } from "./rows.m
|
|
|
47
48
|
import { openStageReceive, readAnswer, receiveStep, stageReceive, stageReceiveStep, stageStepKey } from "./receive-steps.mjs";
|
|
48
49
|
import { memoryOf, openBudget } from "./packs-memory.mjs";
|
|
49
50
|
import { receiveRoomAdmitted } from "./receive-admission.mjs";
|
|
50
|
-
import { fetchFloorBytes, fetchRowCacheBytes,
|
|
51
|
+
import { fetchFloorBytes, fetchRowCacheBytes, pushAdmissionOf, pushFloorsOf, pushPartBytes, pushRulesOf, readReserveBytes, readerFloorBytes, readerMost, unpackInflatedMost } from "./budget.mjs";
|
|
51
52
|
import { chargedCache } from "./charged-cache.mjs";
|
|
52
53
|
import { serverRequestBudget } from "./request-cache.mjs";
|
|
53
54
|
import { AllottedPointers, allotmentCacheCharge, allottedWithin, cacheRoomCharge, fetchBusy, growWaitMs, instanceRoomOf, pushMemoryOf, pushObjectsMostOf, pushTooLarge, readBusy, readerMemoryOf, requestBudgetOf, rowCacheRoomOf, upkeepMemoryOf, upkeepTooLarge, withMemoryBudget } from "./memory-budget.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ref0/git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.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",
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
],
|
|
15
15
|
"type": "module",
|
|
16
16
|
"sideEffects": false,
|
|
17
|
+
"imports": {
|
|
18
|
+
"#zlib-ng": {
|
|
19
|
+
"workerd": "./dist/protocol/bytes/zlib-ng/bundled.mjs",
|
|
20
|
+
"default": "./dist/protocol/bytes/zlib-ng/compile.mjs"
|
|
21
|
+
},
|
|
22
|
+
"#zlib-ng/zlib-ng.wasm": {
|
|
23
|
+
"default": "./dist/protocol/bytes/zlib-ng/zlib-ng.wasm"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
17
26
|
"exports": {
|
|
18
27
|
".": {
|
|
19
28
|
"types": "./dist/index.d.mts",
|
|
@@ -47,12 +56,12 @@
|
|
|
47
56
|
}
|
|
48
57
|
},
|
|
49
58
|
"dependencies": {
|
|
50
|
-
"@ref0/infra": "0.
|
|
59
|
+
"@ref0/infra": "0.27.0",
|
|
51
60
|
"pako": "2.1.0"
|
|
52
61
|
},
|
|
53
62
|
"devDependencies": {
|
|
54
63
|
"@effect/vitest": "4.1.7",
|
|
55
|
-
"@ref0/xdiff-wasm": "0.
|
|
64
|
+
"@ref0/xdiff-wasm": "0.27.0",
|
|
56
65
|
"effect": "4.1.7",
|
|
57
66
|
"vite-plus": "1.8.0",
|
|
58
67
|
"vitest": "5.1.1",
|