Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
assert: typed array deepequal performance fix#4330
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
assert: typed array deepequal performance fix #4330
Uh oh!
There was an error while loading. Please reload this page.
Conversation
jasnell commented Dec 17, 2015
LGTM |
lib/assert.js Outdated
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.
Can this logic be pushed down further? At least past the "7.1." check on line 152.
cjihrig commented Dec 17, 2015
The test should probably have some cases where the two values are not equal. |
cjihrig commented Dec 17, 2015
This seems fine, but I'd like feedback from other collaborators. Are there any edge cases where this change could come back to bite us? |
83468ba to 10d83e5Compareclaudiorodriguez commented Dec 17, 2015
@cjihrig Thanks, just pushed the changes, +1 on waiting for feedback |
lib/assert.js Outdated
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.
These numbers (7.5) are not arbitrary! They come from the CommonJS standard. Looks like they may already be goobered up, but that's not a reason to make them further-removed from the standard they are intended to refer to.
10d83e5 to 94bb526Compareclaudiorodriguez commented Dec 17, 2015
@Trott Oops, thanks for catching that, fixed jslint issues. |
94bb526 to 5b14d55Compareclaudiorodriguez commented Dec 17, 2015
@Trott You really learn something new every day, thanks again. |
Trott commented Dec 17, 2015
Is it worth taking a benchmark to confirm the performance improvement? A benchmark that we could run across different operating systems and hardware on the CI server might be useful. |
5b14d55 to 8f6a57cCompareclaudiorodriguez commented Dec 17, 2015
@Trott you mean something like what I just pushed? Kinda copied over another benchmark's code. Comparison between assert with the fix and without it shows a massive improvement. (20 vs 0.08) PS: jslint wasn't happy about the benchmark, in fact it isn't happy about a lot of files in the benchmark folder... I think benchmarks are a tad obsolete in general |
8f6a57c to f79654aCompareTrott commented Dec 17, 2015
@fansworld-claudio On the benchmark file: Yep, exactly. Thanks! 👍 And yes, the |
silverwind commented Dec 18, 2015
Can we see some benchmark numbers for other primitve type? There should be a regression, hopefully small. |
claudiorodriguez commented Dec 18, 2015
@silverwind Good idea, I'll have it tomorrow. There should only be a very slight impact when asserting inside huge loops. |
assert.deepEqual: when actual and expected are typed arrays, wrap them in a new Buffer each to increase performance significantly. Fixes: nodejs#4294
f79654a to a6a874bCompareclaudiorodriguez commented Dec 18, 2015
@silverwind added two benchmarks: big array objects (falling into 7.5): before PR: after PR: The fluctuations seem to be within random variance (in my computer's case), so there doesn't seem to be a real change here. big loops (forcing into 7.5 with array object): before PR: after PR: Also seems to be within random variance, after running it a few times... at least running it on my computer. |
silverwind commented Dec 18, 2015
Yeah, looks like v8 is optimizing the extra if branch pretty well and your results look to be just fluctuations. Thanks for adding these benchmarks 👍 |
mcollina commented Dec 21, 2015
LGTM |
1 similar comment
silverwind commented Dec 21, 2015
LGTM |
cjihrig commented Dec 21, 2015
assert.deepEqual: when actual and expected are typed arrays, wrap them in a new Buffer each to increase performance significantly. PR-URL: #4330Fixes: #4294 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
silverwind commented Dec 21, 2015
Thanks! Landed in 6378622. |
assert.deepEqual: when actual and expected are typed arrays, wrap them in a new Buffer each to increase performance significantly. PR-URL: nodejs#4330Fixes: nodejs#4294 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
assert.deepEqual: when actual and expected are typed arrays, wrap them in a new Buffer each to increase performance significantly. PR-URL: nodejs#4330Fixes: nodejs#4294 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
* http: - A new status code was added: 451 - "Unavailable For Legal Reasons" (Max Barinov) nodejs#4377 - Idle sockets that have been kept alive now handle errors (José F. Romaniello) nodejs#4482 * This release also includes several minor performance improvements: - assert: deepEqual is now speedier when comparing TypedArrays (Claudio Rodriguez) nodejs#4330 - lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622 - node: Improved accessor perf of process.env (Trevor Norris) nodejs#3780 - node: Improved performance of process.hrtime() (Trevor Norris) nodejs#3780, (Evan Lucas) nodejs#4484 - node: Improved GetActiveHandles performance (Trevor Norris) nodejs#3780 - util: Use faster iteration in util.format() (Jackson Tian) nodejs#3964 PR-URL: nodejs#4547
* http: - A new status code was added: 451 - "Unavailable For Legal Reasons" (Max Barinov) nodejs#4377 - Idle sockets that have been kept alive now handle errors (José F. Romaniello) nodejs#4482 * This release also includes several minor performance improvements: - assert: deepEqual is now speedier when comparing TypedArrays (Claudio Rodriguez) nodejs#4330 - lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622 - node: Improved accessor perf of process.env (Trevor Norris) nodejs#3780 - node: Improved performance of process.hrtime() (Trevor Norris) nodejs#3780, (Evan Lucas) nodejs#4484 - node: Improved GetActiveHandles performance (Trevor Norris) nodejs#3780 - util: Use faster iteration in util.format() (Jackson Tian) nodejs#3964 Refs: nodejs#4547 PR-URL: nodejs#4623 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
assert.deepEqual: when actual and expected are typed arrays, wrap them in a new Buffer each to increase performance significantly. PR-URL: #4330Fixes: #4294 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
assert.deepEqual: when actual and expected are typed arrays, wrap them in a new Buffer each to increase performance significantly. PR-URL: #4330Fixes: #4294 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
assert.deepEqual: when actual and expected are typed arrays, wrap them in a new Buffer each to increase performance significantly. PR-URL: nodejs#4330Fixes: nodejs#4294 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
* http: - A new status code was added: 451 - "Unavailable For Legal Reasons" (Max Barinov) nodejs#4377 - Idle sockets that have been kept alive now handle errors (José F. Romaniello) nodejs#4482 * This release also includes several minor performance improvements: - assert: deepEqual is now speedier when comparing TypedArrays (Claudio Rodriguez) nodejs#4330 - lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622 - node: Improved accessor perf of process.env (Trevor Norris) nodejs#3780 - node: Improved performance of process.hrtime() (Trevor Norris) nodejs#3780, (Evan Lucas) nodejs#4484 - node: Improved GetActiveHandles performance (Trevor Norris) nodejs#3780 - util: Use faster iteration in util.format() (Jackson Tian) nodejs#3964 Refs: nodejs#4547 PR-URL: nodejs#4623 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
assert.deepEqual: when actual and expected are typed arrays,
wrap them in a new Buffer each to increase performance
significantly.
Fixes: #4294