@node-projects/speedscope 2.0.0 → 2.2.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Juanjo Diaz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,174 @@
1
+ # Import formats and background processing
2
+
3
+ The [README](../README.md#supported-file-formats) lists supported sources.
4
+ This guide describes additional fork-specific behavior and its limits.
5
+
6
+ ## Perf clock weights
7
+
8
+ Explicit `perf script` periods now determine aggregate weights. CPU/task-clock
9
+ periods are nanoseconds of sampled CPU time; off-CPU periods remain separate
10
+ sleep-time profiles, and cycles remain raw counts. Missing periods retain
11
+ explicitly labeled inference or sample counts. Timestamp gaps are not claimed
12
+ as measured execution. See [perf semantics and the public regression](PERF_IMPORT.md).
13
+
14
+ ## OpenTelemetry Profiles
15
+
16
+ Current OTLP Profiles JSON imports sampled stacks through a shared dictionary,
17
+ preserving metric weights, inline chains and thread/resource separation.
18
+ Timestamps do not become durations, and sample periods do not multiply values.
19
+ The importer currently parses the JSON in memory and creates aggregate profiles;
20
+ binary protobuf and older development layouts remain unsupported. See the
21
+ [pinned schema, limits and exact supported scope](OTEL_PROFILES.md).
22
+
23
+ ## Classic Android method traces
24
+
25
+ Open the classic concatenated key/data format emitted by Android method tracing:
26
+ a text key section followed by a little-endian `SLOW` binary section. Versions
27
+ 1, 2 and 3 are supported, including version-3 record padding. The file can be
28
+ named `.trace` or renamed; detection uses the format signature.
29
+
30
+ The importer preserves method signatures, thread identities and available Java
31
+ source locations. Clock metadata is required. `thread-cpu` and `wall` clocks
32
+ remain distinct; version-3 `dual` input creates separate labeled CPU and wall
33
+ profiles for each thread. Version-1 `global` means wall time. All values use
34
+ microseconds. CPU clocks are local to their thread; wall offsets remain relative
35
+ to the trace origin, so leading unobserved time can appear as idle weight.
36
+ The absolute date in the binary header is not added to those offsets.
37
+
38
+ Initial method exits reconstruct calls already active at trace start. Calls
39
+ still open at EOF close at that thread's last observed event. These are clipped
40
+ observation windows and do not invent work before or after the recording.
41
+
42
+ Fixed records are scanned without retaining a second parsed-record array.
43
+ Temporary state includes key dictionaries and per-thread stacks, alongside the
44
+ output builders. Key text is decoded line by line with a 16 MiB section limit
45
+ and 1 MiB line limit. The input buffer and final profiles still occupy memory.
46
+
47
+ Raw binary-only/streaming traces, newer ART packet formats, Perfetto protobuf,
48
+ Android systrace HTML and wrapped timestamp recovery are unsupported. Unknown
49
+ clocks, partial records, invalid method actions and decreasing per-thread clocks
50
+ produce explicit errors. See the
51
+ [synthetic fixture, generation script and AOSP references](../sample/profiles/android-method-trace/README.md)
52
+ for the exact supported layouts and clock policy.
53
+
54
+ ## Java thread-dump archives
55
+
56
+ Traditional HotSpot `jstack` / `Thread.print` text can be opened directly or as
57
+ an archive of captures from one JVM. Observed stacks contribute raw samples;
58
+ they do not measure elapsed time. The ZIP importer checks declared sizes and
59
+ actual expansion, feeds bounded UTF-8 lines into the parser and supports
60
+ cancellation without returning partial results.
61
+
62
+ See [text snapshot semantics](JAVA_THREAD_DUMPS.md) and the
63
+ [ZIP format and resource policy](JAVA_THREAD_DUMP_ZIP.md). Archive support is
64
+ limited to classic ZIP32 STORE/DEFLATE; it is not a generic archive extractor.
65
+
66
+ ## pprof metric and source identity
67
+
68
+ pprof's `default_sample_type` selects a sample metric by its string-table
69
+ identity. Protobuf integer objects are compared by value. If the preferred
70
+ metric is absent or cannot be found, the existing last-metric fallback applies.
71
+ For example, a recording can prefer allocation counts even when a later sample
72
+ column measures bytes; the displayed unit follows the chosen metric.
73
+
74
+ Function IDs and location IDs retain their complete unsigned 64-bit identity.
75
+ They are not truncated to their low 32 bits or rounded through a JavaScript
76
+ number, so IDs that share a low word remain distinct. String-table positions
77
+ must fit safe nonnegative integers. Source lines must fit safe positive integers.
78
+
79
+ Each location retains its own source line, falling back to the function's
80
+ definition line when needed. One location no longer overwrites the shared
81
+ function metadata used by another location. The current importer retains the
82
+ outermost entry of an inline-location chain; expanding all inlined functions
83
+ is outside this change.
84
+
85
+ Negative Go heap delta weights now import as separate negative-magnitude and
86
+ positive-contribution profiles. Compare positive minus negative in absolute mode
87
+ to inspect net changes; see [signed pprof semantics and limits](PPROF_IMPORT.md).
88
+ This does not add arbitrary-precision weights, a metric chooser or full inline
89
+ chains. See the [pprof schema used by the importer](../src/import/profile.proto).
90
+
91
+ ## Background import for large recordings
92
+
93
+ ### Streaming perf and folded stacks
94
+
95
+ UTF-8 folded stacks and `perf script` text now stream plain or gzip input into
96
+ the same incremental parsers used by ordinary imports. Supported suffixes are
97
+ `.folded`, `.collapsed`, `.stacks`, `.collapsedstack.txt`, `.perf`, `.perf.txt`
98
+ and `.linux-perf.txt`, optionally followed by `.gz`. Ordinary `.txt` files can
99
+ be detected as either format. Other names retain generic format detection.
100
+
101
+ The reader does not retain the complete expanded byte buffer, decoded text or
102
+ an array of all lines. It retains one bounded line and, for perf, one bounded
103
+ event. Input limits are 1 GiB expanded bytes, 1 Mi UTF-16 code units per line,
104
+ 4 Mi code units per perf event, 65,536 stack frames and two million samples.
105
+ A limit failure stops import; it does not retry through an unbounded reader.
106
+ Malformed weights and existing perf ordering checks remain enforced.
107
+
108
+ This path also runs for small compressed inputs and when workers are unavailable.
109
+ It yields during parsing, exposes progress and supports cancellation. Gzip needs
110
+ native `DecompressionStream`; unavailable native decompression, UTF-16 input and
111
+ other recognized formats retain the generic fallback. Final trees, sample lists,
112
+ symbol processing and worker snapshots still scale with the recording.
113
+
114
+ ### Worker routing and fallback
115
+
116
+ Inputs of at least **1 MiB** use a Web Worker when available, regardless of
117
+ filename extension. This includes perf, folded stacks, pprof, JFR, Android
118
+ method traces, supported ZIP archives and renamed captures. Format detection,
119
+ generic parsing, demangling and profile snapshot preparation happen away from
120
+ the main UI thread. Cancelling the task terminates its worker.
121
+
122
+ Recognized gzip perf/folded/text suffixes prefer a worker at any compressed
123
+ size: a tiny compressed file can expand into a large recording. Small plain
124
+ text stays on the main thread. The bounded text reader yields for cancellation
125
+ when a worker is blocked or unavailable; native gzip streaming requires
126
+ `DecompressionStream`. Unsupported encodings and unavailable streaming APIs use
127
+ the existing generic fallback, which can materialize the full input.
128
+
129
+ The worker first attempts the duration-trace and supported text streaming paths,
130
+ then uses the generic importer when those formats do not apply. Generic fallback
131
+ formats still read/materialize their input and retain their final model; routing them
132
+ through a worker does not make them streaming or out-of-core. Snapshot transfer,
133
+ geometry and final view construction still have memory costs proportional to
134
+ the recording. [Large-trace guidance](LARGE_TRACE_PERFORMANCE.md) describes the
135
+ duration-trace limits and measurements separately.
136
+
137
+ If workers are unavailable or blocked by a host's CSP, the app falls back to
138
+ the main-thread importer. DOM-dependent formats can also fall back after worker
139
+ detection. A transferred input buffer is returned before this fallback, so the
140
+ main thread does not attempt to parse an empty detached buffer. Synchronous
141
+ generic fallback parsing can block the UI until it returns; the streaming text
142
+ and asynchronous ZIP importers yield and check cancellation on the main thread.
143
+
144
+ Oversized supported ZIP files receive a four-byte signature preflight before
145
+ their complete body is read, both in the main importer and worker path. Other
146
+ formats retain their existing input/resource policies; the ZIP compressed-size
147
+ limit is not a blanket cap on every supported recording.
148
+
149
+ ### Text-stream measurements
150
+
151
+ Three fresh Node 24.19.0 ARM64 processes per mode imported a synthetic file
152
+ containing one million copies of `root;worker;leaf 1`: 19,000,000 plain bytes
153
+ or 46,140 gzip bytes. All modes produced one profile with total weight 1,000,000.
154
+ The final model is deliberately tiny, which isolates temporary input costs;
155
+ these figures do not predict memory for a million distinct stacks.
156
+
157
+ | Mode | Plain median time / peak RSS | Gzip median time / peak RSS |
158
+ | --- | ---: | ---: |
159
+ | Generic materializing importer | 466 ms / 110 MiB | 853 ms / 300 MiB |
160
+ | Streaming with worker-style scheduling | 573 ms / 86 MiB | 629 ms / 66 MiB |
161
+ | Streaming with main-thread cooperative yields | 993 ms / 85 MiB | 1,092 ms / 66 MiB |
162
+
163
+ Peak RSS columns are medians of each fresh process's peak, not retained model
164
+ heap. Worker-style measurements skip unnecessary timer yields, as the worker
165
+ can be terminated externally. They time the parsing function over a Node file
166
+ stream, excluding actual worker startup, demangling, snapshot transfer and view
167
+ construction. The cooperative path permits UI cancellation when no worker is
168
+ available; Windows timer overhead makes it slower in this test. Plain-text
169
+ streaming trades some throughput for lower memory even without those yields.
170
+
171
+ Reproduce with `node scripts/benchmark-profile.mjs <path> import`,
172
+ `text-stream-import` (worker-style scheduling), or `text-stream-main-import`
173
+ (cooperative scheduling). Do not compare these folded-stack figures with PLC
174
+ duration-trace timings as if they used the same input or parser.
@@ -0,0 +1,37 @@
1
+ # Java thread-dump snapshots
2
+
3
+ Import traditional HotSpot text output from `jstack PID` or
4
+ `jcmd PID Thread.print` by opening a `.jstack` file or a text file containing
5
+ the `Full thread dump …` header. Concatenate captures from the same JVM to
6
+ compare observed stacks across repeated snapshots. You can also open a ZIP of
7
+ traditional text captures from the same JVM; see [archive limits and supported
8
+ ZIP formats](JAVA_THREAD_DUMP_ZIP.md).
9
+
10
+ Each observed Java stack contributes one raw sample. The importer creates an
11
+ aggregate profile per thread name and Java thread ID, falling back to `tid`
12
+ when the Java ID is absent. Renamed threads appear separately. Missing threads
13
+ and threads without Java frames add no samples. The profile selector switches
14
+ between threads; Left Heavy, Sandwich and Call Tree show the observations.
15
+ Time Order is unavailable because snapshots do not measure execution duration.
16
+ CPU, elapsed, timestamps, state and lock text are not converted into weights.
17
+
18
+ Frames retain method/module names and available source files and positive line
19
+ numbers. Native Method and Unknown Source entries keep their identity without
20
+ inventing a source location. Deadlock summaries are ignored because they repeat
21
+ stacks already listed in the snapshot. Malformed thread headers, malformed Java
22
+ frames and duplicate thread identities within a snapshot produce an import error.
23
+
24
+ The parser iterates lines and retains the current stack and current snapshot's
25
+ thread identities, rather than collecting every line or observation. The text
26
+ input and resulting profile model still occupy memory; this format does not use
27
+ the duration-trace streaming importer. Prefer captures from one JVM per file.
28
+ The ZIP importer instead feeds bounded UTF-8 lines into the same parser and
29
+ checks both declared and actual decompressed sizes. Structured virtual-thread
30
+ JSON, native address stacks and lock/state visualization remain outside the
31
+ supported format. Unsupported ZIP variants can be extracted before importing
32
+ their text captures.
33
+
34
+ The checked-in [synthetic example](../sample/profiles/java-thread-dump/synthetic.jstack)
35
+ contains repeated snapshots and source locations. Format references are
36
+ [OpenJDK's traditional dump examples](https://github.com/openjdk/jdk/blob/master/test/hotspot/jtreg/serviceability/tmtools/jstack/utils/DefaultFormat.java)
37
+ and the [Oracle Java troubleshooting guide](https://docs.oracle.com/en/java/javase/21/troubleshoot/troubleshooting-guide.pdf).
@@ -0,0 +1,65 @@
1
+ # Java thread-dump ZIP archives
2
+
3
+ Open a ZIP containing traditional HotSpot `jstack` / `jcmd Thread.print` text
4
+ captures from **one JVM**. The same thread name and Java thread ID identify a
5
+ thread across snapshots; renamed threads remain separate. Each observed Java
6
+ stack contributes one raw sample, not measured elapsed time. Missing threads
7
+ and entries without Java stacks contribute no samples.
8
+
9
+ Entries are processed in deterministic, case-sensitive filename order, not ZIP
10
+ insertion order or file modification time. For example, `1.jstack`, `10.jstack`,
11
+ then `2.jstack` is the lexical order. The result is aggregate, so this ordering
12
+ does not claim a timeline or attach elapsed durations to snapshot intervals.
13
+ Every `.jstack` entry must contain its own `Full thread dump` header near the
14
+ start. Each entry boundary closes the previous snapshot.
15
+
16
+ The importer recognizes `.jstack`, `.txt`, `.log`, `.dump` and `.tdump` entries
17
+ with a `Full thread dump` header within the first 64 KiB. Other regular files
18
+ and ordinary notes are ignored as profile input, but still undergo bounded
19
+ decompression and checksum validation. Directories are skipped. Text is strict
20
+ UTF-8; UTF-16 dumps should be converted or imported as separate text files.
21
+
22
+ ## Resource policy
23
+
24
+ | Resource | Maximum |
25
+ | --- | ---: |
26
+ | Compressed archive | 32 MiB |
27
+ | Archive entries, including directories | 512 |
28
+ | Decompressed bytes per entry | 16 MiB |
29
+ | Total decompressed bytes, including ignored files | 64 MiB |
30
+ | UTF-8 filename bytes | 512 |
31
+ | Path depth | 8 components |
32
+ | Decoded line length | 65,536 UTF-16 code units |
33
+
34
+ Declared sizes are checked before decompression. Actual expanded bytes are
35
+ checked on every output chunk before decoding or parsing, so lying ZIP headers
36
+ cannot bypass the limits. The inflater emits chunks of at most 16 KiB; a limit
37
+ violation can allocate that one output chunk before it is rejected. It never
38
+ accumulates the whole expanded entry. The line decoder retains at most one
39
+ bounded line, while the parser retains the current stack, current snapshot's
40
+ thread identities and the resulting profile builders. The compressed input and
41
+ final profile model still occupy memory; this is not an out-of-core viewer.
42
+ The importer yields during work and supports cancellation without returning a
43
+ partially imported group.
44
+
45
+ ## Supported ZIP subset
46
+
47
+ Single-disk ZIP32 archives using **STORE** or **DEFLATE** are supported, including
48
+ ordinary data descriptors. Local/central headers, entry extents, decompressed
49
+ sizes and CRC32 checksums must agree. Paths are validated without extracting
50
+ anything to disk. Absolute/traversal paths, duplicate or case-colliding names,
51
+ file/directory conflicts, symlinks, special files and non-normalized Unicode
52
+ paths are rejected. Names must be ASCII or explicitly UTF-8.
53
+
54
+ Encrypted archives, ZIP64, split archives, self-extracting prefixes, archive
55
+ padding, alternate Unicode-path extra fields and other compression methods are
56
+ unsupported. Extract an unsupported archive yourself and open its text captures
57
+ individually or concatenate them into one `.jstack` file.
58
+
59
+ The checked-in [synthetic archive](../sample/profiles/java-thread-dump/synthetic.zip)
60
+ contains two short snapshots of the same thread. This is an independently
61
+ implemented ZIP32 reader based on
62
+ [PKWARE's ZIP specification](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT),
63
+ using the existing
64
+ [pako incremental inflater](https://github.com/nodeca/pako/blob/1.0.6/lib/inflate.js).
65
+ It does not use JSZip's whole-entry `async('string')` allocation path.
@@ -1,5 +1,77 @@
1
1
  # Large trace performance follow-up
2
2
 
3
+ ## Long-timeline GPU precision (2026-11-21)
4
+
5
+ The renderer previously uploaded absolute time coordinates as float32. Near
6
+ 6,000 seconds in a microsecond recording, endpoints 100 microseconds apart could
7
+ round to the same GPU value, making a call disappear at high zoom. A synthetic
8
+ [late-call recording](../sample/profiles/speedscope/long-late-calls.speedscope.json)
9
+ reproduces that failure, including early and late rectangles in one wide batch.
10
+
11
+ Rectangles are now clipped against the current atlas/source tile using CPU
12
+ doubles, then normalized before upload. The shader transforms unit coordinates
13
+ to the destination. Profile times, range-tree bounds, atlas keys, hit testing,
14
+ frame colors and measured durations retain their existing identities and values.
15
+ Each batch keeps one buffer and one full source-rectangle cache key; a shared
16
+ staging allocation is capped at 1,200,000 bytes for 10,000 rectangles. Switching
17
+ an uncached tile can require another bounded CPU normalization/upload; cached
18
+ tiles and unchanged source rectangles reuse their data. Final profile and GPU
19
+ buffer storage still scale with the recording.
20
+
21
+ Five regressions check real uploaded float32 coordinates and the renderer's
22
+ uniform transform, adjacent late calls, negative/spanning clipping, source
23
+ origin/extent changes, shared staging ownership, buffer lifecycle and limits.
24
+ Browser QA showed both 100-microsecond calls near 6,000 seconds, including after
25
+ overview reset/refocus. The private PLC imported four profiles and rendered
26
+ Time Order, Left Heavy and Sandwich's inverted callers/callees correctly during
27
+ pan/zoom checks, with no browser errors.
28
+
29
+ A warmed Node smoke using a preallocated-copy mock upload and source rectangles
30
+ covering almost all 10,000 rectangles measured about 0.19 ms per repack and
31
+ 2.6 ms for 100,000 unchanged-source requests, with one buffer allocation. These are local CPU
32
+ measurements, not browser/GPU frame-rate claims. This addresses the demonstrated
33
+ float32 failure associated with [#467](https://github.com/jlfwong/speedscope/issues/467);
34
+ the original upstream capture remains unavailable for direct comparison. These
35
+ buffer/matrix tests also extend [#125](https://github.com/jlfwong/speedscope/issues/125),
36
+ but do not replace a browser/GPU pixel-regression harness.
37
+
38
+ Final local verification passed all 418 Jest tests in 72 suites with 307
39
+ snapshots on checksum-verified Node 22.23.5 ARM64 using a clean Jest cache.
40
+ The five Node tests, type checking, lint, schema and backlog checks passed
41
+ separately on the system Node runtime. Two full Jest runs on local Node 24.19.0
42
+ ARM64 exited with native access violations without an assertion failure, so a
43
+ green local Node 24 full-suite result is not claimed. GitHub's Windows/Linux
44
+ Node 22/24 matrix validates the branch independently before merge.
45
+
46
+ ## Fixed-height Sandwich list geometry (2026-11-21)
47
+
48
+ Sandwich already rendered a viewport window. It now calculates that window and
49
+ initial scroll offset directly from row count/height, removing the size object
50
+ per frame and full-list geometry scans. A single cached selected-frame/index
51
+ replaces the frame-index Map: repeated, adjacent and wrap-around navigation are
52
+ constant time; unrelated new selections scan the existing sorted array once.
53
+ Missing results are cached. Element resizing updates the viewport and filtering
54
+ clamps stale scroll offsets, even without a browser-generated scroll event.
55
+
56
+ Tests cover 100,000-row selection/navigation, billion-row arithmetic without a
57
+ row allocation, visible-row bounds, filter shrink, resize and cleanup. The
58
+ billion-row case tests arithmetic only: browser scroll-height limits still apply.
59
+ The sorted row array, model, sorting and graph/color geometry remain proportional
60
+ to the recording. These changes reduce auxiliary storage and repeated work;
61
+ they do not establish a fully bounded-memory viewer.
62
+
63
+ Combined validation passed 410 Jest tests in 71 suites (307 snapshots), five
64
+ Node tests, type checking, lint, schema/backlog checks and both builds. The
65
+ private PLC gzip still exported four profiles, 17,510 frames and 1,039,656 call
66
+ events with the established SHA-256
67
+ `522de77afbfc4dd94f1f30c3a9551979d12db506305ffef999db9c910ae8eddb`.
68
+ The local Node streaming smoke took about 4.3 seconds to import; this is not a
69
+ browser performance guarantee or a claim of faster importing in this batch.
70
+ In browser QA the first PLC profile's 16,231-frame table rendered 40 rows at the
71
+ scroll end, clamped to zero when filtered to one row, and updated to 49 rendered
72
+ rows after a viewport resize. A generated local function link restored its
73
+ selection after reopening the same PLC recording in another tab.
74
+
3
75
  Baseline: `eb93425`, reviewed 2026-11-18. These changes continue the open-issue
4
76
  review, prioritizing large profiles and the export request in issue #89.
5
77
 
@@ -86,9 +158,261 @@ completed download, disabled Time Order for aggregates and combined-stack
86
158
  inversion. The downloaded JSON was compared exactly with the standard exporter,
87
159
  then reimported with all profile totals preserved.
88
160
 
89
- Import parsing and derived transformations still run on the main thread. They
90
- remain in-memory operations; lazy folded parsing does not make JSON or binary
91
- imports streaming. Export retains the final Blob bytes and source profile, while
92
- bounding temporary serialization chunks (apart from an individually huge string).
93
- Worker-backed import/transforms, cancellation during import, signed comparisons
94
- and synchronized multitrack timelines remain separate architectural follow-ups.
161
+ ## Worker import and search follow-up
162
+
163
+ Large input files (at least 1 MiB of input bytes) named `.json`, `.trace`,
164
+ `.cpuprofile` or `.heapprofile`, optionally gzip-compressed, now use a browser
165
+ worker when available. The existing format detector is reused, preserving its
166
+ dispatch order. HTTP/profileURL, local File and CLI base64 loading use this path.
167
+ Input buffers and numeric profile tables transfer ownership instead of being
168
+ JSON-serialized or cloned as full call-tree objects. File inputs can be read in
169
+ the worker. Symbols are demangled there before returning immutable profile data.
170
+
171
+ The UI shows import progress and cancellation. Cancellation terminates the worker;
172
+ new loads and unmounts cancel old imports, and stale results cannot replace newer
173
+ profiles or clear their loading state. The worker is released before UI object
174
+ reconstruction, which yields between bounded batches so it can also be cancelled.
175
+ Worker creation blocked by a host can fall back to the ordinary importer. An
176
+ unexpected worker crash reports an error rather than trying a detached buffer.
177
+ Small files and other filename extensions retain the ordinary importer; that
178
+ synchronous fallback cannot be interrupted during parsing.
179
+
180
+ The worker code is embedded by the build plugin, so both HTTP and offline builds
181
+ can create it without fetching a worker script or WASM from an external host.
182
+ The transport is an internal implementation detail, not a public interchange API.
183
+
184
+ Tests cover numeric/string frame identity, recursion, source locations, formatting,
185
+ aggregate/derived flags, idle ranges, transferred buffers, deep trees, invalid
186
+ references, cancellation, worker cleanup, host fallback and stale-load races.
187
+ The PLC worker import was cancelled interactively while parsing, then completed;
188
+ its exported JSON matched the ordinary importer exactly (four profiles, 17,510
189
+ frames and 1,039,656 call events). A local snapshot smoke check measured 214 ms to
190
+ encode the PLC profiles and 34,602,732 bytes of numeric tables (excluding frame
191
+ strings and metadata). Browser elapsed-time/peak-RSS speedups are not claimed.
192
+
193
+ Search also supports literal whole-word and exact matching. Patterns are reused
194
+ per query and file-only checks avoid allocating name highlight ranges. Unicode
195
+ word boundaries, punctuation, escaped metacharacters and full-name/path matching
196
+ have regressions. User-provided regex is still not enabled.
197
+
198
+ Profile trees and rendering remain in-memory operations. Unsupported formats
199
+ still use the original full-document importer. UI hydration and rendering have
200
+ costs, and transferring work can increase overall elapsed time even while making
201
+ the interface responsive. This does not fix every OOM report. Derived
202
+ transformations other than frame filtering remain synchronous. Frame filtering
203
+ visits grouped paths and yields during traversal, with cancellation; final tree
204
+ sorting remains synchronous. See [filter behavior and limits](PROFILE_FILTERS.md).
205
+ Export retains the final
206
+ Blob bytes and source profile while bounding temporary serialization chunks
207
+ (apart from an individually huge string). An out-of-core model, heap budgets,
208
+ worker-backed transforms, signed comparisons and synchronized timelines remain
209
+ separate follow-ups in [the maintained backlog](ISSUE_BACKLOG.md).
210
+
211
+ ## Streaming duration traces
212
+
213
+ Large duration-event `.json`/`.trace` files, optionally gzip-compressed, now use
214
+ incremental parsing inside the worker. A local File is streamed without reading
215
+ its whole contents; transferred ArrayBuffers are consumed in 64 KiB slices.
216
+ Native `DecompressionStream` inflates gzip incrementally. The streaming parser
217
+ ([@streamparser/json](https://github.com/juanjoDiaz/streamparser-json), pinned at
218
+ 0.0.26) releases completed event objects from its parent array. We retain the
219
+ duration events, naming metadata and first event needed by the existing Hermes
220
+ discriminator, dropping unused event fields and ignored events. Event arguments
221
+ remain intact because they participate in frame identities.
222
+
223
+ This avoids a full inflated byte buffer, a whole JSON string and a complete
224
+ parsed input object. Out-of-order traces still need stable sorting, so retained
225
+ events and constructed trees continue to scale with the capture. This is not an
226
+ out-of-core profile store or a hard bound on total JavaScript/browser memory.
227
+
228
+ The streaming path rejects excessive input complexity before returning a profile:
229
+
230
+ | Limit | Default |
231
+ | --- | ---: |
232
+ | Decompressed input | 1 GiB |
233
+ | Pending event/metadata bytes between completed events | 16 MiB |
234
+ | Retained event source bytes | 256 MiB |
235
+ | Input events, including ignored events | 2,000,000 |
236
+ | JSON nesting depth | 128 |
237
+
238
+ Checks run before bounded parser writes and while tokens/events are emitted.
239
+ The pending-byte check is conservative at chunk boundaries. These are source
240
+ complexity limits, not heap accounting: object overhead, expanded Unicode,
241
+ sorting, call-tree nodes, numeric snapshots, hydration and GPU resources have
242
+ additional costs. A limit failure stops with an actionable error; it never
243
+ silently truncates the trace or retries the full importer. Cancellation releases
244
+ the reader and terminates the worker; source cancellation failures cannot hide
245
+ the original error.
246
+
247
+ Native CPU/heap/speedscope files and known filename overrides retain their
248
+ detector. CPU markers anywhere in the stream, sample tables, duplicate root
249
+ `traceEvents` properties and unrecognized wrapper properties return to that
250
+ detector, preserving their original semantics. Those fallback formats do not
251
+ gain these streaming budgets. Gzip also falls back when native decompression is
252
+ unavailable. URL/CLI loading still buffers the input response before transfer;
253
+ local File streaming avoids that buffer. Tolerated trailing commas and missing
254
+ final `]` after complete array events remain supported. Incomplete values and
255
+ corrupt gzip fail rather than producing a partial result.
256
+
257
+ Validation includes every duration-trace fixture against the ordinary importer,
258
+ one-byte UTF-8/escape boundaries, late metadata, argument identity, unordered and
259
+ anonymous events, sampled/CPU fallback, ignored payloads, gzip File imports with
260
+ whole-file reads forbidden, resource-limit failures, and cancellation races.
261
+ The PLC capture exported identically: four profiles, 17,510 frames, 1,039,656
262
+ call events and matching totals. Fresh-process Windows/Node 24 import-only runs:
263
+
264
+ | Path | Import time | Peak RSS | Heap after import |
265
+ | --- | ---: | ---: | ---: |
266
+ | Ordinary importer | 2,281 ms | 999 MiB | 572 MiB |
267
+ | Streaming duration importer | 4,311 ms | 623 MiB | 437 MiB |
268
+
269
+ This single capture/run measured about 38% lower peak RSS at a latency cost.
270
+ Browser peak memory, rendering and worker hydration are not represented by this
271
+ Node benchmark. Results vary by machine, input and garbage collection. Reproduce
272
+ each path in its own process with `node scripts/benchmark-profile.mjs <capture>
273
+ import` and `node scripts/benchmark-profile.mjs <capture> stream-import`.
274
+
275
+ Issues #519, #347, #478, #386 and #404 remain **partial** in the backlog: the
276
+ specific original reproductions and a general bounded-memory profile model still
277
+ need work.
278
+
279
+ ## Faster streaming event parsing
280
+
281
+ CPU profiling of the first streaming implementation showed substantial time in
282
+ token parsing, per-property assignment, selector matching and callbacks. The
283
+ worker now scans structural bytes to frame each complete event object, then
284
+ decodes and parses that one object with native `JSON.parse`. The token parser
285
+ still validates the wrapper/array grammar and handles other values. The bounded
286
+ event framing scan tracks string escapes and nesting; it does not interpret
287
+ fields or split on text delimiters. A rare permissive retry retains the existing
288
+ trailing-comma behavior.
289
+
290
+ No whole-document string or inflated buffer is introduced. Events spanning read
291
+ boundaries use a temporary buffer for that one event. The existing decompressed,
292
+ pending, retained, event-count and depth limits remain in force, including while
293
+ framing native records. Truncated later records cannot be silently dropped when
294
+ repairing a producer's omitted final array bracket. Additional regressions cover
295
+ all small chunk sizes, large records, split UTF-8/escapes, malformed inner and
296
+ outer grammar, and the existing fallback/cancellation/limit cases.
297
+
298
+ Three alternating fresh-process runs of the same PLC capture on Windows/Node 24
299
+ compared the previous streaming bundle (`39b264b`) with native event framing:
300
+
301
+ | Metric | Previous streaming | Native event framing |
302
+ | --- | ---: | ---: |
303
+ | Import times | 4,255 / 4,336 / 4,423 ms | 2,493 / 2,563 / 2,445 ms |
304
+ | Median import time | 4,336 ms | 2,493 ms |
305
+ | Peak RSS | 612 / 613 / 615 MiB | 579 / 573 / 581 MiB |
306
+ | Median peak RSS | 613 MiB | 579 MiB |
307
+
308
+ That is about 43% faster while retaining (and slightly improving) the previous
309
+ memory reduction. These are import-only process measurements, not browser
310
+ rendering or hydration measurements. Each revision's `benchmark-profile.ts` was
311
+ bundled separately with esbuild (Node/CommonJS, ES2020, binary WASM) and run with
312
+ the capture path and `stream-import` action, alternating revisions without
313
+ explicit garbage collection. Captures and timing logs are not committed.
314
+ The full exported profiles match the ordinary importer, including all four
315
+ profiles, 17,510 frames, 1,039,656 call events and profile totals.
316
+
317
+ The same follow-up fixes issue #199's deep-zoom axis labels: formatting receives
318
+ the visible tick interval, tick generation clamps below floating-point precision,
319
+ and overlapping labels are skipped. V8 source-path extraction and exact-first
320
+ sourcemap matching (with empty maps ignored) improve #446, which remains partial
321
+ because automatic linked map discovery/loading is still separate work. The
322
+ maintained backlog records these completion boundaries explicitly.
323
+
324
+ ## Smaller duration queues and bounded selected-stack details
325
+
326
+ The 2026-11-20 follow-up reuses complete (`X`) events as begin records rather
327
+ than spreading every event into another full object. Synthesized end records
328
+ retain only their timestamp, name and shared arguments. Source positions and
329
+ argument-based frame identity remain unchanged. Queues already ordered by time
330
+ skip stable-sort workspace; unordered queues still use the existing stable sort,
331
+ including equal-timestamp and epoch-rounding behavior. No additional event index
332
+ is retained. The streaming limits are unchanged.
333
+
334
+ Three alternating fresh-process runs on Windows/Node 24 compared `f6c5d43`
335
+ against this change, using the same ES2020 CommonJS benchmark bundle options:
336
+
337
+ | Capture / metric | Before | After |
338
+ | --- | ---: | ---: |
339
+ | PLC import times (ms) | 2,609 / 2,524 / 2,579 | 2,562 / 2,546 / 2,562 |
340
+ | PLC median peak RSS (MiB) | 576 | 576 |
341
+ | Complete-event fixture import times (ms) | 1,131 / 833 / 822 | 986 / 767 / 779 |
342
+ | Complete-event fixture median peak RSS (MiB) | 362 | 295 |
343
+ | Complete-event fixture median heap at import (MiB) | 224 | 155 |
344
+
345
+ The synthetic fixture contains 250,000 sequential complete events with 5,000
346
+ distinct argument-based frame keys. Its median peak RSS fell about 19%; PLC
347
+ performance remained essentially unchanged. These are process import measurements,
348
+ not browser hydration/rendering or hard heap bounds. Separate full-export checks
349
+ matched the baseline hash for both captures. PLC still exports four profiles,
350
+ 17,510 frames and 1,039,656 call events. Captures and benchmark artifacts are not
351
+ committed. Reproduce import measurements with `node scripts/benchmark-profile.mjs
352
+ <capture> stream-import`; do not include export validation in import-only RSS.
353
+
354
+ Selected-stack details now retain/render at most 100 ancestor rows and follow
355
+ parent pointers only as pages are requested, without building the full ancestor
356
+ list. All scopes remain reachable through older-page and reset controls. Clicking
357
+ one selects the exact ancestor instance; see [stack navigation](SEARCH_AND_LAYOUT.md#navigate-selected-stack-ancestors).
358
+ Tests include a 100,000-level chain with a guarded page boundary. The PLC's
359
+ deepest seven-scope stack was paged without changing the export hash.
360
+
361
+ Issues #519, #478, #386, #347 and #404 remain partial: the final profile model,
362
+ worker snapshots, unordered sorts and graph rendering still grow with capture
363
+ size. This work reduces specific temporary allocations and bounds the details
364
+ panel, without claiming an out-of-core viewer or fixing every reported OOM.
365
+
366
+ Validation passed 339 Jest tests across 58 suites (307 snapshots), five Node
367
+ tests, type checking, linting, schema/backlog checks, both builds and a dry-run
368
+ npm contents check. Browser smoke checks used a 220-level profile to verify
369
+ 100-row pages, access to the root, reset controls, Enter/Space selection and
370
+ visible ancestor highlighting below the time axis, without console errors.
371
+
372
+ ## Bounded graph-search state
373
+
374
+ On 2026-11-21, graph search stopped eagerly caching every source symbol and
375
+ allocating navigation geometry/index entries for every matching call. Per query,
376
+ boolean frame results are capped at 4,096 entries and drawn-label ranges at
377
+ 512 entries with at most 64 ranges each. Time Order/Left Heavy navigation keeps
378
+ the first 10,000 matches and checks for one further match to establish
379
+ truncation. The search UI displays a `+` lower bound and a visible refinement
380
+ notice; it never claims the truncated count is complete. Matching/highlighting
381
+ can continue beyond that navigation window.
382
+
383
+ Three alternating fresh-process Windows/Node 24 runs compared `a72d309` with
384
+ bounded search on the PLC's first profile (513,009 graph frames), using a broad
385
+ single-space query:
386
+
387
+ | Search-only metric | Before | After |
388
+ | --- | ---: | ---: |
389
+ | Initialization times (ms) | 96 / 89 / 94 | 3 / 3 / 4 |
390
+ | Retained search heap after explicit GC (MiB) | 119.60 / 119.60 / 119.60 | 0.907 / 0.907 / 0.906 |
391
+ | Retained navigation matches | 513,009 | 10,000 (explicitly limited) |
392
+
393
+ This is a deliberate navigation-limit tradeoff, not equivalent full-result
394
+ enumeration. Separate single-run checks found the same 40 `GroupCalls` matches
395
+ (14 → 22 ms) and zero matches for a nonexistent symbol (14 → 25 ms). Those sparse
396
+ queries retain about half as much search heap, but can be slower because cached
397
+ entries are recomputed. These are Node search measurements after import and graph
398
+ construction, not whole-app memory caps or browser latency guarantees.
399
+ The measured initialization counts results and opens the first ten; it does not
400
+ draw labels or measure browser rendering.
401
+
402
+ The PLC import/export check still reports four profiles, 17,510 source frames
403
+ and 1,039,656 call events, with the unchanged baseline export hash. Captures and
404
+ benchmark artifacts remain private/uncommitted. The maintained benchmark adds
405
+ `node scripts/benchmark-profile.mjs <capture> stream-search [query]` for streaming
406
+ import followed by bounded search of the first profile; its default query is a
407
+ single space. It reports the navigation limit and retained search heap separately
408
+ from input/model memory. Graph creation, worker snapshots, sorting, Sandwich
409
+ row lists and the final model remain proportional to recording size; the OOM
410
+ backlog stays partial.
411
+
412
+ Validation passed all 354 Jest tests across 62 suites (307 snapshots), five Node
413
+ tests, type checking, linting, schema/backlog checks, both builds and package
414
+ contents. Regressions cover cache eviction, dense-symbol range limits, exact
415
+ limit detection, late sparse matches, depth-first order and 25,000-level graphs.
416
+ Browser checks on 20,050 calls verified the visible limit notice, both keyboard
417
+ wrap directions, narrowing to a late result, and the root-label axis fix,
418
+ without console errors.