Skip to content

Commit

Permalink
Get rid of the cloneDeep from lodash
Browse files Browse the repository at this point in the history
Summary: Assuming that the `cloneDeep` function has been introduced in order to avoid memory leaks/inefficient memory usage, an investigation checking whether it still occurs without cloning has been performed. Apparently this is not an issue anymore. The main reason for removing this function is our will to switch to Hermes. Using `cloneDeep` with this engine, a significant performance drop can be observed, the problem is described [here](facebook/hermes#471).

Test Plan: Test results are presented in [this](https://phabricator.ashoat.com/D884#21096) and two following comments. We also ran a test logging in to the comm app with an account that has a lot of data to be fetched and parsed(and, up to this point, clonned).

Reviewers: palys-swm, ashoat

Reviewed By: palys-swm, ashoat

Subscribers: ashoat, KatPo, zrebcu411, Adrian, atul, subnub

Differential Revision: https://phabricator.ashoat.com/D916
  • Loading branch information
karol-bisztyga committed Mar 30, 2021
1 parent aafc03e commit 887fa8d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
4 changes: 1 addition & 3 deletions lib/utils/fetch-json.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @flow

import _cloneDeep from 'lodash/fp/cloneDeep';

import { fetchJSONTimeout } from '../shared/timeouts';
import { SocketOffline, SocketTimeout } from '../socket/inflight-requests';
import type { Shape } from '../types/core';
Expand Down Expand Up @@ -155,7 +153,7 @@ async function fetchJSON(
});
const text = await response.text();
try {
return _cloneDeep(JSON.parse(text));
return JSON.parse(text);
} catch (e) {
console.log(text);
throw e;
Expand Down
3 changes: 1 addition & 2 deletions lib/utils/upload-blob.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow

import invariant from 'invariant';
import _cloneDeep from 'lodash/fp/cloneDeep';
import _throttle from 'lodash/throttle';

import { getConfig } from './config';
Expand Down Expand Up @@ -78,7 +77,7 @@ function uploadBlob(
}
const text = xhr.responseText;
try {
resolve(_cloneDeep(JSON.parse(text)));
resolve(JSON.parse(text));
} catch (e) {
console.log(text);
reject(e);
Expand Down

0 comments on commit 887fa8d

Please sign in to comment.