Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid redundant deep cloning when unwinding. #286

Merged
merged 3 commits into from
Apr 16, 2018

Conversation

jarib
Copy link
Contributor

@jarib jarib commented Apr 16, 2018

AFAICT there's no reason to deep clone unless the unwind path has multiple levels. For large and deeply nested objects this should be a significant performance gain.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 85.443% when pulling 8ba4101 on jarib:faster-unwind into 61d9808 on zemirco:master.

@coveralls
Copy link

coveralls commented Apr 16, 2018

Coverage Status

Coverage decreased (-0.05%) to 85.35% when pulling b86dc24 on jarib:faster-unwind into 61d9808 on zemirco:master.

Copy link
Collaborator

@juanjoDiaz juanjoDiaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the code quite more unreadable and I'm not convinced about how much of a difference it makes from the performance point of view.

@jarib
Copy link
Contributor Author

jarib commented Apr 16, 2018

It makes a huge difference if you're working on large objects. It improves performance by 80% on the data I'm currently working on:

$ cat data/result.json | jq '.[0:5]' | time ~/src/json2csv/bin/json2csv.js --unwind 'hits' >| /dev/null
~/src/json2csv/bin/json2csv.js --unwind 'hits' >| /dev/null  5.03s user 0.11s system 89% cpu 5.743 total
$ cat data/result.json | jq '.[0:5]' | time ~/src/json2csv/bin/json2csv.js --unwind 'hits' >| /dev/null
~/src/json2csv/bin/json2csv.js --unwind 'hits' >| /dev/null  0.35s user 0.08s system 39% cpu 1.079 total

@jarib
Copy link
Contributor Author

jarib commented Apr 16, 2018

I agree the readability isn't great though. I can try to clean it up a bit.

@jarib
Copy link
Contributor Author

jarib commented Apr 16, 2018

I think this is the best I can do right now :)

@knownasilya knownasilya merged commit 95a6ca9 into zemirco:master Apr 16, 2018
@knownasilya
Copy link
Collaborator

Thanks for submitting and working with us on getting it mergeable 👍

@knownasilya
Copy link
Collaborator

Published in v4.1.0

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

Successfully merging this pull request may close these issues.

4 participants