sliftutils 1.4.69 → 1.4.70

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "1.4.69",
3
+ "version": "1.4.70",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -42,11 +42,11 @@ const MAX_INDEX_RELOAD_ATTEMPTS = 3;
42
42
  const FIRST_MERGE_BYTES = TARGET_FILE_BYTES / 2;
43
43
  const KEY_GROUP_BYTES = 800 * 1024 * 1024;
44
44
  const DUP_THRESHOLD = 0.4;
45
- // Emergency Pass 2 short-circuit: once Pass 1 has had a chance to fold streams, if the bulk tier is
46
- // big enough AND the overall key duplication fraction is high, do ONE merge across every bulk file
47
- // instead of the per-key-group walk (which spaces merges 5 min apart — 16 hours for 200 groups).
48
- const EMERGENCY_DEDUP_BYTES = 512 * 1024 * 1024;
49
- const EMERGENCY_DEDUP_FRACTION = 0.5;
45
+ // Whole-tier dedup short-circuit (after Pass 1): when the bulk tier is over this size AND the overall
46
+ // key duplication fraction is over this threshold, fold every bulk file in one merge instead of the
47
+ // per-key-group walk (which spaces merges 5 min apart — 16 h for 200 groups).
48
+ const DEDUP_TRIGGER_BYTES = 512 * 1024 * 1024;
49
+ const DEDUP_TRIGGER_FRACTION = 0.5;
50
50
  const WRITE_FLUSH_FIRST_STEP_MS = 250;
51
51
 
52
52
  export const bulkDatabase2Timing = {
@@ -941,9 +941,9 @@ export class BulkDatabaseBase<T extends { key: string }> {
941
941
  }
942
942
  }
943
943
 
944
- // Pass 1.5 (emergency dedup): Pass 1 has had its chance. If the bulk tier is fat AND mostly
945
- // duplicates, the per-group walk below (5 min spacing per group) takes hours for an extreme
946
- // state (1000+ files, 99% dup) — fold every bulk file in one merge and skip the walk.
944
+ // Whole-tier dedup short-circuit (between Pass 1 and the per-group Pass 2): when the bulk tier
945
+ // is big enough AND mostly duplicates, fold every bulk file in one merge. Avoids the per-group
946
+ // walk's 5-min spacing × N-groups latency.
947
947
  {
948
948
  const { bulkFiles } = await this.listFiles();
949
949
  if (bulkFiles.length >= 2) {
@@ -960,8 +960,8 @@ export class BulkDatabaseBase<T extends { key: string }> {
960
960
  } catch { /* skip unreadable */ }
961
961
  }
962
962
  const dupFraction = totalSlots ? (totalSlots - uniqueKeys.size) / totalSlots : 0;
963
- if (totalBytes > EMERGENCY_DEDUP_BYTES && dupFraction > EMERGENCY_DEDUP_FRACTION) {
964
- console.log(`${blue(this.name)} ${magenta("emergency-dedup")}: ${fmtBytes(totalBytes)} across ${bulkFiles.length} bulk file(s), ${Math.round(dupFraction * 100)}% duplicate key-slots — folding all at once`);
963
+ if (totalBytes > DEDUP_TRIGGER_BYTES && dupFraction > DEDUP_TRIGGER_FRACTION) {
964
+ 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`);
965
965
  if (!await runMerge(bulkFiles, [])) return merged;
966
966
  return merged;
967
967
  }