Skip to content

Conversation

@bnoordhuis
Copy link
Member

Replace a call to isNaN(n) with n !== n. Removes most of the
overhead from the following hotspot:

13.59%  iojs             perf-603.map         [.] LazyCompile:*isNaN
native v8natives.js:67

R=@chrisdickinson, /cc @trevnorris

CI: https://jenkins-iojs.nodesource.com/view/iojs/job/iojs+any-pr+multi/784/

Replace a call to `isNaN(n)` with `n !== n`.  Removes most of the
overhead from the following hotspot:

    13.59%  iojs             perf-603.map         [.] LazyCompile:*isNaN
    native v8natives.js:67
@trevnorris
Copy link
Contributor

LGTM

@brendanashworth
Copy link
Contributor

ref: #936

@brendanashworth brendanashworth added the stream Issues and PRs related to the stream subsystem. label Jun 9, 2015
@Fishrock123
Copy link
Contributor

LGTM

@mscdex
Copy link
Contributor

mscdex commented Jun 9, 2015

LGTM but perhaps there should be a comment in case someone stumbles upon this and does not understand it?

Copy link
Contributor

Choose a reason for hiding this comment

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

What if state is undefined?

@trevnorris
Copy link
Contributor

@bnoordhuis What would you like to do here?

@chrisdickinson
Copy link
Contributor

A note: we're really checking for n === undefined here (from read() calls with no argument.) Perhaps it'd be better to make -1 the special arg and always provide it?

@Fishrock123
Copy link
Contributor

@chrisdickinson if you're sure that's what it is then it sounds good to me.

(Also I'll try to get ab installed on my perf machine today so I can test it.) ((why did we think removing that from our deps was a good idea?? it's a pain to get!))

apt-get install apache2-utils

@Fishrock123
Copy link
Contributor

Perhaps the original isn't an issue anymore with a newer v8?

perf report:

 0.11%     0.11%  iojs     perf-22222.map       [.] LazyCompile:*isNaN native v8natives.js:67 

From perf record -c 50000 -e cpu-clock -g -i io.js/iojs --perf_basic_prof io.js/benchmark/http_simple_auto.js -k -t 10 -c 100 -n1000000 on master.

@bnoordhuis
Copy link
Member Author

@Fishrock123 You're not passing a request path. Try bytes/8 or buffer/8.

@dcousens
Copy link

This should really just be if (n === undefined || n === null) {.

We are not checking types anywhere else, as can be seen by the possible type explosion: state.buffer.length (cannot read property 'length' of undefined).

@cjihrig
Copy link
Contributor

cjihrig commented Nov 9, 2015

@bnoordhuis what is the status of this one liner?

@bnoordhuis
Copy link
Member Author

Closing, I'll revisit when it comes up again.

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

Labels

stream Issues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants