assert,util: improve deep object comparison performance#57648
Merged
nodejs-github-bot merged 5 commits intonodejs:mainfrom Apr 5, 2025
Merged
assert,util: improve deep object comparison performance#57648nodejs-github-bot merged 5 commits intonodejs:mainfrom
nodejs-github-bot merged 5 commits intonodejs:mainfrom
Conversation
Collaborator
|
Review requested:
|
ljharb
approved these changes
Mar 28, 2025
Member
ljharb
left a comment
There was a problem hiding this comment.
looks good, just some thoughts
717c5ac to
c9b2d34
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #57648 +/- ##
==========================================
+ Coverage 90.24% 90.27% +0.02%
==========================================
Files 630 630
Lines 184990 185129 +139
Branches 36216 36259 +43
==========================================
+ Hits 166948 167116 +168
+ Misses 11003 10984 -19
+ Partials 7039 7029 -10
🚀 New features to boost your workflow:
|
Member
Author
Contributor
Failed to start CI⚠ Commits were pushed since the last approving review: ⚠ - assert,util: improve deep object comparison performance ⚠ - assert,util: improve deep equal comparison performance ⚠ - assert,util: improve (partial) deep equal comparison performance ⚠ - test: add assert.deepStrictEqual test cases to cover more cases ✘ Refusing to run CI on potentially unsafe PRhttps://github.com/nodejs/node/actions/runs/14264748421 |
bengl
requested changes
Apr 4, 2025
Member
bengl
left a comment
There was a problem hiding this comment.
Broadly speaking, a lot of these optimizations are very non-obvious, and could use some commentary. That said, the reasons why become clearer on multiple reads, so I'm not going to block on that.
The one about getting the descriptor instead of using ObjectPropertyIsEnumerable still stands though.
This improves the performance for almost all objects when comparing them deeply.
This allows the compiler to inline parts of the code in a way that especially primitives in arrays can be compared faster.
The circular check is now done lazily. That way only users that actually make use of such structures have to do the calculation overhead. It is an initial overhead the very first time it's run to detect the circular structure, while every following call uses the check for circular structures by default. This improves the performance for object comparison significantly. On top of that, this includes an optimised algorithm for sets and maps that contain objects as keys. The tracking is now done in an array and the array size is not changed when elements at the start or at the end of the array is detected. The order of the elements matter, so a reversed key order is now a magnitude faster. Insert sort comparison is also signficantly faster, random order is a tad faster.
aduh95
reviewed
Apr 4, 2025
ccea4ca to
75d8fbb
Compare
aduh95
approved these changes
Apr 4, 2025
bengl
approved these changes
Apr 4, 2025
Collaborator
Collaborator
Collaborator
|
Landed in e739559 |
JonasBa
pushed a commit
to JonasBa/node
that referenced
this pull request
Apr 11, 2025
This improves the performance for almost all objects when comparing them deeply. PR-URL: nodejs#57648 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
RafaelGSS
pushed a commit
that referenced
this pull request
May 1, 2025
This improves the performance for almost all objects when comparing them deeply. PR-URL: #57648 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
RafaelGSS
pushed a commit
that referenced
this pull request
May 2, 2025
This improves the performance for almost all objects when comparing them deeply. PR-URL: #57648 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
aduh95
pushed a commit
that referenced
this pull request
May 6, 2025
This improves the performance for almost all objects when comparing them deeply. PR-URL: #57648 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
RafaelGSS
pushed a commit
that referenced
this pull request
May 14, 2025
This improves the performance for almost all objects when comparing them deeply. PR-URL: #57648 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
aduh95
pushed a commit
that referenced
this pull request
May 16, 2025
This improves the performance for almost all objects when comparing them deeply. PR-URL: #57648 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
aduh95
pushed a commit
that referenced
this pull request
May 17, 2025
This improves the performance for almost all objects when comparing them deeply. PR-URL: #57648 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
aduh95
pushed a commit
that referenced
this pull request
May 17, 2025
This improves the performance for almost all objects when comparing them deeply. PR-URL: #57648 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
aduh95
pushed a commit
that referenced
this pull request
May 17, 2025
This improves the performance for almost all objects when comparing them deeply. PR-URL: #57648 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
aduh95
pushed a commit
that referenced
this pull request
May 18, 2025
This improves the performance for almost all objects when comparing them deeply. PR-URL: #57648 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
aduh95
pushed a commit
that referenced
this pull request
May 19, 2025
This improves the performance for almost all objects when comparing them deeply. PR-URL: #57648 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This improves the performance for almost all objects when comparing
them deeply significantly.