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

test: speed up stringbytes-external test #3005

Merged
merged 1 commit into from
Oct 6, 2015

Conversation

evanlucas
Copy link
Contributor

test-stringbytes-external tends to take quite a while on slower
hardware. A lot of the time is taken by creating a new buffer that is
very large. The improvements come from reusing the same buffer.

Before:

$ time ./node test/parallel/test-stringbytes-external.js
        4.33 real         2.36 user         1.89 sys

After:

$ time ./node test/parallel/test-stringbytes-external.js 
        2.48 real         1.44 user         1.03 sys

Related: #2370

R= @trevnorris

@evanlucas
Copy link
Contributor Author

@mscdex mscdex added the test Issues and PRs related to the tests. label Sep 22, 2015
@mscdex
Copy link
Contributor

mscdex commented Sep 22, 2015

LGTM

1 similar comment
@trevnorris
Copy link
Contributor

LGTM

@trevnorris
Copy link
Contributor

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

EDIT: immediate scroll from top to bottom omitted showing the first CI in my browser window.

@@ -112,9 +112,11 @@ var PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS;
(function() {
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
const buf1 = new Buffer(kStringMaxLength + 1);
const buf2 = new Buffer(kStringMaxLength);
Copy link
Contributor

Choose a reason for hiding this comment

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

These allocations need to be after the try catch else it would fail on Raspberry Pi 1/2.

Copy link
Contributor

Choose a reason for hiding this comment

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

awesome save. Thanks for catching this.

@evanlucas
Copy link
Contributor Author

Weird...it seems like the test is slower on all of the CI machines with this? Locally, it is about a 20% improvement...

@@ -126,12 +122,19 @@ var PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS;
return;
}

const buf1 = new Buffer(kStringMaxLength + 1);
const buf2 = new Buffer(kStringMaxLength);
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably, buf2 can be moved below and created only when it is actually used.

@evanlucas evanlucas force-pushed the speedupesb branch 2 times, most recently from 47d5f36 to ebc1aef Compare September 22, 2015 23:12
@evanlucas
Copy link
Contributor Author

Made some changes with the help of @trevnorris. Should be improved quite a bit more now.

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

@@ -126,50 +122,57 @@ var PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS;
return;
}

const buf0 = new Buffer(kStringMaxLength * 2 + 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we slice this off the Buffer allocated in the try..catch above?

Copy link
Contributor

Choose a reason for hiding this comment

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

That would work. my worry is that we allocate 256MB more than needed above, and if we hang on to that then the tests that turn these into strings will need to increase the heap by an additional 256MB. Hence why over allocating in the check above is a small way to ensure the heap has enough space for the toString() calls below.

@silverwind
Copy link
Contributor

This is still haunting the CI, LGTM.

The improvement looks to be around 20% right now, still worth it imho:

node test/parallel/test-stringbytes-external.js 
3.28s user 2.95s system 92% cpu 6.713 total
node test/parallel/test-stringbytes-external.js 
2.95s user 2.06s system 92% cpu 5.417 total

@evanlucas
Copy link
Contributor Author

@mscdex and @trevnorris mind taking a look again since changes have been made since your signed off on it?

@trevnorris
Copy link
Contributor

Changes LGTM

@trevnorris
Copy link
Contributor

Maybe this will need to be broken into two tests so as to not exceed the time limit.

@evanlucas
Copy link
Contributor Author

You want me to go ahead and do that?

@silverwind
Copy link
Contributor

I think I'd also prefer a split, but that can be done in another PR.

@trevnorris
Copy link
Contributor

@evanlucas Don't worry about splitting it now. We can handle that later. If CI on latest changes is happy then I'd say land it. (on vacation ATM so can't do it myself)

@evanlucas
Copy link
Contributor Author

@evanlucas
Copy link
Contributor Author

Still failing on arm. I've got a Pi2 I'm messing with locally, so will try to split the test up and see if that helps

@trevnorris
Copy link
Contributor

@evanlucas Still wouldn't worry about the failing tests on arm. They were failing before. This PR is an incremental improvement, and splitting the test up can happen in another PR. I move we land this as is.

test-stringbytes-external tends to take quite a while on slower
hardware. A lot of the time is taken by creating a new buffer that is
very large. The improvements come from reusing the same buffer.

PR-URL: nodejs#3005
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
@evanlucas evanlucas closed this Oct 6, 2015
@evanlucas evanlucas deleted the speedupesb branch October 6, 2015 17:07
@evanlucas evanlucas merged commit 7d66749 into nodejs:master Oct 6, 2015
@evanlucas
Copy link
Contributor Author

Landed in 7d66749. Thanks!

@jasnell jasnell mentioned this pull request Oct 8, 2015
29 tasks
evanlucas added a commit that referenced this pull request Oct 8, 2015
test-stringbytes-external tends to take quite a while on slower
hardware. A lot of the time is taken by creating a new buffer that is
very large. The improvements come from reusing the same buffer.

PR-URL: #3005
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
@ChALkeR ChALkeR added the performance Issues and PRs related to the performance of Node.js. label Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Issues and PRs related to the performance of Node.js. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants