Skip to content

Commit 2f6fa35

Browse files
committed
Merge scoped instant tracks and bounded streaming collection
Add independent instant lanes, native/worker/chunked export support, original-event inspection and clock pagination. Preserve existing CPU/JIT routes and retain mixed stack/counter captures with explicit, export-preserved whole-marker omissions when optional point budgets are exceeded. Collect normalized metadata while framing streams and release raw arguments, preserving exact exports with substantially lower measured peak import RSS. Validation: 779 tests in 112 suites, 310 snapshots, five Node tests, type/lint/schema/backlog checks, all builds/package checks, browser dense-point/scoped/clock/omission flows and all four Windows/Linux Node 22/24 branch CI jobs passed. PLC counts and both payload hashes remain unchanged; async annotations and out-of-core storage remain documented work.
2 parents 841f576 + a092710 commit 2f6fa35

40 files changed

Lines changed: 3231 additions & 112 deletions

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ speedscope is designed to ingest profiles from a variety of different profilers
7272
- [Differential folded files](docs/PROFILE_COMPARISON.md#differential-folded-files), using explicit import to preserve ordinary numeric symbol names.
7373
- [Producer frame colors](docs/SOURCE_AND_LABELS.md), with theme contrast adaptation and exact RGB export.
7474
- [Numeric counter charts](docs/COUNTERS.md), including Trace Event `C` input and independent native time/value axes.
75+
- [Instant-event tracks](docs/INSTANT_EVENTS.md), with zero-duration points, coincident observations and bounded detail pages.
7576

7677
Contributions to add support for additional formats are welcome! Open an issue in
7778
[this fork](https://github.com/node-projects/speedscope/issues). Upstream importer
@@ -127,6 +128,9 @@ units. Trace Event counters keep unspecified units as `unknown`; explicit native
127128
metadata can declare bytes or other gauges. Markers use original observations,
128129
and dense ranges show bounded min/max envelopes. Counter-only captures and export
129130
are supported. See [counter semantics and limits](docs/COUNTERS.md).
131+
Trace Event instant points appear in separate scoped rows without inventing call
132+
durations. Use **Inspect events** for original timestamps and plain-text details;
133+
see [instant-event scope and limits](docs/INSTANT_EVENTS.md).
130134
Use **Profile actions → Link to selected function…** to share a function selection.
131135
For local recordings, the recipient opens the link and imports the same file.
132136
Same-tab links and browser Back/Forward update the function selection without

‎docs/IMPORT_FORMATS.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
The [README](../README.md#supported-file-formats) lists supported sources.
44
This guide describes additional fork-specific behavior and its limits.
55

6+
## Instant events
7+
8+
Trace Event phases `i`, historical `I` and `R` import as scoped points on
9+
independent lanes, including instant-only recordings. Missing scope defaults to
10+
thread; process and global scope remain distinct. Source wall `ts` uses
11+
microseconds regardless of `displayTimeUnit`. Equal-time points remain distinct;
12+
stack-looking metadata is inspectable text rather than invented execution.
13+
Recognized historical CPU-profile and JIT records retain their original routing.
14+
15+
The [instant-event guide](INSTANT_EVENTS.md) defines metadata and point budgets,
16+
native export and the paged inspector. Native/instant-only input exceeding a
17+
budget fails explicitly. For a mixed recording with valid stack/counter data,
18+
an instant resource limit excludes the entire marker set and records its count
19+
and reason in `instantEventOmission`. The app displays that notice in every
20+
view, and exports preserve it. Records in an excluded marker set are not fully
21+
validated. Malformed marker data that is processed before a resource limit
22+
still fails; there is no silent truncation or reinterpretation as weighted calls.
23+
624
## Perf clock weights
725

826
Explicit `perf script` periods now determine aggregate weights. CPU/task-clock

‎docs/IMPORT_VALIDATION_2026-11-21.md‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,40 @@ The shared-frame/profile payload hash above is unchanged.
308308
Browser checks covered rapid late-range zoom/pan, original call markers, source
309309
replacement resetting range/marker, and the authored example at 505 ms showing
310310
application/compute/read on the expected rows without console errors.
311+
312+
## Scoped instant-event tracks
313+
314+
The final local Node 22 run passed 779 tests across 112 suites with 310 snapshots.
315+
Five Node tests, typecheck, lint, schema/backlog checks and all build/package
316+
checks passed. Model/worker/native tests cover bounded ownership and frozen
317+
metadata reuse, explicit omissions, cancellation and chunked export. Importer
318+
regressions cover historical CPU routing, accessor-free detail reads, scope and
319+
timestamp semantics, resource-versus-malformed errors, tiny gzip/plain streams
320+
and the exact instant-only #402 input at 829 microseconds despite its ns display
321+
hint. Its stack array remains unresolved inspectable text.
322+
323+
The public #235/#236 input still imports 113 profiles and 12 counter series with
324+
406,923 observations; its 309,230 instant events exceed the new point budget and
325+
are all explicitly omitted. The count/reason survives export and the browser
326+
shows the notice in stack and Tracks views. A subsequent PLC import clears the
327+
notice, retaining four profiles/four counters and both hashes recorded above.
328+
329+
Browser tests also covered thread/process/global lanes, coincident source order,
330+
65 clock groups with 64 choices per page, original source origin/offset pairs,
331+
Escape/focus restoration and native omission-only metadata. An authored dense
332+
recording exposes all 25,000 events through 250 pages of at most 100 rows, draws
333+
250 representative ticks with an explicit 24,750 not-individually-drawn count,
334+
renders script-looking details as literal text, and exports all 25,000 points
335+
without synthetic profiles. No console errors were observed. The app preserves
336+
data or omission notices through stack actions, remapping, state and export.
337+
338+
Incremental streaming collection avoids retaining raw instant arguments beyond
339+
the current record (plus the first bounded discriminator event). Resource
340+
failures release normalized marker state while preserving exact recognized
341+
counts. Mixed/pure error precedence, first-event Hermes behavior, late CPU
342+
fallback, source argument mutation and tiny raw-retention budgets are covered.
343+
Three fresh-process input pairs matched exact chunked export hashes: normalized
344+
100k points peak RSS 116.3→94.0 MiB; excluded 300k points 289.5→91.0 MiB; public
345+
#235 576.1→499.7 MiB. Forced-GC liveness checks are separate from timing and show
346+
discarded argument objects released. Measurements and limits are detailed in
347+
LARGE_TRACE_PERFORMANCE; diagnostic captures/archives remain ignored.

‎docs/INSTANT_EVENTS.md‎

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Instant-event tracks
2+
3+
Instant events are observations at a timestamp. Tracks displays them separately from stack intervals and numeric counters. They have **no measured duration or sample weight**. An event's name, category and details do not become frame identity, create a call stack, or affect stack/counter totals.
4+
5+
Choose **Tracks** to inspect compatible clocks. Instant-only recordings are valid and do not require a synthetic stack profile. Equal-time events remain separate in source order; unlike numeric counter updates, they are not deduplicated into a last value.
6+
7+
## Native metadata
8+
9+
A native file can contain group-level `instantTracks` independently of `profiles` and `counterTracks`:
10+
11+
```json
12+
{
13+
"$schema": "https://www.speedscope.app/file-format-schema.json",
14+
"name": "Request markers",
15+
"shared": {"frames": []},
16+
"profiles": [],
17+
"instantTracks": [{
18+
"id": "request-marks",
19+
"name": "Request markers",
20+
"clock": "trace-event:wall",
21+
"timeUnit": "microseconds",
22+
"start": 1000,
23+
"scope": "thread",
24+
"processId": "42",
25+
"threadId": "7",
26+
"times": [0, 10, 10],
27+
"events": [
28+
{"name": "received", "category": "request"},
29+
{"name": "cache miss", "details": "Request id: abc"},
30+
{"name": "retry scheduled"}
31+
]
32+
}]
33+
}
34+
```
35+
36+
`id` is unique within the recording; `name` labels the lane. `clock` is a recording-local clock, not evidence that separate recordings are synchronized. `start` is the finite raw source timestamp of local zero, in the explicit time unit. `times` contains finite, nonnegative, nondecreasing offsets from that origin. Supported units are nanoseconds, microseconds, milliseconds and seconds. Equal times preserve all corresponding events. Empty lanes are valid metadata but have no observed points to display.
37+
38+
`scope` is explicitly `thread`, `process` or `global`. Optional process/thread IDs provide context. Each timestamp has exactly one `events` entry with a required name and optional category/details text. Details are plain text, including multiline text; they are not HTML, executable data, or a promise that embedded stack-looking data describes measured execution. Unknown event-object fields are not retained by model validation.
39+
40+
Native object/chunked exports, worker snapshots and source-map/profile-action group changes preserve instant tracks. Internal timestamps use `Float64Array`; worker transfer deduplicates backing buffers and hydration validates ownership without copying the numeric array. Event metadata is copied and frozen when native/worker data becomes a completed model. Later validation/export reuses owned frozen metadata; timestamp arrays remain immutable by ownership convention and are still fully validated.
41+
42+
## Trace Event input scope
43+
44+
The supported point phases are `i`, historical `I`, and `R`. Scope `s: "t"` (or omitted) selects a thread lane; `s: "p"` selects a process lane, and `s: "g"` selects a global lane. Source lane identity preserves numeric versus string identifiers. Scope-irrelevant identifiers remain in details rather than artificially splitting a global/process lane into threads.
45+
46+
Timestamps use wall `ts` in microseconds, not `tts` or the trace's display-unit hint. Generic Trace Event points share the source-local `trace-event:wall` clock. Where points accompany supported Chrome Timeline CPU profiles, they use `chrome-timeline:wall`. Only matching explicit clocks and time units align with stack/counter rows.
47+
48+
Selected source fields (`pid`, `tid`, `id`, `id2`, `args`, `stack`, `sf`, `tts`) are preserved as bounded JSON **text** in details when present. An input such as `stack: ["a", "b", "c"]` remains inspectable metadata; it does not become invented duration or a weighted sampled profile. Malformed imported point timestamps/scopes/labels or unsupported details fail explicitly. Resource exclusions in mixed recordings follow the separate whole-set policy below.
49+
50+
Recognized historical `CpuProfile` payloads retain their existing sampled-CPU routing, even when a producer uses an instant phase. V8 `JitCodeAdded`/`JitCodeMoved` records are excluded from ordinary markers; this feature does not newly decode standalone JIT records. Asynchronous begin/end spans, flow/causal links, arbitrary metadata attached to existing call occurrences and manual annotation creation remain separate work.
51+
52+
Primary scope/phase evidence: [Chromium Catapult's pinned instant importer](https://github.com/catapult-project/catapult/blob/6fd8bbe723677254ff1130a1a416988b8b3e285e/tracing/tracing/extras/importer/trace_event_importer.html#L657), including its historical CPU/JIT distinctions. The fork renders explicit points rather than manufacturing a positive-duration slice.
53+
54+
## Overview and inspection
55+
56+
Instant lanes use bounded glyphs at source observation times. Dense ranges group
57+
points into time buckets, retaining at most 4,096 representative glyphs across
58+
visible instant lanes. Counts make omitted/coincident events explicit; they are
59+
not counts of measured calls or an invented duration. The display does not
60+
connect points into a continuous activity interval.
61+
62+
Use **Inspect events** on a lane to read the original events in the selected
63+
viewport. The list is paged at 100 events, retains equal-time entries in order,
64+
and expands details for one event at a time. Details are selectable plain text.
65+
Inspection reads original arrays rather than treating overview representatives
66+
as the complete data. Shared clock and navigation behavior is described in
67+
[MULTI_TRACK.md](MULTI_TRACK.md).
68+
Clock choices are paged 64 at a time; changing clock pages selects that page's
69+
first group. Replacing the source clears stale event details and clock paging.
70+
71+
The inspector shows source origin and local offset separately. A computed source
72+
timestamp is explicitly labeled as potentially rounded, and is omitted if its
73+
sum is nonfinite. Overview readouts distinguish exact source-time coincidences
74+
from different offsets that collide at shared floating-point display precision.
75+
76+
## Resource exclusions in mixed recordings
77+
78+
Trace recordings that already contain stack profiles or counters keep that data
79+
when instant events exceed a supported resource budget. The importer excludes
80+
the **entire** instant-event set and attaches a persistent notice with the count
81+
of recognized instant events and the reason. It never returns a partial marker
82+
array or represents the retained subset as complete.
83+
84+
Mixed-recording preflight can count more than 250,000 recognized instant events
85+
and exclude them before building their metadata. **Excluded marker records are
86+
not fully validated.** The same whole-set policy applies when track, metadata or
87+
details budgets are exceeded. Stack/counter validation is unchanged; malformed
88+
marker data being imported still fails. A pure instant-only recording over a
89+
resource limit fails rather than becoming an empty successful import.
90+
91+
The streaming duration reader normalizes instant metadata as each record arrives
92+
instead of retaining a second raw marker/argument array. On the first marker
93+
failure it releases collected lane data and continues counting recognized
94+
points. Errors are resolved after the stack/counter group is known, preserving
95+
the same mixed/pure policy and late CPU-format fallback. Only the first bounded
96+
source event is also retained for the existing Hermes discriminator. Existing
97+
input-byte, per-record pending-byte, event-count, JSON-depth and cancellation
98+
guards still apply. Stack/counter raw records retain their existing sorting
99+
budget; normalized marker state uses the separate point/metadata budgets below.
100+
Generic full-array import keeps its count-first shortcut for oversized mixed
101+
marker sets, but still materializes that original input array.
102+
103+
The notice survives native export and worker transport as optional group-level
104+
metadata, for example:
105+
106+
```json
107+
"instantEventOmission": {"count": 309230, "reason": "point-limit"}
108+
```
109+
110+
The reason is one of `point-limit`, `track-limit`, `metadata-limit` or
111+
`details-limit`; the count must be a positive safe integer. No retained instant
112+
tracks accompany an omission summary. The summary preserves the fidelity
113+
warning when a mixed recording is exported; it cannot reconstruct omitted data.
114+
Native model data and worker payloads are validated strictly, including summary
115+
counts/reasons and contradictory retained-track/omission fields.
116+
Native `instantTracks` are never automatically omitted: malformed or over-limit
117+
model data fails validation even when the native file also contains stacks.
118+
119+
## Resource and export policy
120+
121+
- At most 256 lanes and 250,000 points in total.
122+
- At most 512 characters per label, 16,384 details characters per point, and 4,194,304 metadata characters in total. The total includes lane IDs/names/clocks/context plus event names/categories/details; shared labels count per observation. Labels are nonempty, trimmed and contain no control characters. Details can contain ordinary multiline text.
123+
- At most 2,000,000 bytes of unique retained timestamp backing buffers. Aliases count once; a tiny view into an oversized buffer is rejected.
124+
- Trace Event details are checked before serialization, with nesting depth at most eight and at most 4,096 visited values. Custom serializers, getters, cycles and nonfinite numeric details are unsupported.
125+
126+
Caps apply together. Metadata character counts use JavaScript UTF-16 string lengths. Timestamp/model arrays, parsed input, metadata objects and the exported artifact still occupy memory; these are resource limits, not a whole-process or out-of-core guarantee. Generic gzip/zlib fallback retains its [separate expansion limit](IMPORT_FORMATS.md#generic-gzipzlib-decompression).
127+
128+
Worker hydration and chunked Blob export yield periodically, support cancellation and report instant-specific export progress. Blob export writes timestamp and event entries in pieces, preserving owned metadata without constructing a full JavaScript number array. The synchronous object-export API deliberately materializes JSON-compatible arrays.

0 commit comments

Comments
 (0)