Skip to content

Profiling javascript thread performance #10944

@mdamien

Description

@mdamien

Description

When profiling a react-native app, often the bottleneck is in the JS thread. But there's no way to know which javascript functions are the bottleneck.

As shown in the profiling doc, we can't see the exact js calls:

image

Reproduction

I've reproduced it by using systrace.py as shown in the docs and got a profile looking like this:

image

Solution

Ideal solution would be some doc to use the V8 profiler.

Also, for react.js, we have React.addons.Perf. Maybe showing how to use it for react-native would be also nice.

EDIT3: looks like using react-addons-perf solve most of the issues for my specific case, I should maybe include it in the docs

I don't know much about the react-native profiling infrastructure, maybe there's already something built-in that I missed.

EDIT: after a bit more of research, I saw a few things:

EDIT2: also, looks like something is planned

image

I'm interested in contributing a PR for this if necessary.

Additional Information

  • React Native version: 0.30.0
  • Platform: android
  • Operating System: linux

EDIT4: managed to something like what I wanted with react-addons-perf by using something like this:

import Perf from 'react-addons-perf';

....
    componentDidMount() {
        console.log('start perf tracking');
        Perf.start();
        setTimeout(() => {
            console.log('stop perf tracking');
            Perf.stop();
            Perf.printExclusive();
        }, 10000);
   }
...

But something nicer would be to be able to get a flamegraph

EDIT5: Looks like debugging with chrome allow to use the profiler from chrome directly, making this whole issue solved

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions