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

querystring: improve querystring unescapeBuffer perf #12525

Closed
wants to merge 4 commits into
base: master
from

Conversation

Projects
None yet
6 participants
@jseijas
Contributor

jseijas commented Apr 19, 2017

Refactored the unescapeBuffer function in order to simplify it,
and also to improve the performance.

The benchmark:

querystring/querystring-unescapebuffer.js n=1000000 input="%20%21%2..."
   18.10 %        *** 6.671620e-29
querystring/querystring-unescapebuffer.js n=1000000 input="there%20..."
   2.75 %          * 1.775320e-02
querystring/querystring-unescapebuffer.js n=1000000 input="there%2Q..."
   34.12 %        *** 8.074612e-25
querystring/querystring-unescapebuffer.js n=1000000 input="there is..."
   27.92 %        *** 4.923348e-29
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)
lib: improve querystring unescapeBuffer perf
Refactored the unescapeBuffer function in order to simplify it,
and also to improve the performance.

The benchmark:

```improvement confidence      p.value
querystring/querystring-unescapebuffer.js n=1000000 input="%20%21%2..."
   18.10 %        *** 6.671620e-29
querystring/querystring-unescapebuffer.js n=1000000 input="there%20..."
   2.75 %          * 1.775320e-02
querystring/querystring-unescapebuffer.js n=1000000 input="there%2Q..."
   34.12 %        *** 8.074612e-25
querystring/querystring-unescapebuffer.js n=1000000 input="there is..."
   27.92 %        *** 4.923348e-29
```
@vsemozhetbyt

This comment has been minimized.

}

This comment has been minimized.

@mscdex

mscdex Apr 19, 2017

Contributor

Unnecessary whitespace change

This comment has been minimized.

@jseijas

jseijas Apr 19, 2017

Contributor

What is the standard? Because the file contains both 2 and 1 line separation between functions.

This comment has been minimized.

@mscdex

mscdex Apr 19, 2017

Contributor

My own opinion is that such changes should be addressed separately.

if (c === 37 /*'%'*/ && index < maxLength) {
c = s.charCodeAt(++index);
n = unhexTable[c];
if (n < 0) {

This comment has been minimized.

@mscdex

mscdex Apr 19, 2017

Contributor

This won't work for characters not in the table. This is why I had used !(n >= 0), which will cover undefined as well.

} else {
c1 = s.charCodeAt(++index);
m = unhexTable[c1];
if (m < 0) {

This comment has been minimized.

@mscdex

mscdex Apr 19, 2017

Contributor

Ditto.

@mscdex

This comment has been minimized.

Contributor

mscdex commented Apr 19, 2017

The subsystem target in the commit message should be querystring instead of lib.

@jseijas jseijas changed the title from lib: improve querystring unescapeBuffer perf to querystring: improve querystring unescapeBuffer perf Apr 19, 2017

@jseijas

This comment has been minimized.

Contributor

jseijas commented Apr 19, 2017

@mscdex subsystem changed, also the three changes asked commited.

if (c === 37 /*'%'*/ && index < maxLength) {
c = s.charCodeAt(++index);
n = unhexTable[c];
if !(n >= 0) {

This comment has been minimized.

@mscdex

mscdex Apr 19, 2017

Contributor

Missing parens. These sorts of things should be caught by make jslint.

} else {
c1 = s.charCodeAt(++index);
m = unhexTable[c1];
if !(m >= 0) {

This comment has been minimized.

@mscdex

mscdex Apr 19, 2017

Contributor

Ditto.

@jseijas

This comment has been minimized.

Contributor

jseijas commented Apr 19, 2017

@mscdex sorry, fixed, lint passing ok, also tests.

break;
var index = 0;
var outIndex = 0;
var c, c1, n, m;

This comment has been minimized.

@mscdex

mscdex Apr 24, 2017

Contributor

Can we name these better and place them on separate lines?

@mscdex

This comment has been minimized.

Contributor

mscdex commented Apr 24, 2017

My benchmark results seem to agree more or less with those already posted.

querystring: improve querystring unescapeBuffer perf
Rename variables and separate in lines.
@jseijas

This comment has been minimized.

Contributor

jseijas commented Apr 25, 2017

@mscdex Variables renamed and separated in lines. Lint passing. UT passing. Benchmark times remains similar.

@mscdex

This comment has been minimized.

Contributor

mscdex commented Apr 25, 2017

@jseijas

This comment has been minimized.

Contributor

jseijas commented May 23, 2017

Hi @mscdex! Do you need more changes to be made, or you are ok with this? I see that not all the CI is passing :(

@lpinca

This comment has been minimized.

Member

lpinca commented May 23, 2017

@mscdex

This comment has been minimized.

Contributor

mscdex commented May 23, 2017

@jseijas It's fine if CI still checks out and there are no performance regressions. Can you please rebase against current master and re-run the benchmarks? I think V8 5.8 was added since this PR was opened and may/may not have an impact on this.

@jseijas

This comment has been minimized.

Contributor

jseijas commented May 23, 2017

@mscdex Of course I can :) I will come back with the results.

@jseijas

This comment has been minimized.

Contributor

jseijas commented May 23, 2017

@mscdex Done. Now is even better.

 querystring/querystring-unescapebuffer.js n=1000000 input="%20%21%2..."
    25.54 %        *** 5.020680e-28
 querystring/querystring-unescapebuffer.js n=1000000 input="there%20..."           
    16.14 %        *** 2.536763e-22
 querystring/querystring-unescapebuffer.js n=1000000 input="there%2Q..."                        
    22.93 %        *** 3.068218e-17
 querystring/querystring-unescapebuffer.js n=1000000 input="there is..."                                            
    35.53 %        *** 4.584131e-27

@lpinca

lpinca approved these changes May 24, 2017

@mscdex

This comment has been minimized.

Contributor

mscdex commented May 24, 2017

LGTM

@lpinca

This comment has been minimized.

Member

lpinca commented May 26, 2017

Landed in 19685ea.

@lpinca lpinca closed this May 26, 2017

lpinca added a commit that referenced this pull request May 26, 2017

querystring: improve unescapeBuffer() performance
Refactored the `unescapeBuffer` function in order to simplify it,
and also to improve the performance.

PR-URL: #12525
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>

jasnell added a commit that referenced this pull request May 28, 2017

querystring: improve unescapeBuffer() performance
Refactored the `unescapeBuffer` function in order to simplify it,
and also to improve the performance.

PR-URL: #12525
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>

@jasnell jasnell referenced this pull request May 28, 2017

Closed

8.0.0 Release Proposal #12220

@gibfahn gibfahn referenced this pull request Jun 15, 2017

Closed

Auditing for 6.11.1 #230

2 of 3 tasks complete
@MylesBorins

This comment has been minimized.

Member

MylesBorins commented Jul 17, 2017

should this land in LTS? If so it will need to bake a bit longer.

Please change labels as appropriate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment