Skip to content

Format AutoAssertMaybeEventsDisallowed's message only when asserting - #190

Merged
Andarist merged 1 commit into
masterfrom
andarist/futex-wait-assert-format-when-recording
Oct 23, 2026
Merged

Andarist merged 1 commit into
masterfrom
andarist/futex-wait-assert-format-when-recording

Conversation

@Andarist

Copy link
Copy Markdown
Member

The scope formatted its message into a heap-allocated string even when not recording or replaying, where it never asserts, so every Atomics.wait and Atomics.waitAsync paid for a vsnprintf and an allocation. It now returns before formatting when there are no asserts; whether there are is fixed once recording or replaying starts, so the destructor still asserts exactly when the constructor did.

Not recording, a million not-equal Atomics.wait calls on the main thread went from 2196 to 1476 user-space instructions per call (perf stat), and Atomics.waitAsync from 5414 to 4693.

The scope formatted its message into a heap-allocated string even when not
recording or replaying, where it never asserts, so every Atomics.wait and
Atomics.waitAsync paid for a vsnprintf and an allocation. It now returns
before formatting when there are no asserts; whether there are is fixed
once recording or replaying starts, so the destructor still asserts exactly
when the constructor did.

Not recording, a million not-equal Atomics.wait calls on the main thread
went from 2196 to 1476 user-space instructions per call (perf stat), and
Atomics.waitAsync from 5414 to 4693.
@Andarist
Andarist merged commit 59522ee into master Oct 23, 2026
1 of 2 checks passed
Andarist added a commit that referenced this pull request Nov 6, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,
#170, #173, #190, #191 and #202.

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 6, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,
#170, #173, #190, #191 and #202.

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,
#170, #173, #190, #191 and #202.

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,
#170, #173, #190, #191 and #202.

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant