Netflix / falcor

A JavaScript library for efficient data fetching
http://netflix.github.io/falcor
Apache License 2.0
10.47k stars 444 forks source link

Minor changes to reduce garbage #980

Closed bendmorris closed 4 years ago

bendmorris commented 4 years ago

cc: @jcranendonk

The goal here was to reduce the amount being allocated when fetching data using falcor. Our JS engine is particularly sensitive to garbage generation which may not be a problem on modern browsers. There should be no functional changes.

Locally my test case is showing about a 30% reduction in total allocations from Falcor, particularly coming from setJSONGraphPathSet which was reduced by over 50%.

I'll add comments inline to explain the rationale for the changes.

bendmorris commented 4 years ago

So that I don't have to call it out everywhere, there were a few utility methods - arrayConcat, fastCat, arraySlice, arrayMap... - which just reimplemented prototype methods with no apparent functional differences. I removed these and replaced them with the native versions; they're not faster, so there's no reason to ship the extra code.

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.2%) to 92.826% when pulling aaf59a591225923ddfcc12386cff1b6e45521d45 on bendmorris:garbage-opt into 61796c6bf1f9a6dbaaf775cd262a3218175a4ee7 on Netflix:master.