querysub 0.356.0 → 0.358.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/.cursorrules +9 -0
- package/bin/movelogs.js +4 -0
- package/package.json +13 -6
- package/scripts/postinstall.js +23 -0
- package/src/-a-archives/archiveCache.ts +10 -12
- package/src/-a-archives/archives.ts +29 -0
- package/src/-a-archives/archivesBackBlaze.ts +60 -12
- package/src/-a-archives/archivesDisk.ts +39 -13
- package/src/-a-archives/archivesLimitedCache.ts +21 -0
- package/src/-a-archives/archivesMemoryCache.ts +374 -0
- package/src/-a-archives/archivesPrivateFileSystem.ts +22 -0
- package/src/-g-core-values/NodeCapabilities.ts +3 -0
- package/src/0-path-value-core/auditLogs.ts +5 -1
- package/src/0-path-value-core/pathValueCore.ts +7 -7
- package/src/4-dom/qreact.tsx +1 -0
- package/src/4-querysub/Querysub.ts +1 -5
- package/src/config.ts +5 -0
- package/src/deployManager/components/MachineDetailPage.tsx +43 -2
- package/src/deployManager/components/MachinesListPage.tsx +10 -2
- package/src/deployManager/machineApplyMainCode.ts +3 -3
- package/src/deployManager/machineSchema.ts +39 -0
- package/src/diagnostics/MachineThreadInfo.tsx +235 -0
- package/src/diagnostics/NodeViewer.tsx +5 -3
- package/src/diagnostics/logs/FastArchiveAppendable.ts +79 -42
- package/src/diagnostics/logs/FastArchiveController.ts +102 -63
- package/src/diagnostics/logs/FastArchiveViewer.tsx +36 -8
- package/src/diagnostics/logs/IndexedLogs/BufferIndex.ts +462 -0
- package/src/diagnostics/logs/IndexedLogs/BufferIndexCPP.cpp +327 -0
- package/src/diagnostics/logs/IndexedLogs/BufferIndexCPP.d.ts +18 -0
- package/src/diagnostics/logs/IndexedLogs/BufferIndexCPP.js +1 -0
- package/src/diagnostics/logs/IndexedLogs/BufferIndexHelpers.ts +222 -0
- package/src/diagnostics/logs/IndexedLogs/BufferIndexLogsOptimizationConstants.ts +22 -0
- package/src/diagnostics/logs/IndexedLogs/BufferIndexWAT.wat +1145 -0
- package/src/diagnostics/logs/IndexedLogs/BufferIndexWAT.wat.d.ts +178 -0
- package/src/diagnostics/logs/IndexedLogs/BufferListStreamer.ts +208 -0
- package/src/diagnostics/logs/IndexedLogs/BufferUnitIndex.ts +716 -0
- package/src/diagnostics/logs/IndexedLogs/BufferUnitSet.ts +146 -0
- package/src/diagnostics/logs/IndexedLogs/FilePathSelector.tsx +569 -0
- package/src/diagnostics/logs/IndexedLogs/FindProgressTracker.ts +45 -0
- package/src/diagnostics/logs/IndexedLogs/IndexedLogs.ts +685 -0
- package/src/diagnostics/logs/IndexedLogs/LogStreamer.ts +47 -0
- package/src/diagnostics/logs/IndexedLogs/LogViewer3.tsx +901 -0
- package/src/diagnostics/logs/IndexedLogs/TimeFileTree.ts +236 -0
- package/src/diagnostics/logs/IndexedLogs/binding.gyp +23 -0
- package/src/diagnostics/logs/IndexedLogs/moveIndexLogsToPublic.ts +251 -0
- package/src/diagnostics/logs/IndexedLogs/moveLogsEntry.ts +10 -0
- package/src/diagnostics/logs/LogViewer2.tsx +120 -55
- package/src/diagnostics/logs/TimeRangeSelector.tsx +5 -2
- package/src/diagnostics/logs/diskLogger.ts +32 -48
- package/src/diagnostics/logs/errorNotifications/ErrorNotificationController.ts +3 -2
- package/src/diagnostics/logs/errorNotifications/errorDigests.tsx +1 -0
- package/src/diagnostics/logs/errorNotifications2/errorNotifications2.ts +0 -0
- package/src/diagnostics/logs/lifeCycleAnalysis/LifeCyclePages.tsx +150 -0
- package/src/diagnostics/logs/lifeCycleAnalysis/lifeCycles.tsx +150 -15
- package/src/diagnostics/logs/lifeCycleAnalysis/test.ts +0 -0
- package/src/diagnostics/logs/lifeCycleAnalysis/test.wat +106 -0
- package/src/diagnostics/logs/lifeCycleAnalysis/test.wat.d.ts +2 -0
- package/src/diagnostics/logs/lifeCycleAnalysis/testHoist.ts +5 -0
- package/src/diagnostics/logs/logViewerExtractField.ts +2 -3
- package/src/diagnostics/managementPages.tsx +10 -0
- package/src/diagnostics/trackResources.ts +1 -1
- package/src/functional/limitProcessing.ts +39 -0
- package/src/misc/lz4_wasm_nodejs.d.ts +34 -0
- package/src/misc/lz4_wasm_nodejs.js +178 -0
- package/src/misc/lz4_wasm_nodejs_bg.js +94 -0
- package/src/misc/lz4_wasm_nodejs_bg.wasm +0 -0
- package/src/misc/lz4_wasm_nodejs_bg.wasm.d.ts +15 -0
- package/src/storage/CompressedStream.ts +13 -0
- package/src/storage/LZ4.ts +32 -0
- package/src/storage/ZSTD.ts +10 -0
- package/src/wat/watCompiler.ts +1716 -0
- package/src/wat/watGrammar.pegjs +93 -0
- package/src/wat/watHandler.ts +179 -0
- package/src/wat/watInstructions.txt +707 -0
- package/src/zip.ts +3 -89
- package/src/diagnostics/logs/lifeCycleAnalysis/spec.md +0 -125
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { formatPercent, formatNumber } from "socket-function/src/formatting/format";
|
|
2
|
+
import { red } from "socket-function/src/formatting/logColors";
|
|
3
|
+
import { measureFnc } from "socket-function/src/profiling/measure";
|
|
4
|
+
import { Unit } from "./BufferIndexHelpers";
|
|
5
|
+
|
|
6
|
+
export class UnitSet {
|
|
7
|
+
// Hash-based set for checking unit membership (no positions stored)
|
|
8
|
+
// Similar to the hash table approach in UnitRefList.encode, but only stores presence
|
|
9
|
+
|
|
10
|
+
@measureFnc
|
|
11
|
+
static encode(blocks: Buffer[][]): Buffer {
|
|
12
|
+
const MAX_FILL_RATIO = 0.35;
|
|
13
|
+
|
|
14
|
+
// First pass: count total units
|
|
15
|
+
let totalUnits = 0;
|
|
16
|
+
for (let blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
|
|
17
|
+
const block = blocks[blockIndex];
|
|
18
|
+
for (let bufferIndex = 0; bufferIndex < block.length; bufferIndex++) {
|
|
19
|
+
const buffer = block[bufferIndex];
|
|
20
|
+
if (buffer.length >= 4) {
|
|
21
|
+
totalUnits += buffer.length - 3;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (totalUnits === 0) {
|
|
27
|
+
return Buffer.from(new Uint32Array([0]).buffer);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function tryEncodeWithRatio(estimatedUniqueRatio: number): { hashTable: Uint32Array; collisions: number; totalInserts: number; } | undefined {
|
|
31
|
+
const HASH_FACTOR = 2;
|
|
32
|
+
const estimatedUnique = Math.max(Math.ceil(totalUnits / estimatedUniqueRatio), 16);
|
|
33
|
+
const desiredCapacity = estimatedUnique * HASH_FACTOR;
|
|
34
|
+
const hashTableCount = Math.pow(2, Math.ceil(Math.log2(desiredCapacity)));
|
|
35
|
+
|
|
36
|
+
const maxUniqueCount = Math.floor(hashTableCount * MAX_FILL_RATIO);
|
|
37
|
+
|
|
38
|
+
// Each entry is just a single uint32 (the unit value, 0 means empty)
|
|
39
|
+
const hashTable = new Uint32Array(hashTableCount);
|
|
40
|
+
|
|
41
|
+
function getHashIndex(unit: number): number {
|
|
42
|
+
const hash = Math.imul(unit, 2654435761);
|
|
43
|
+
return (hash >>> 16) & (hashTableCount - 1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getNextIndex(index: number): number {
|
|
47
|
+
return (index + 1) & (hashTableCount - 1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let uniqueCount = 0;
|
|
51
|
+
let collisions = 0;
|
|
52
|
+
let totalInserts = 0;
|
|
53
|
+
|
|
54
|
+
// Iterate and add to hash table directly (no first pass)
|
|
55
|
+
for (let blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
|
|
56
|
+
const block = blocks[blockIndex];
|
|
57
|
+
for (let bufferIndex = 0; bufferIndex < block.length; bufferIndex++) {
|
|
58
|
+
const buffer = block[bufferIndex];
|
|
59
|
+
// Extract units directly
|
|
60
|
+
for (let i = 0; i <= buffer.length - 4; i++) {
|
|
61
|
+
const unit = buffer.readUint32LE(i);
|
|
62
|
+
if (!unit) continue;
|
|
63
|
+
|
|
64
|
+
totalInserts++;
|
|
65
|
+
let index = getHashIndex(unit);
|
|
66
|
+
// Linear probing
|
|
67
|
+
while (true) {
|
|
68
|
+
if (hashTable[index] === 0) {
|
|
69
|
+
// Empty slot - insert
|
|
70
|
+
hashTable[index] = unit;
|
|
71
|
+
uniqueCount++;
|
|
72
|
+
if (uniqueCount > maxUniqueCount) {
|
|
73
|
+
return undefined; // Failed, exceeded fill ratio
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
if (hashTable[index] === unit) {
|
|
78
|
+
// Already present
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
// Collision, probe next
|
|
82
|
+
collisions++;
|
|
83
|
+
index = getNextIndex(index);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return { hashTable, collisions, totalInserts };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Try with increasingly conservative ratios until we succeed
|
|
93
|
+
let ratio = 1000;
|
|
94
|
+
let result: ReturnType<typeof tryEncodeWithRatio>;
|
|
95
|
+
while (true) {
|
|
96
|
+
result = tryEncodeWithRatio(ratio);
|
|
97
|
+
if (result) break;
|
|
98
|
+
ratio /= 2;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const collisionRate = result.totalInserts > 0 ? result.collisions / result.totalInserts : 0;
|
|
102
|
+
|
|
103
|
+
if (collisionRate > 0.5) {
|
|
104
|
+
console.warn(red(`WARNING: UnitSet collision rate is over 50%: ${formatPercent(collisionRate)}`));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Store capacity as first uint32, followed by the hash table
|
|
108
|
+
const output = new Uint32Array(1 + result.hashTable.length);
|
|
109
|
+
output[0] = result.hashTable.length;
|
|
110
|
+
output.set(result.hashTable, 1);
|
|
111
|
+
|
|
112
|
+
return Buffer.from(output.buffer);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@measureFnc
|
|
116
|
+
static has(data: Buffer, unit: Unit): boolean {
|
|
117
|
+
const hashTableCount = data.readUInt32LE(0);
|
|
118
|
+
|
|
119
|
+
if (hashTableCount === 0) return false;
|
|
120
|
+
|
|
121
|
+
function getHashIndex(unit: number): number {
|
|
122
|
+
const hash = Math.imul(unit, 2654435761);
|
|
123
|
+
return (hash >>> 16) & (hashTableCount - 1);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function getNextIndex(index: number): number {
|
|
127
|
+
return (index + 1) & (hashTableCount - 1);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
let index = getHashIndex(unit);
|
|
131
|
+
const maxProbes = hashTableCount;
|
|
132
|
+
|
|
133
|
+
for (let probes = 0; probes < maxProbes; probes++) {
|
|
134
|
+
const value = data.readUInt32LE((1 + index) * 4);
|
|
135
|
+
if (value === 0) return false; // Empty slot, unit not present
|
|
136
|
+
if (value === unit) return true; // Found it
|
|
137
|
+
index = getNextIndex(index);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return false; // Shouldn't reach here if hash table isn't full
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|