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: add ASCII fast path to getStringWidth() #29301

Closed
wants to merge 4 commits into from

Conversation

addaleax
Copy link
Member

A lot of strings that are going to be passed to getStringWidth()
are ASCII strings, for which the calculation is rather easy and
calling into C++ can be skipped.

                                                   confidence improvement accuracy (*)    (**)   (***)
 misc/getstringwidth.js n=100000 type='ascii'            ***    328.99 %      ±21.73% ±29.25% ±38.77%
 misc/getstringwidth.js n=100000 type='emojiseq'                  2.94 %       ±7.66% ±10.19% ±13.26%
 misc/getstringwidth.js n=100000 type='fullwidth'                 4.70 %       ±5.64%  ±7.50%  ±9.76%
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

A lot of strings that are going to be passed to `getStringWidth()`
are ASCII strings, for which the calculation is rather easy and
calling into C++ can be skipped.

                                                       confidence improvement accuracy (*)    (**)   (***)
     misc/getstringwidth.js n=100000 type='ascii'            ***    328.99 %      ±21.73% ±29.25% ±38.77%
     misc/getstringwidth.js n=100000 type='emojiseq'                  2.94 %       ±7.66% ±10.19% ±13.26%
     misc/getstringwidth.js n=100000 type='fullwidth'                 4.70 %       ±5.64%  ±7.50%  ±9.76%
@nodejs-github-bot nodejs-github-bot added the readline Issues and PRs related to the built-in readline module. label Aug 25, 2019
lib/internal/readline/utils.js Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Aug 25, 2019
@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented Sep 3, 2019

Landed in ab841d5

@Trott Trott closed this Sep 3, 2019
Trott pushed a commit that referenced this pull request Sep 3, 2019
A lot of strings that are going to be passed to `getStringWidth()`
are ASCII strings, for which the calculation is rather easy and
calling into C++ can be skipped.

                                                       confidence improvement accuracy (*)    (**)   (***)
     misc/getstringwidth.js n=100000 type='ascii'            ***    328.99 %      ±21.73% ±29.25% ±38.77%
     misc/getstringwidth.js n=100000 type='emojiseq'                  2.94 %       ±7.66% ±10.19% ±13.26%
     misc/getstringwidth.js n=100000 type='fullwidth'                 4.70 %       ±5.64%  ±7.50%  ±9.76%

PR-URL: #29301
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
BridgeAR pushed a commit that referenced this pull request Sep 3, 2019
A lot of strings that are going to be passed to `getStringWidth()`
are ASCII strings, for which the calculation is rather easy and
calling into C++ can be skipped.

                                                       confidence improvement accuracy (*)    (**)   (***)
     misc/getstringwidth.js n=100000 type='ascii'            ***    328.99 %      ±21.73% ±29.25% ±38.77%
     misc/getstringwidth.js n=100000 type='emojiseq'                  2.94 %       ±7.66% ±10.19% ±13.26%
     misc/getstringwidth.js n=100000 type='fullwidth'                 4.70 %       ±5.64%  ±7.50%  ±9.76%

PR-URL: #29301
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@BridgeAR BridgeAR mentioned this pull request Sep 3, 2019
BridgeAR pushed a commit that referenced this pull request Sep 4, 2019
A lot of strings that are going to be passed to `getStringWidth()`
are ASCII strings, for which the calculation is rather easy and
calling into C++ can be skipped.

                                                       confidence improvement accuracy (*)    (**)   (***)
     misc/getstringwidth.js n=100000 type='ascii'            ***    328.99 %      ±21.73% ±29.25% ±38.77%
     misc/getstringwidth.js n=100000 type='emojiseq'                  2.94 %       ±7.66% ±10.19% ±13.26%
     misc/getstringwidth.js n=100000 type='fullwidth'                 4.70 %       ±5.64%  ±7.50%  ±9.76%

PR-URL: #29301
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Rich Trott <[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. readline Issues and PRs related to the built-in readline module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants