SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

0 0 0 C++

Make JSCRuntime::createValue 35% faster (#27016)

Summary:
JSC does some sort of thread safety locking on every single JSC API call, which makes them ridiculously expensive for a large number of calls (such as when passing a large array over the RN bridge). It would be great if we could lock and unlock once for an entire sequence of JSC calls… but in the meantime, the less we call JSC the better.

![unknown](https://user-images.githubusercontent.com/183747/67624956-08bd6e00-f838-11e9-8f65-e077693f113d.png)

In my benchmark environment (https://github.com/Nozbe/WatermelonDB/pull/541), the time spent in JSCRuntime::createValue went down from 1.07s to 0.69s by changing JSValueIsXXXX calls to a single JSValueGetType call.

The underlying implementation does the same thing: https://github.com/WebKit/webkit/blob/master/Source/JavaScriptCore/API/JSValueRef.cpp#L58

## Changelog

[General] [Fixed] - Make JSCRuntime::createValue faster
Pull Request resolved: https://github.com/facebook/react-native/pull/27016

Reviewed By: RSNara

Differential Revision: D18769047

Pulled By: mhorowitz

fbshipit-source-id: 9d1ee28840303f7721e065c1b3c347e354cd7fef
R
Radek Pietruszewski committed
24e0bad8bea95ef7ddf72e2f00a93ffd47872d5b
Parent: a793ed7
Committed by Facebook Github Bot <facebook-github-bot@users.noreply.github.com> on 2/20/2020, 6:33:16 PM