WhoBuilt

RN TV Hermes JS Sampling Profiling – Become The RN JS App Performance SME

Sep 26, 2024· 26 min· 482 views·Watch on YouTube

Speaker

Michael Khirallah of Callstack explains how React Native teams can investigate JavaScript performance problems across TV and other platforms using Hermes sampling profiles.

Start with the user impact

Kh irallah frames the investigation around a multiplatform React Native app facing a release-blocking slowdown three days before launch. The reported symptoms are a slow home screen, sluggish navigation, and degraded video startup time across platforms, while spot checks suggest memory is not the main issue.

Form and test hypotheses

He proposes two possible causes: unnecessary renders and time spent executing expensive JavaScript functions. A React Native DevTools render profile shows that renders look healthy, so the team moves on to investigate JavaScript execution.

Record the affected journey

Kh irallah recommends recording a representative user journey: launch the app, focus the Back button, start profiling, navigate to the library and a detail screen, then return and stop the recording. He describes using the Hermes sampling profiler and notes that React Native 0.75's debugger and the release profile package are other profiling options.

Read the sampling profile

In the flame graph, he looks for wide bars with few sub-bars as possible long-running functions, then searches for repeated calls. Because the profiler samples every 10 milliseconds, it may miss individual calls, but frequent appearances can point to a costly pattern. In the example, cleanup functions and a `useSwimLanes` action appear repeatedly.

Fix the repeated cleanup

The profile points to `useCleanupDataInStore`, called from a card's `useEffect` cleanup. Since many cards render on the screen, the cleanup runs repeatedly during navigation. Moving it to the higher-level content component lets it run once during the screen transition.

Takeaways

  • Start with user-facing symptoms and affected KPIs, then check whether the issue spans platforms.
  • Use a render profile to test render-related suspicions before investigating JavaScript execution.
  • Record a complete journey that reproduces the slowdown so the profile reflects the real user experience.
  • In a Hermes flame graph, inspect wide bars with few sub-bars and search for repeated calls.
  • When a function runs too often, inspect its call sites and lifecycle before optimizing its internals.

Mentioned in this talk

Search inside this talk

What was claimed 5

  • feature
    Callstack: Conference sponsor; described as a total software engineering consultancy
    “This conference is brought to you by Callstack, a total software engineering consultancy.”
    YouTube
    Unverified1 source· Talk
  • feature
    React DevTools: Includes a profiler for recording render profiles
    “We open React Native DevTools and the profiler, then record a render profile.”
    YouTube
    Unverified1 source· Talk
  • feature
    Hermes JavaScript sampling profiler: Samples JavaScript function calls every 10 milliseconds
    “It's a sampling profile; it's only going to take a snapshot of function calls every 10 milliseconds.”
    YouTube
    Unverified1 source· Talk
  • feature
    React Native: Provides the `profile-hermes` command to pull a profile from a device and save it locally
    “Run this command: `react-native profile-hermes`. Give it the path; it'll pull the profile off the device and save it locally.”
    YouTube
    Unverified1 source· Talk
  • uses
    “Then upload it to Chrome via the Performance tab.”
    YouTube
    Unverified1 source· Talk

Related talks