Skip to content

Conversation

@hoxyq
Copy link
Contributor

@hoxyq hoxyq commented Oct 30, 2025

Summary:

Changelog: [Internal]

The approach is identical to console.timeStamp(), see the diff below for more context.

In this diff, we apply this approach to performance.measure().

Differential Revision: D85481863

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 30, 2025
@meta-codesync
Copy link

meta-codesync bot commented Oct 30, 2025

@hoxyq has exported this pull request. If you are a Meta employee, you can view the originating Diff in D85481863.

hoxyq added a commit to hoxyq/react-native that referenced this pull request Oct 31, 2025
Summary:

# Changelog: [Internal]

The approach is identical to `console.timeStamp()`, see the diff below for more context.

In this diff, we apply this approach to `performance.measure()`.

Differential Revision: D85481863
hoxyq added a commit to hoxyq/react-native that referenced this pull request Oct 31, 2025
Summary:

# Changelog: [Internal]

The approach is identical to `console.timeStamp()`, see the diff below for more context.

In this diff, we apply this approach to `performance.measure()`.

Differential Revision: D85481863
@hoxyq hoxyq force-pushed the export-D85481863 branch 2 times, most recently from af511f7 to 93d82c0 Compare November 3, 2025 16:23
hoxyq added a commit to hoxyq/react-native that referenced this pull request Nov 3, 2025
Summary:

# Changelog: [Internal]

The approach is identical to `console.timeStamp()`, see the diff below for more context.

In this diff, we apply this approach to `performance.measure()`.

Reviewed By: huntie

Differential Revision: D85481863
hoxyq added a commit to hoxyq/react-native that referenced this pull request Nov 5, 2025
Summary:

# Changelog: [Internal]

The approach is identical to `console.timeStamp()`, see the diff below for more context.

In this diff, we apply this approach to `performance.measure()`.

Reviewed By: huntie

Differential Revision: D85481863
hoxyq added 10 commits November 5, 2025 03:12
Summary:

# Changelog: [Internal]

This is not used, nor required. The controller is the canonical way of using targets.

Reviewed By: huntie

Differential Revision: D85440639
…k#54282)

Summary:

# Changelog: [Internal]

It is already in a tracing session state, we are going to use it in RuntimeTarget.

Reviewed By: huntie

Differential Revision: D85440638
Summary:

# Changelog: [Internal]

This will control scenarios when we enable `console.createTask` implementation, and when we just use the stub version.

Reviewed By: huntie

Differential Revision: D85440641
Summary:

# Changelog: [Internal]

This defines the main entities for the console.createTask():
- ConsoleTaskOrchestrator: global stack that can be used as a source of pending tasks.
- ConsoleTaskContext: RAII object, captures the context for a specific task. Lifetime is bound to the lifetime of the task object in JavaScript.
- ConsoleTask: RAII-like object. Initialized only during the callback run of `task.run(...)`.

I couldn't find a better way to solve this without having a static singleton. Native modules don't have access to ReactInstance object, so we won't be able to access this global stack from `performance.measure` implementation, for example.

Not using the word `async` anywhere in the naming, because the current implementation doesn't support async stack traces.

Reviewed By: sbuggay

Differential Revision: D85481864
Summary:

# Changelog: [Internal]

Adds a basic implementation of the `console.createTask()` method.

When this method is called, the `ConsoleTaskContext` is allocated.

When `task.run()` is called, the corresponding `ConsoleTask` that has a pointer to `ConsoleTaskContext` will push it onto the stack in `ConsoleTaskOrchestrator`.

Also adds types to corresponding Flow declarations.

Reviewed By: sbuggay

Differential Revision: D85481865
Summary:

# Changelog: [Internal]

I couldn't add it to the previous diff, since console.createTask is not present on the base revision. See [1].

Reviewed By: sbuggay

Differential Revision: D85860982
Summary:

# Changelog: [Internal]

Adds a benchmark that is scoped to JSX scenario. React uses createTask() on JSX instances to preserve owner stacks relationship, and so users can see tree-like stacks in the debugger.

Since this only happens in DEV, I have to force dev mode in Fantom as well.

Reviewed By: sbuggay

Differential Revision: D85860981
Summary:

# Changelog: [Internal]

Actually gate the task scheduling logic, so that the implementation is a no-op by default, if we are not tracing in the background or have Runtime CDP domain enabled.

The drawback is that we might loose stack traces for some component renders, if the corresponding JSX declaration was called before we've enabled the `console.createTask()`.

Reviewed By: huntie

Differential Revision: D85849862
Summary:

# Changelog: [Internal]

Whenever the `console.timeStamp()` is called and we are actually tracing, we will peek at the `ConsoleTaskOrchestrator` stack and check if there is a task.

If so, it means that this call happened inside a task context, so we can request a stack trace and propagate it down to `PerformanceTracer`.

Reviewed By: huntie

Differential Revision: D85481866
Summary:

# Changelog: [Internal]

The approach is identical to `console.timeStamp()`, see the diff below for more context.

In this diff, we apply this approach to `performance.measure()`.

Reviewed By: huntie

Differential Revision: D85481863
@meta-codesync meta-codesync bot closed this in 7722eae Nov 6, 2025
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Nov 6, 2025
@meta-codesync
Copy link

meta-codesync bot commented Nov 6, 2025

This pull request has been merged in 7722eae.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants