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

Buffer performance degradation in 6.6.0 #8733

Closed
CurryKitten opened this issue Sep 23, 2016 · 8 comments
Closed

Buffer performance degradation in 6.6.0 #8733

CurryKitten opened this issue Sep 23, 2016 · 8 comments
Labels
buffer Issues and PRs related to the buffer subsystem. performance Issues and PRs related to the performance of Node.js.

Comments

@CurryKitten
Copy link
Contributor

CurryKitten commented Sep 23, 2016

When comparing 6.6.0 against 6.5.0 using one of our benchmarks, we’ve noticed that there’s a performance degradation in the buffer code. We’re running a benchmark that creates a new buffer from an array as many times as it can over a given period of time, for example -

var ARRAY = [1, 2, 23829, 4, 5, 7, 12312321, 2131, 434832, 43792, 23421, 65345, 132210, 77777, 322131, 1, 2, 23829, 4, 5, 7, 12312321, 2131, 434832, 43792, 23421, 65345, 132210, 77777, 322131, 1, 2, 23829, 4, 5, 7, 12312321, 2131, 434832, 43792, 23421, 65345, 132210, 77777, 322131, 1, 2, 23829, 4, 5, 7, 12312321, 2131, 434832, 43792, 23421, 65345, 132210, 77777, 322131];
var ITERATIONS = 300000;
var result;

function test() {
        for(var i=0;i<ITERATIONS;i++) {
                result = new Buffer(ARRAY);
        }
}

On 6.6.0 there an approx 10% slowdown over 6.5.0. Been working through the likely reasons with @gareth-ellis and found that this appears to have been caused by PR #8453 where in buffer.js instances of

if (value instanceof ArrayBuffer)

have been changed to

if (isArrayBuffer(value))

We saw this regression on Linux PPC64, however, if we back this change out of 6.6.0 and rebuild on both Linux PPC64 and Linux Intel, then we see a performance increase, suggesting that the change is having an adverse affect on buffer performance.

@claudiorodriguez claudiorodriguez added buffer Issues and PRs related to the buffer subsystem. performance Issues and PRs related to the performance of Node.js. labels Sep 23, 2016
@addaleax
Copy link
Member

I’ll look into this. I assume the overhead comes from the explicit call into C++, so it trades of correctness for performance; I guess this particular case could be easily improved with an Array.isArray() shortcut, but I’ll try to make the Buffer benchmarking suite a bit more comprehensive to get an accurate picture of how Buffer.from() performs.

addaleax added a commit to addaleax/node that referenced this issue Sep 23, 2016
Adds benchmarks for `Buffer.from()` and its various
argument combinations.

Ref: nodejs#8733
@addaleax
Copy link
Member

Benchmark PR for Buffer.from(): #8738

@trevnorris
Copy link
Contributor

I threw up a branch w/ a commit that should gain back that performance issue: trevnorris@e555b5a

not putting that in a PR just yet because it doesn't fix the actual problem. was just able to find performance elsewhere that was lying around.

@addaleax
Copy link
Member

btw, #8739 touches the same code, so you may want to comment there too, once you know more?

@Fishrock123
Copy link
Contributor

fix is in #8754 I think?

@addaleax
Copy link
Member

No, that is a distinct performance regression –#8754 fixes a performance regression that comes with the V8 5.4 upgrade, nothing that’s released yet.

addaleax added a commit that referenced this issue Sep 26, 2016
Adds benchmarks for `Buffer.from()` and its various
argument combinations.

Ref: #8733
PR-URL: #8738
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
jasnell pushed a commit that referenced this issue Sep 29, 2016
Adds benchmarks for `Buffer.from()` and its various
argument combinations.

Ref: #8733
PR-URL: #8738
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Fishrock123 pushed a commit that referenced this issue Oct 11, 2016
Adds benchmarks for `Buffer.from()` and its various
argument combinations.

Ref: #8733
PR-URL: #8738
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@Trott
Copy link
Member

Trott commented Jul 10, 2017

Is this still an issue?

@apapirovski
Copy link
Member

I'm going to go ahead and close given the lack of any updates or movement in over a year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

No branches or pull requests

7 participants