Skip to content
This repository has been archived by the owner on Mar 20, 2022. It is now read-only.

Enable loose transformation for object spread operator to improve per… #431

Merged
merged 1 commit into from
Jan 14, 2020

Conversation

wurstbonbon
Copy link
Contributor

Problem

Upgrading to babel 7 has significantly worsened the normalization performance, which is part of the reason for https://github.com/paularmstrong/normalizr/issues/383. With Babel 7 the transpilation of the spread operator changed from a simple Object.assign to a more complicate logic https://babeljs.io/docs/en/v7-migration#babel-plugin-proposal-object-rest-spread. Spreading is used as processStrategy and mergeStrategy which became a lot more expensive.

Solution

Enable "loose" transformation for object spreading.

Performance comparison

Setup

const mySchema = new schema.Entity('tacos');
const data = [];
for (let i = 0; i < N; i++) {
  data.push({ id: i, type: `foo-${i}` });
}
normalize(data, [mySchema]);

Normalization times in milliseconds for 5 runs

N = 10,000 entities
current 27 22 22 22 21
loose transformation 17 9 11 9 12
N = 100,000 entities
current 210 201 200 200 198
loose transformation 97 111 97 97 94

TODO

  • Add & update tests
  • Ensure CI is passing (lint, tests, flow)
  • Update relevant documentation

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 8a2eaaa on wurstbonbon:babel-spread into 3df7d07 on paularmstrong:master.

@ntucker ntucker merged commit b5f570a into paularmstrong:master Jan 14, 2020
@paularmstrong
Copy link
Owner

🎉 Thanks @wurstbonbon @ntucker

@wurstbonbon
Copy link
Contributor Author

@paularmstrong Any chance to get this released soon?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants