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

lib: remove internal util._extends() usage #25105

Closed

Conversation

BridgeAR
Copy link
Member

This removes all internal calls to the deprecated _extends()
function. It is slower than Object.assign() and the object spread
notation since V8 6.8 and using the spread notation often also
results in shorter code.

Benchmark with 11.4:

// node benchmark/es/spread-assign.js 
es/spread-assign.js n=1000000 count=5 method="spread": 36,495,416.66835458
es/spread-assign.js n=1000000 count=10 method="spread": 31,889,730.923060697
es/spread-assign.js n=1000000 count=20 method="spread": 151,930.52448171392
es/spread-assign.js n=1000000 count=5 method="assign": 9,476,496.804852217
es/spread-assign.js n=1000000 count=10 method="assign": 4,704,920.0252048215
es/spread-assign.js n=1000000 count=20 method="assign": 123,309.56193177585
es/spread-assign.js n=1000000 count=5 method="_extend": 5,076,862.324845331
es/spread-assign.js n=1000000 count=10 method="_extend": 2,359,288.3170930305
es/spread-assign.js n=1000000 count=20 method="_extend": 382,746.2281006062
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

This removes all internal calls to the deprecated `_extends()`
function. It is slower than `Object.assign()` and the object spread
notation since V8 6.8 and using the spread notation often also
results in shorter code.
@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Dec 18, 2018
@BridgeAR
Copy link
Member Author

@mscdex
Copy link
Contributor

mscdex commented Dec 18, 2018

Why is _extend faster than spread at count=20?

@BridgeAR
Copy link
Member Author

@mscdex please have a look at my comment here https://bugs.chromium.org/p/v8/issues/detail?id=7611#c27. There is a weird cliff from 19 to 20 properties when running the benchmark for the first time. The average is definitely going to be faster.

lib/https.js Outdated Show resolved Hide resolved
@BridgeAR
Copy link
Member Author

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 18, 2018
Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

Definitely think this is the right way to go but this definitely should not be backported to older Node.js versions where the same performance improvements haven't been made in V8.

@bmeurer ... any insights on the speed of the > 20 case?

@Trott
Copy link
Member

Trott commented Dec 18, 2018

AIX failure on CI reported at #25047.

Linux container failure reported at #25070.

Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/19660/ ✔️

@bmeurer
Copy link
Member

bmeurer commented Dec 18, 2018

@jasnell I guess @caitp could help here?

BridgeAR added a commit to BridgeAR/node that referenced this pull request Dec 20, 2018
This removes all internal calls to the deprecated `_extends()`
function. It is slower than `Object.assign()` and the object spread
notation since V8 6.8 and using the spread notation often also
results in shorter code.

PR-URL: nodejs#25105
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@BridgeAR
Copy link
Member Author

Landed in d4c91f2

@BridgeAR BridgeAR closed this Dec 20, 2018
@BridgeAR BridgeAR added the performance Issues and PRs related to the performance of Node.js. label Dec 23, 2018
@MylesBorins
Copy link
Contributor

This doesn't land cleanly on v11.x, would someone be willing to backport?

BridgeAR added a commit to BridgeAR/node that referenced this pull request Jan 9, 2019
This removes all internal calls to the deprecated `_extends()`
function. It is slower than `Object.assign()` and the object spread
notation since V8 6.8 and using the spread notation often also
results in shorter code.

PR-URL: nodejs#25105
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
BridgeAR added a commit that referenced this pull request Jan 10, 2019
This removes all internal calls to the deprecated `_extends()`
function. It is slower than `Object.assign()` and the object spread
notation since V8 6.8 and using the spread notation often also
results in shorter code.

PR-URL: #25105
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
addaleax pushed a commit that referenced this pull request Jan 14, 2019
This removes all internal calls to the deprecated `_extends()`
function. It is slower than `Object.assign()` and the object spread
notation since V8 6.8 and using the spread notation often also
results in shorter code.

PR-URL: #25105
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
This removes all internal calls to the deprecated `_extends()`
function. It is slower than `Object.assign()` and the object spread
notation since V8 6.8 and using the spread notation often also
results in shorter code.

PR-URL: nodejs#25105
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@BridgeAR BridgeAR mentioned this pull request Jan 16, 2019
BridgeAR added a commit to BridgeAR/node that referenced this pull request Jan 16, 2019
This removes all internal calls to the deprecated `_extends()`
function. It is slower than `Object.assign()` and the object spread
notation since V8 6.8 and using the spread notation often also
results in shorter code.

PR-URL: nodejs#25105
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Jan 24, 2019
@BridgeAR BridgeAR deleted the remove-internal-extends-usage branch January 20, 2020 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. lib / src Issues and PRs related to general changes in the lib or src directory. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants