querysub 0.356.0 → 0.357.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 +8 -0
- package/bin/movelogs.js +4 -0
- package/package.json +12 -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 +27 -8
- package/src/-a-archives/archivesLimitedCache.ts +21 -0
- package/src/-a-archives/archivesMemoryCache.ts +350 -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/diagnostics/MachineThreadInfo.tsx +235 -0
- package/src/diagnostics/NodeViewer.tsx +3 -2
- 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 +461 -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 +140 -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 +206 -0
- package/src/diagnostics/logs/IndexedLogs/BufferUnitIndex.ts +719 -0
- package/src/diagnostics/logs/IndexedLogs/BufferUnitSet.ts +146 -0
- package/src/diagnostics/logs/IndexedLogs/FilePathSelector.tsx +408 -0
- package/src/diagnostics/logs/IndexedLogs/FindProgressTracker.ts +45 -0
- package/src/diagnostics/logs/IndexedLogs/IndexedLogs.ts +598 -0
- package/src/diagnostics/logs/IndexedLogs/LogStreamer.ts +47 -0
- package/src/diagnostics/logs/IndexedLogs/LogViewer3.tsx +702 -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 +221 -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/lifeCycleAnalysis/LifeCyclePages.tsx +150 -0
- package/src/diagnostics/logs/lifeCycleAnalysis/lifeCycles.tsx +132 -15
- package/src/diagnostics/logs/lifeCycleAnalysis/test.ts +180 -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/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,93 @@
|
|
|
1
|
+
// WebAssembly Text Format (WAT) Grammar
|
|
2
|
+
// This grammar captures the basic S-expression structure of WAT
|
|
3
|
+
|
|
4
|
+
{
|
|
5
|
+
function makeNode(type, data) {
|
|
6
|
+
return { type, ...data };
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
Start
|
|
11
|
+
= _ items:SExpr* _ {
|
|
12
|
+
return makeNode('module', { items });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// S-Expression (parenthesized form)
|
|
16
|
+
SExpr
|
|
17
|
+
= "(" _ keyword:Keyword attrs:(_ MemoryAttribute)* items:(_ (SExpr / Literal / Identifier / TypeName))* _ ")" {
|
|
18
|
+
return makeNode('sexpr', { keyword, attributes: attrs.map(a => a[1]), items: items.map(i => i[1]) });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Memory operation attributes (offset=N, align=N)
|
|
22
|
+
MemoryAttribute
|
|
23
|
+
= name:$("offset" / "align") "=" value:$([0-9]+) {
|
|
24
|
+
return makeNode('attribute', { name, value: parseInt(value, 10) });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Type names (i32, i64, f32, f64, etc.)
|
|
28
|
+
TypeName
|
|
29
|
+
= name:$("i32" / "i64" / "f32" / "f64" / "v128" / "funcref" / "externref" / "anyref") {
|
|
30
|
+
return makeNode('identifier', { name });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Keywords (instructions, directives, etc.)
|
|
34
|
+
Keyword
|
|
35
|
+
= keyword:$([a-z_][a-z0-9_\.]*) {
|
|
36
|
+
return keyword;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Identifiers (e.g., $funcName, $varName)
|
|
40
|
+
Identifier
|
|
41
|
+
= "$" name:$([a-zA-Z0-9_\.]+) {
|
|
42
|
+
return makeNode('identifier', { name: '$' + name });
|
|
43
|
+
}
|
|
44
|
+
/ name:$([0-9]+) {
|
|
45
|
+
return makeNode('index', { value: parseInt(name, 10) });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Literals
|
|
49
|
+
Literal
|
|
50
|
+
= NumberLiteral
|
|
51
|
+
/ StringLiteral
|
|
52
|
+
|
|
53
|
+
NumberLiteral
|
|
54
|
+
= sign:"-"? value:$(
|
|
55
|
+
"0x" [0-9a-fA-F_]+
|
|
56
|
+
/ [0-9]+ "." [0-9]+ ([eE] [+-]? [0-9]+)?
|
|
57
|
+
/ [0-9]+ ([eE] [+-]? [0-9]+)?
|
|
58
|
+
) {
|
|
59
|
+
let fullValue = (sign || '') + value.replace(/_/g, '');
|
|
60
|
+
return makeNode('number', { value: fullValue });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
StringLiteral
|
|
64
|
+
= '"' chars:DoubleStringChar* '"' {
|
|
65
|
+
return makeNode('string', { value: chars.join('') });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
DoubleStringChar
|
|
69
|
+
= !'"' !"\\" char:. { return char; }
|
|
70
|
+
/ "\\" escape:EscapeSequence { return escape; }
|
|
71
|
+
|
|
72
|
+
EscapeSequence
|
|
73
|
+
= "n" { return "\n"; }
|
|
74
|
+
/ "r" { return "\r"; }
|
|
75
|
+
/ "t" { return "\t"; }
|
|
76
|
+
/ "\\" { return "\\"; }
|
|
77
|
+
/ '"' { return '"'; }
|
|
78
|
+
/ "x" hex:$([0-9a-fA-F][0-9a-fA-F]) {
|
|
79
|
+
return String.fromCharCode(parseInt(hex, 16));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Whitespace and comments
|
|
83
|
+
_
|
|
84
|
+
= (Whitespace / LineComment / BlockComment)*
|
|
85
|
+
|
|
86
|
+
Whitespace
|
|
87
|
+
= [ \t\r\n]+
|
|
88
|
+
|
|
89
|
+
LineComment
|
|
90
|
+
= ";;" [^\r\n]*
|
|
91
|
+
|
|
92
|
+
BlockComment
|
|
93
|
+
= "(;" (!";" .)* ";)"
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { sha256 } from "js-sha256";
|
|
2
|
+
import { addAdditionalExtensions, compileTransform2 } from "../../../typenode";
|
|
3
|
+
import { compileWAT } from "./watCompiler";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
|
|
6
|
+
let injected = false;
|
|
7
|
+
|
|
8
|
+
export function watHandler(): void {
|
|
9
|
+
if (injected) return;
|
|
10
|
+
injected = true;
|
|
11
|
+
addAdditionalExtensions([".wat"]);
|
|
12
|
+
|
|
13
|
+
let watFileContents = fs.readFileSync(__dirname + "/watCompiler.ts", "utf8");
|
|
14
|
+
|
|
15
|
+
compileTransform2({
|
|
16
|
+
matches: [/\.wat$/],
|
|
17
|
+
additionalCacheKey: sha256(watFileContents),
|
|
18
|
+
transform: (contents: string, path: string, module: NodeJS.Module): string => {
|
|
19
|
+
const wasmBuffer = compileWAT(contents);
|
|
20
|
+
const base64 = Buffer.from(wasmBuffer).toString("base64");
|
|
21
|
+
console.log(base64.slice(0, 200));
|
|
22
|
+
let maxPages = MAX_TOTAL_BYTES / WASM_PAGE_SIZE;
|
|
23
|
+
return `
|
|
24
|
+
const wasmBuffer = Buffer.from("${base64}", "base64");
|
|
25
|
+
const wasmModule = new WebAssembly.Module(wasmBuffer);
|
|
26
|
+
|
|
27
|
+
// If in node, and < node 24, throw
|
|
28
|
+
if (typeof process !== 'undefined' && process.versions && process.versions.node) {
|
|
29
|
+
const nodeMajorVersion = parseInt(process.versions.node.split('.')[0], 10);
|
|
30
|
+
if (nodeMajorVersion < 24) {
|
|
31
|
+
throw new Error(\`WebAssembly memory64 requires Node.js 24 or later. Current version: \${process.versions.node}\`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const memory = new WebAssembly.Memory({
|
|
36
|
+
initial: 1n,
|
|
37
|
+
maximum: ${maxPages}n,
|
|
38
|
+
address: 'i64'
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const wasmInstance = new WebAssembly.Instance(wasmModule, {
|
|
42
|
+
env: { memory }
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Export both the instance exports and the memory
|
|
46
|
+
module.exports = {
|
|
47
|
+
...wasmInstance.exports,
|
|
48
|
+
memory
|
|
49
|
+
};
|
|
50
|
+
`;
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ─── Memory allocation support ────────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
const WASM_PAGE_SIZE = 65536; // 64 KiB per WebAssembly spec
|
|
58
|
+
const MAX_TOTAL_BYTES = 16 * 1024 * 1024 * 1024; // 16 GiB hard ceiling
|
|
59
|
+
const ALIGNMENT = 8; // align all allocations to 8-byte boundaries
|
|
60
|
+
|
|
61
|
+
/** Running total of all pages ever grown across every WAT module instance. */
|
|
62
|
+
let totalGrownBytes = 0;
|
|
63
|
+
|
|
64
|
+
interface ModuleMemoryState {
|
|
65
|
+
/** Byte offset of the next free allocation slot (always ALIGNMENT-aligned). */
|
|
66
|
+
nextOffset: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const memoryStateMap = new WeakMap<WebAssembly.Memory, ModuleMemoryState>();
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Describes the exports a WAT module must provide to support memory allocation.
|
|
73
|
+
*
|
|
74
|
+
* Required:
|
|
75
|
+
* - `memory` — the module's exported WebAssembly.Memory
|
|
76
|
+
*
|
|
77
|
+
* Optional:
|
|
78
|
+
* - `__heap_base` — an exported i32 global whose value is the first byte
|
|
79
|
+
* after any static data; the allocator starts here.
|
|
80
|
+
* If absent, allocations start from byte 0.
|
|
81
|
+
*
|
|
82
|
+
* Example WAT:
|
|
83
|
+
* (memory (export "memory") 1)
|
|
84
|
+
* (global (export "__heap_base") i32 (i32.const 0))
|
|
85
|
+
*/
|
|
86
|
+
export interface WatModuleExports {
|
|
87
|
+
memory: WebAssembly.Memory;
|
|
88
|
+
__heap_base?: WebAssembly.Global;
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A stable handle to a region of WebAssembly linear memory.
|
|
94
|
+
*
|
|
95
|
+
* Because `WebAssembly.Memory.grow()` detaches and replaces the underlying
|
|
96
|
+
* ArrayBuffer, any raw Uint8Array taken before a grow becomes invalid.
|
|
97
|
+
* WatBuffer solves this: access `.view` or `.dataView` each time you need
|
|
98
|
+
* to read or write, and you always get a fresh view from the current buffer.
|
|
99
|
+
*
|
|
100
|
+
* Allocate once per logical scratch region; reuse the handle for every call.
|
|
101
|
+
*/
|
|
102
|
+
export class WatBuffer {
|
|
103
|
+
private readonly _memory: WebAssembly.Memory;
|
|
104
|
+
/** Byte offset of this region within the module's linear memory. */
|
|
105
|
+
readonly offset: number;
|
|
106
|
+
/** Size of this region in bytes (as requested, before alignment padding). */
|
|
107
|
+
readonly byteLength: number;
|
|
108
|
+
|
|
109
|
+
constructor(memory: WebAssembly.Memory, offset: number, byteLength: number) {
|
|
110
|
+
this._memory = memory;
|
|
111
|
+
this.offset = offset;
|
|
112
|
+
this.byteLength = byteLength;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** A Uint8Array view into the current memory buffer for this region.
|
|
116
|
+
* Re-read after any call that may grow the module's memory. */
|
|
117
|
+
get view(): Uint8Array {
|
|
118
|
+
return new Uint8Array(this._memory.buffer, this.offset, this.byteLength);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** A DataView into the current memory buffer for this region.
|
|
122
|
+
* Re-read after any call that may grow the module's memory. */
|
|
123
|
+
get dataView(): DataView {
|
|
124
|
+
return new DataView(this._memory.buffer, this.offset, this.byteLength);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function alignUp(value: number, alignment: number): number {
|
|
129
|
+
return Math.ceil(value / alignment) * alignment;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Allocates `byteLength` bytes in a WAT module's linear memory and returns
|
|
134
|
+
* a `WatBuffer` handle for that region.
|
|
135
|
+
*
|
|
136
|
+
* - Memory is grown (in 64 KiB pages) as needed to satisfy the request.
|
|
137
|
+
* - Allocations are never freed; callers should allocate once and reuse.
|
|
138
|
+
* - Cumulative grown memory across *all* modules must not exceed 16 GiB;
|
|
139
|
+
* exceeding this throws an error.
|
|
140
|
+
*
|
|
141
|
+
* The module's exports must satisfy `WatModuleExports` (export `memory`,
|
|
142
|
+
* and optionally `__heap_base` to skip over any static data section).
|
|
143
|
+
*/
|
|
144
|
+
export function allocateBuffer(exports: WatModuleExports, byteLength: number): WatBuffer {
|
|
145
|
+
const memory = exports.memory;
|
|
146
|
+
|
|
147
|
+
let state = memoryStateMap.get(memory);
|
|
148
|
+
if (!state) {
|
|
149
|
+
const heapBase = exports.__heap_base !== undefined
|
|
150
|
+
? (exports.__heap_base.value as number)
|
|
151
|
+
: 0;
|
|
152
|
+
state = { nextOffset: alignUp(heapBase, ALIGNMENT) };
|
|
153
|
+
memoryStateMap.set(memory, state);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const startOffset = state.nextOffset;
|
|
157
|
+
const endOffset = alignUp(startOffset + byteLength, ALIGNMENT);
|
|
158
|
+
|
|
159
|
+
const currentBytes = memory.buffer.byteLength;
|
|
160
|
+
if (endOffset > currentBytes) {
|
|
161
|
+
const needed = endOffset - currentBytes;
|
|
162
|
+
const pages = Math.ceil(needed / WASM_PAGE_SIZE);
|
|
163
|
+
const newBytes = pages * WASM_PAGE_SIZE;
|
|
164
|
+
|
|
165
|
+
if (totalGrownBytes + newBytes > MAX_TOTAL_BYTES) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
`WAT memory allocation would exceed 16 GiB limit. ` +
|
|
168
|
+
`Already grown ${totalGrownBytes} bytes, trying to grow by ${newBytes} bytes` +
|
|
169
|
+
`(${pages} page(s)) to satisfy request of ${byteLength} bytes at offset ${startOffset}.`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
memory.grow(BigInt(pages) as any);
|
|
174
|
+
totalGrownBytes += newBytes;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
state.nextOffset = endOffset;
|
|
178
|
+
return new WatBuffer(memory, startOffset, byteLength);
|
|
179
|
+
}
|