Page MenuHomePhabricator

[iOS] Add `withEnableSampleProfiling(true)` to `makeRuntimeConfig`
ClosedPublic

Authored by atul on Sep 19 2023, 1:28 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Sep 17, 6:34 AM
Unknown Object (File)
Tue, Sep 10, 12:07 PM
Unknown Object (File)
Thu, Aug 29, 1:20 AM
Unknown Object (File)
Sun, Aug 25, 7:53 AM
Unknown Object (File)
Aug 17 2024, 7:47 PM
Unknown Object (File)
Aug 7 2024, 10:05 PM
Unknown Object (File)
Aug 7 2024, 10:05 PM
Unknown Object (File)
Aug 7 2024, 10:05 PM
Subscribers
None

Details

Summary

This enables us to use Hermes sampling profiler. Without this change we were getting facebook::jsi::JSINativeException: Runtime not registered for profiling when trying to do a Hermes sample profiling session.

Conveniently this isn't really documented (anywhere I could find), but was able to figure it out searching through hermes and react-native sources on GitHub.

Test Plan

Here's an example:

0bee45.png (772×2 px, 377 KB)

Diff Detail

Repository
rCOMM Comm
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul published this revision for review.Sep 19 2023, 1:31 PM
atul edited the test plan for this revision. (Show Details)

It seems sketchy to do this in production, especially given it's undocumented. I'm worried about the potential impact on performance. Can we restrict this change to dev builds?

It seems sketchy to do this in production, especially given it's undocumented. I'm worried about the potential impact on performance. Can we restrict this change to dev builds?

So after reading through https://github.com/facebook/react-native/pull/34129/files#diff-45899233397345155a5d7cf81063ce4a749c8c40966cfe30f4189c34c4340436 it looks like this is enabled by default now

Here is is in latest 0.70-stable: https://github.com/facebook/react-native/pull/34129/files#diff-45899233397345155a5d7cf81063ce4a749c8c40966cfe30f4189c34c4340436

(I think the profiler gets disabled on prod builds, I'll do a little more research)

Okay, please make sure that upstream React Native does this on all builds too before landing!

This revision is now accepted and ready to land.Sep 19 2023, 1:50 PM

Okay, please make sure that upstream React Native does this on all builds too before landing!

Yeah here's the latest HermesExecutorFactory: https://github.com/facebook/react-native/blob/0.70-stable/ReactCommon/hermes/executor/HermesExecutorFactory.cpp. That said I'll toggle it based on DEBUG to be safe.

toggle withEnableSampleProfiling on DEBUG

This revision was landed with ongoing or failed builds.Sep 20 2023, 10:31 AM
This revision was automatically updated to reflect the committed changes.