-
-
Notifications
You must be signed in to change notification settings - Fork 735
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
perf: remove unnecessary extra child traversal in collectDirtyChildren #1058
perf: remove unnecessary extra child traversal in collectDirtyChildren #1058
Conversation
116cfee
to
037875f
Compare
The function in question actually has a few more issues:
|
@shlusiak Thanks for your PR and apologies for the late reply, we are finally looking to close all PRs. Could you merge master into this and resolve any conflicts? |
Codecov Report
@@ Coverage Diff @@
## master #1058 +/- ##
============================================
+ Coverage 65.29% 65.31% +0.02%
- Complexity 2218 2219 +1
============================================
Files 122 122
Lines 9961 9961
Branches 1337 1338 +1
============================================
+ Hits 6504 6506 +2
+ Misses 2945 2943 -2
Partials 512 512
Continue to review full report at Codecov.
|
Thanks for opening this pull request!
|
@mtrezza done. |
Thanks! Could you also add a test to prevent the issue from occurring in the future? |
@mtrezza from what I can tell this class does not have any tests at all. Since from the outside the behaviour has not changed at all I couldn't add any blackbox test that verifies that my changes are correct, other than having tests that ensure that behaviour has indeed not changed. This is an optimisation after all. I'm afraid I don't have the time myself to add the required regression tests to ensure I didn't break anything. And I'm unsure whether you'd want to spend time on pouring concret onto the current implementation details to ensure the algorithm isn't altered in the future. A test for this specific issue would require mocking, I suppose. |
@shlusiak I see, looks like not worth the effort because difficult to test. There is just one new added line that seems to decrease coverage. Maybe we can cover that with a new test (or by modifying an existing test) before merging. Seems to be a simple one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mtrezza LGTM
## [2.0.4](2.0.3...2.0.4) (2021-11-03) ### Performance Improvements * remove unnecessary extra child traversal in collectDirtyChildren ([#1058](#1058)) ([1844b3e](1844b3e))
🎉 This change has been released in version 2.0.4 |
Please see #1006 (comment) for the analysis of this.
The
collectDirtyChildren
forgets seen siblings when traversing, which causes extra traversals if those siblings point to the same objects and causes lots of garbage to be created in memory. It also has the potential of adding the same dirty object twice to thedirtyChildren
collection, which may or may not be a set.Removing the copy of the
seen
set may improve performance significantly.Should hopefully massively improve the situations described in issues #1006, #1007, possibly #888 and #993 .