Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce format-agnostic API for JS Sampling #1603

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hoxyq
Copy link
Contributor

@hoxyq hoxyq commented Jan 28, 2025

Summary:
This diff adds a new API on HermesRuntime, which will emit a struct with all necessary information about completed JavaScript Sampling Profile.

This struct can later be used by other third parties, such as React Native. The reason for creating a data source, and not just providing a stream to which Hermes will emit serialized information is that on React Native side we own the format in which data should be serialized, together with the data from other potential sources, such as User Timings, Interactions, Network, etc.

HermesRuntime will have 2 new API endpoints:

  • dumpAsProfile. A method on HermesRuntime instance, which returns Profile that contains all relevant information about the recorded sampled stack trace.
  • dumpAsProfilesGlobal. A static method, which returns vector of all recorded Profiles for all registered sampling profiler instances.

The actual conversion to Trace Event Format will hapen on React Native side, Hermes will only emit data structure that is agnostic to format and operates only with JavaScript runtime-level entities and general stuff: call stack frame information, timestamps, information about OS process and thread where sampling occured.

Differential Revision: D67353585

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jan 28, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67353585

hoxyq added a commit to hoxyq/hermes that referenced this pull request Jan 28, 2025
Summary:

This diff adds a new API on `HermesRuntime`, which will emit a `struct` with all necessary information about completed JavaScript Sampling Profile.

This `struct` can later be used by other third parties, such as React Native. The reason for creating a data source, and not just providing a stream to which Hermes will emit serialized information is that on React Native side we own the format in which data should be serialized, together with the data from other potential sources, such as User Timings, Interactions, Network, etc.

HermesRuntime will have 2 new API endpoints:
- `dumpAsProfile`. A method on `HermesRuntime` instance, which returns `Profile` that contains all relevant information about the recorded sampled stack trace.
- `dumpAsProfilesGlobal`. A static method, which returns vector of all recorded Profiles for all registered sampling profiler instances.


The actual conversion to Trace Event Format will hapen on React Native side, Hermes will only emit data structure that is agnostic to format and operates only with JavaScript runtime-level entities and general stuff: call stack frame information, timestamps, information about OS process and thread where sampling occured.

Differential Revision: D67353585
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67353585

hoxyq added a commit to hoxyq/hermes that referenced this pull request Jan 28, 2025
Summary:

This diff adds a new API on `HermesRuntime`, which will emit a `struct` with all necessary information about completed JavaScript Sampling Profile.

This `struct` can later be used by other third parties, such as React Native. The reason for creating a data source, and not just providing a stream to which Hermes will emit serialized information is that on React Native side we own the format in which data should be serialized, together with the data from other potential sources, such as User Timings, Interactions, Network, etc.

HermesRuntime will have 2 new API endpoints:
- `dumpAsProfile`. A method on `HermesRuntime` instance, which returns `Profile` that contains all relevant information about the recorded sampled stack trace.
- `dumpAsProfilesGlobal`. A static method, which returns vector of all recorded Profiles for all registered sampling profiler instances.


The actual conversion to Trace Event Format will hapen on React Native side, Hermes will only emit data structure that is agnostic to format and operates only with JavaScript runtime-level entities and general stuff: call stack frame information, timestamps, information about OS process and thread where sampling occured.

Reviewed By: dannysu

Differential Revision: D67353585
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67353585

Matt Blagden and others added 2 commits January 31, 2025 05:04
Summary:
The sampling profiler tracks the type of each frame. A "suspend" frame
denotes that execution is suspended, with an arbitrary string providing
details.

We would like to identify GC frames for the sake of Chrome DevTools
visualizations/stats about GC time. This diff adds an enum to suspend
frames to allow GC frames to be identified without depending on
specific contents of the details string.

Another option would be to replace the "suspend" frame with multiple
different frame types for debugger, GC, etc.

Differential Revision: D68442991
Summary:

This diff adds a new API on `HermesRuntime`, which will emit a `struct` with all necessary information about completed JavaScript Sampling Profile.

This `struct` can later be used by other third parties, such as React Native. The reason for creating a data source, and not just providing a stream to which Hermes will emit serialized information is that on React Native side we own the format in which data should be serialized, together with the data from other potential sources, such as User Timings, Interactions, Network, etc.

HermesRuntime will have 2 new API endpoints:
- `dumpAsProfile`. A method on `HermesRuntime` instance, which returns `Profile` that contains all relevant information about the recorded sampled stack trace.
- `dumpAsProfilesGlobal`. A static method, which returns vector of all recorded Profiles for all registered sampling profiler instances.


The actual conversion to Trace Event Format will hapen on React Native side, Hermes will only emit data structure that is agnostic to format and operates only with JavaScript runtime-level entities and general stuff: call stack frame information, timestamps, information about OS process and thread where sampling occured.

Reviewed By: dannysu

Differential Revision: D67353585
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67353585

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants