Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deduplicate strings and provide std::string_view #51098

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

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

Conversation

hoxyq
Copy link
Contributor

@hoxyq hoxyq commented May 5, 2025

Summary:

Changelog: [Internal]

Depending on the sampling rate, there could be lots of samples recorded. Right now, React Native requests the rate to be 10kHz. In reality, Hermes will be slower. How exactly slower will depend on the platform, because sampling profiler implementation is platform-specific. Windows peaks at ~500Hz, whereas iOS and Android that are using signals can reach up to 5kHz, based on my observations. This means that we could record sample approximately every 0.5ms.

For 30 seconds of sampling, we can get around 150k samples, every one of which may have up to 500 call frames (it is a custom limitation on Hermes side). Previously, every call frame could have a unique copy of function name string and url string.

This diff changes the approach to deduplicate strings, keeping a single copy for every unique string. A new abstraction UniqueStringEntry is added that will keep a shared pointer to the string storage and an offset to the entry in this storage.

On React Native side, we are going to re-use these std::string_view and keep Hermes' Profile alive as long as they are used. We are going to achieve this by keeping unique pointer to the Hermes' Profile in React Native's Profile abstraction - RuntimeSamplingProfile, which is agnostic to the runtime.

Differential Revision: D73106068

hoxyq added 2 commits May 5, 2025 01:34
…#51084)

Summary:

# Changelog: [Internal]

Reviewed By: dannysu

Differential Revision: D73850528
Summary:
# Changelog: [Internal]

Depending on the sampling rate, there could be lots of samples recorded. Right now, React Native requests the rate to be 10kHz. In reality, Hermes will be slower. How exactly slower will depend on the platform, because sampling profiler implementation is platform-specific. Windows peaks at ~500Hz, whereas iOS and Android that are using signals can reach up to 5kHz, based on my observations. This means that we could record sample approximately every 0.5ms.

For 30 seconds of sampling, we can get around 150k samples, every one of which may have up to 500 call frames (it is a custom limitation on Hermes side). Previously, every call frame could have a unique copy of function name string and url string.

This diff changes the approach to deduplicate strings, keeping a single copy for every unique string. A new abstraction `UniqueStringEntry` is added that will keep a shared pointer to the string storage and an offset to the entry in this storage.

On React Native side, we are going to re-use these `std::string_view` and keep Hermes' `Profile` alive as long as they are used. We are going to achieve this by keeping unique pointer to the Hermes' `Profile` in React Native's Profile abstraction - `RuntimeSamplingProfile`, which is agnostic to the runtime.

Differential Revision: D73106068
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels May 5, 2025
@facebook-github-bot
Copy link
Contributor

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

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 p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants