sliftutils 1.4.72 → 1.4.74
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/package.json
CHANGED
|
@@ -262,7 +262,7 @@ export class BulkDatabaseBase<T extends { key: string }> {
|
|
|
262
262
|
db.reloadFromDisk();
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
if (flushed.length) console.log(`[bulk2] heap ${fmtBytes(usedHeapBytes)} over ${fmtBytes(bulkDatabase2Timing.memoryFlushHeapBytes)}
|
|
265
|
+
if (flushed.length) console.log(`[bulk2] heap ${fmtBytes(usedHeapBytes)} over ${fmtBytes(bulkDatabase2Timing.memoryFlushHeapBytes)} - flushed ${flushed.length} large collection(s): ${flushed.join(", ")}`);
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
public static clearCache() {
|
|
@@ -706,7 +706,7 @@ export class BulkDatabaseBase<T extends { key: string }> {
|
|
|
706
706
|
}
|
|
707
707
|
return;
|
|
708
708
|
}
|
|
709
|
-
console.warn(`${this.name}: skipping unreadable bulk file ${file.fileName} (recent
|
|
709
|
+
console.warn(`${this.name}: skipping unreadable bulk file ${file.fileName} (recent - may be in-progress): ${message}`);
|
|
710
710
|
}
|
|
711
711
|
|
|
712
712
|
// The one merge primitive. Reads + plans + writes outputs before deleting any input, so a crash
|
|
@@ -815,7 +815,7 @@ export class BulkDatabaseBase<T extends { key: string }> {
|
|
|
815
815
|
const outTotal = outputs.reduce((a, f) => a + f.size, 0);
|
|
816
816
|
log(`${magenta("wrote")}: ${outputs.length} output file(s), ${fmtBytes(outTotal)}${carriedDeletes ? `, ${carriedDeletes} tombstones carried` : ""}`);
|
|
817
817
|
|
|
818
|
-
console.group(`${blue(this.name)} ${magenta("merge")}: ${fmtBytes(inTotal)}
|
|
818
|
+
console.group(`${blue(this.name)} ${magenta("merge")}: ${fmtBytes(inTotal)} -> ${fmtBytes(outTotal)} (${inputs.length}->${outputs.length} files) in ${formatTime(Date.now() - mergeStartMs)}`);
|
|
819
819
|
for (const line of steps) console.log(line);
|
|
820
820
|
console.groupEnd();
|
|
821
821
|
|
|
@@ -896,7 +896,7 @@ export class BulkDatabaseBase<T extends { key: string }> {
|
|
|
896
896
|
const sizes = await Promise.all(streamFiles.map(async f => { try { return (await storage.getInfo(f.fileName))?.size ?? 0; } catch { return 0; } }));
|
|
897
897
|
const totalStreamBytes = sizes.reduce((a, b) => a + b, 0);
|
|
898
898
|
if (totalStreamBytes > bulkDatabase2Timing.streamFoldHardLimitBytes) {
|
|
899
|
-
console.log(`${blue(this.name)} ${magenta("fold")} stream tier ${fmtBytes(totalStreamBytes)} over hard limit ${fmtBytes(bulkDatabase2Timing.streamFoldHardLimitBytes)}
|
|
899
|
+
console.log(`${blue(this.name)} ${magenta("fold")} stream tier ${fmtBytes(totalStreamBytes)} over hard limit ${fmtBytes(bulkDatabase2Timing.streamFoldHardLimitBytes)} - folding all streams now`);
|
|
900
900
|
if (await this.mergeFileSet([], streamFiles, false, true)) merged = true;
|
|
901
901
|
}
|
|
902
902
|
}
|
|
@@ -964,7 +964,7 @@ export class BulkDatabaseBase<T extends { key: string }> {
|
|
|
964
964
|
}
|
|
965
965
|
const dupFraction = totalSlots ? (totalSlots - uniqueKeys.size) / totalSlots : 0;
|
|
966
966
|
if (totalBytes > DEDUP_TRIGGER_BYTES && dupFraction > DEDUP_TRIGGER_FRACTION) {
|
|
967
|
-
console.log(`${blue(this.name)} ${magenta("dedup")}: ${fmtBytes(totalBytes)} across ${bulkFiles.length} bulk file(s), ${Math.round(dupFraction * 100)}% duplicate key-slots
|
|
967
|
+
console.log(`${blue(this.name)} ${magenta("dedup")}: ${fmtBytes(totalBytes)} across ${bulkFiles.length} bulk file(s), ${Math.round(dupFraction * 100)}% duplicate key-slots - folding all at once`);
|
|
968
968
|
if (!await runMerge(bulkFiles, [])) return merged;
|
|
969
969
|
return merged;
|
|
970
970
|
}
|
|
@@ -601,23 +601,32 @@ function getCompactor(baseDir: string, name: string): BulkDatabaseBase<{ key: st
|
|
|
601
601
|
export async function autocompactBulkDatabases(root: string): Promise<void> {
|
|
602
602
|
// Collections live under <baseDir>/bulkDatabases2/<name>/. The app may nest its data under a "data"
|
|
603
603
|
// subfolder (see getFileStorageNested2's heuristic), so look in both <root> and <root>/data.
|
|
604
|
+
const collections: { baseDir: string; name: string }[] = [];
|
|
604
605
|
for (const baseDir of [root, path.join(root, "data")]) {
|
|
605
|
-
let names: string[];
|
|
606
606
|
try {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
} catch { continue; } // no bulkDatabases2 here
|
|
610
|
-
for (const name of names) {
|
|
611
|
-
const start = Date.now();
|
|
612
|
-
console.log(` [autocompact] ${name}: starting merge…`);
|
|
613
|
-
try {
|
|
614
|
-
await getCompactor(baseDir, name).tryMergeNow();
|
|
615
|
-
console.log(` [autocompact] ${name}: done (${Date.now() - start}ms)`);
|
|
616
|
-
} catch (e) {
|
|
617
|
-
console.warn(` [autocompact] ${name}: failed after ${Date.now() - start}ms — ${(e as Error).message}`);
|
|
607
|
+
for (const d of fs.readdirSync(path.join(baseDir, BULK_ROOT_FOLDER), { withFileTypes: true })) {
|
|
608
|
+
if (d.isDirectory()) collections.push({ baseDir, name: d.name });
|
|
618
609
|
}
|
|
610
|
+
} catch { continue; } // no bulkDatabases2 here
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
const total = collections.length;
|
|
614
|
+
if (!total) return;
|
|
615
|
+
const passStart = Date.now();
|
|
616
|
+
console.log(` [autocompact] iterating over ${total} collection(s)`);
|
|
617
|
+
for (let i = 0; i < total; i++) {
|
|
618
|
+
const { baseDir, name } = collections[i];
|
|
619
|
+
const at = `${i + 1} / ${total}`;
|
|
620
|
+
const start = Date.now();
|
|
621
|
+
console.log(` [autocompact] ${at} ${name}: starting merge`);
|
|
622
|
+
try {
|
|
623
|
+
await getCompactor(baseDir, name).tryMergeNow();
|
|
624
|
+
console.log(` [autocompact] ${at} ${name}: done (${Date.now() - start}ms)`);
|
|
625
|
+
} catch (e) {
|
|
626
|
+
console.warn(` [autocompact] ${at} ${name}: failed after ${Date.now() - start}ms - ${(e as Error).message}`);
|
|
619
627
|
}
|
|
620
628
|
}
|
|
629
|
+
console.log(` [autocompact] done all ${total} collection(s) (${Date.now() - passStart}ms)`);
|
|
621
630
|
}
|
|
622
631
|
|
|
623
632
|
// CLI entry (invoked by bin/filehoster.js or `yarn filehoster <folder>`). Starts the server, logs the
|