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

util: improve format performance #24981

Closed

Conversation

BridgeAR
Copy link
Member

@BridgeAR BridgeAR commented Dec 12, 2018

This simplifies the format() code and significantly improves the
performance.

Just a few runs to verify the gain:

                                               confidence improvement accuracy (*)    (**)   (***)
 util/format.js type='many-%' n=600000                ***     18.98 %       ±9.60% ±13.22% ±18.15%
 util/format.js type='no-replace-2' n=600000          ***    396.74 %      ±43.42% ±60.18% ±83.52%
 util/format.js type='no-replace' n=600000            ***    166.64 %      ±32.80% ±44.98% ±61.39%
 util/format.js type='number' n=600000                ***     56.96 %      ±11.00% ±15.14% ±20.80%
 util/format.js type='only-objects' n=600000           **     19.21 %      ±13.09% ±17.82% ±24.05%
 util/format.js type='replace-object' n=600000          *     14.14 %      ±12.46% ±17.04% ±23.16%
 util/format.js type='string-2' n=600000              ***     28.66 %      ±13.20% ±18.21% ±25.07%
 util/format.js type='string' n=600000                ***     59.04 %      ±14.04% ±19.03% ±25.49%
 util/format.js type='unknown' n=600000               ***    338.50 %      ±37.78% ±52.19% ±72.06%

CI https://ci.nodejs.org/job/node-test-pull-request/19442/

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 simplifies the `format()` code and significantly improves the
performance.
@nodejs-github-bot nodejs-github-bot added the util Issues and PRs related to the built-in util module. label Dec 12, 2018
@BridgeAR
Copy link
Member Author

@nodejs/performance @nodejs/util PTAL

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

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM with a nit.

lib/util.js Outdated Show resolved Hide resolved
BridgeAR added a commit to BridgeAR/node that referenced this pull request Dec 14, 2018
This simplifies the `format()` code and significantly improves the
performance.

PR-URL: nodejs#24981
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
@BridgeAR
Copy link
Member Author

Landed in 9752fce

@BridgeAR BridgeAR closed this Dec 14, 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 does not land cleanly on v11.x, would someone be willing to backport?

@silverwind
Copy link
Contributor

I don't think it's worth backporting as the performance regression was mostly introduced by my semver-major commit.

@BridgeAR
Copy link
Member Author

BridgeAR commented Jan 9, 2019

I changed the labels so this is not requested for backporting anymore.

refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
This simplifies the `format()` code and significantly improves the
performance.

PR-URL: nodejs#24981
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
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. performance Issues and PRs related to the performance of Node.js. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants