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 : millions and thounsand changed to n in benchmark #18917

Closed
wants to merge 3 commits into from

Conversation

juggernaut451
Copy link
Contributor

@juggernaut451 juggernaut451 commented Feb 21, 2018

This is refactoring of the benchmark.
It contained millions or thousands which is changed to n

Fixes : #18778

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test, benchmark

@nodejs-github-bot nodejs-github-bot added benchmark Issues and PRs related to the benchmark subsystem. buffer Issues and PRs related to the buffer subsystem. module Issues and PRs related to the module subsystem. process Issues and PRs related to the process subsystem. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. v8 engine Issues and PRs related to the V8 dependency. labels Feb 21, 2018
function main({ millions, size, args }) {
const iter = millions * 1e6;
function main({ n, size, args }) {
const iter = n * 1e6;
Copy link
Member

Choose a reason for hiding this comment

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

Hm, it seems like the description in #18778 was not clear enough: it was not about just replacing the variable name. Instead of having millions = 1 it should be n = 1e6, not n = 1. That applies to all of these changes.

This also has influence on the for loops and the benchmark end call. These should be changed accordingly.

If there is a iter variable as here, it is likely obsolete and it could be replaced with n instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

working on it.

@BridgeAR
Copy link
Member

@juggernaut451 since you opened multiple pull requests so far: would you be so kind and please have another look at the commit guidelines?

@juggernaut451
Copy link
Contributor Author

@BridgeAR changed the commit message. Thank you for pointing out.

@BridgeAR
Copy link
Member

@juggernaut451 So far nothing is changed. I guess you did not push your commit. If you want to change the commit message, you have to change the commit history by force pushing. Please use git push --force-with-lease.

@juggernaut451 juggernaut451 changed the title Fixes : https://github.com/nodejs/node/issues/18778 test : millions and thounsand changed to n in benchmark Feb 22, 2018
@juggernaut451
Copy link
Contributor Author

@BridgeAR sorry forgot to push the message. Can you please check now?

@@ -5,7 +5,7 @@ const assert = require('assert');

const bench = common.createBenchmark(main, {
method: ['withoutdefaults', 'withdefaults'],
millions: [100]
n: [100e6]
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to use 1e8 for consistency. (ditto throughout)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@starkwang so everywhere I should replace the value of n with 1e8?

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure what the question stands for. Is there something unclear with the suggestion from @starkwang ?

Copy link
Member

Choose a reason for hiding this comment

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

@juggernaut451 100e6 means 100 * 1e6, 1e6 means 10^6. Thus 100e6 can be written as 1e8.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes made. Thanks

@@ -5,7 +5,7 @@ require('../common');
const runBenchmark = require('../common/benchmark');

runBenchmark('module', [
'thousands=.001',
'n=.001',
Copy link
Member

Choose a reason for hiding this comment

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

n=1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes made. Thanks

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

Besides the comments there are a couple of tests that still need to be changed as well. The millions and thousands entries should be replaced in that case.

b0.compare(b1, 0);
}
bench.end(iter / 1e6);
bench.end(n / 1e6);
Copy link
Member

Choose a reason for hiding this comment

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

bench.end should never say n / x. Instead, it should always only be n. That applies to all benchmarks and is missing in many files here.

Copy link
Member

Choose a reason for hiding this comment

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

Mostly correct. There are cases where we see how many requests a server can take over 10 seconds and then we run bench.end(numberOfRequests) but those are special cases.

@@ -5,7 +5,7 @@ const assert = require('assert');

const bench = common.createBenchmark(main, {
method: ['withoutdefaults', 'withdefaults'],
millions: [100]
n: [100e6]
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure what the question stands for. Is there something unclear with the suggestion from @starkwang ?

@@ -2,113 +2,113 @@
const common = require('../common.js');

const bench = common.createBenchmark(main, {
thousands: [5000],
n: [5000e3],
Copy link
Member

Choose a reason for hiding this comment

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

The comment from @starkwang applies here as well and in more places.

function depth(N) {
var n = 0;
function depth(n) {
var i = 0;
Copy link
Member

@BridgeAR BridgeAR Feb 27, 2018

Choose a reason for hiding this comment

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

This is a independent change and is not necessary. Please change it to the way it was before to reduce churn. This applies to all these functions in this test.

}

function benchInt(dv, fn, len, le) {
function benchInt(dv, fn, n, le) {
Copy link
Member

@BridgeAR BridgeAR Feb 27, 2018

Choose a reason for hiding this comment

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

Renaming this variable is not necessary. I would rather change it to the way as it was before to reduce churn. That applies to all functions in this test besides main.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this const len = millions * 1e6 was defined. There is no need of len as it's value is n. So that's why I replaced len with n. If I don't replace then I have to initialize the len

Copy link
Member

Choose a reason for hiding this comment

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

So what I meant is that only the main function is impacted by that change. You can keep the len argument here and only change len / 1e6 to len. That way there is less churn.

Copy link
Contributor Author

@juggernaut451 juggernaut451 Mar 1, 2018

Choose a reason for hiding this comment

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

that sounds good. Thanks :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes made.

bench.end(n / 1e6);
j++;
if (j === n)
bench.end(i / 1e6);
Copy link
Member

Choose a reason for hiding this comment

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

Please do not use i but n here and only n and no division as mentioned in another comment. That applies to all cases in this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes made :)

const N = millions * 1e6;
var n = 0;
function main({ n }) {

Copy link
Member

Choose a reason for hiding this comment

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

Nit: please remove the line break here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes made :)

function main({ millions }) {
var n = millions * 1e6;
function main({ n }) {


Copy link
Member

Choose a reason for hiding this comment

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

Please do not add double line breaks. This is a unnecessary change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes made :)

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

This looks quite nice now.

}

function benchInt(dv, fn, len, le) {
function benchInt(dv, fn, n, le) {
Copy link
Member

Choose a reason for hiding this comment

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

So what I meant is that only the main function is impacted by that change. You can keep the len argument here and only change len / 1e6 to len. That way there is less churn.

Copy link
Member

@AndreasMadsen AndreasMadsen left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, this is something that has annoyed me for a long time and confused new users, thus I'm very happy to see this is now fixed :)

Well done!

@juggernaut451
Copy link
Contributor Author

Thanks, @AndreasMadsen

Copy link
Member

@apapirovski apapirovski left a comment

Choose a reason for hiding this comment

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

LGTM but needs to be rebased and there's a small nit below.

@@ -39,9 +39,9 @@ const mod = {
setUint32: UINT32
};

function main({ millions, type }) {
function main({ n, type }) {
const len = n;
Copy link
Member

Choose a reason for hiding this comment

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

This could just use n throughout the main function rather than creating an extra variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is done to reduce the churn as requested by @BridgeAR

Copy link
Member

Choose a reason for hiding this comment

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

No, I actually explicitly excluded the main function in my comment ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

making the change on the main function too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes made

@starkwang
Copy link
Contributor

@juggernaut451
Copy link
Contributor Author

Resolved :)

@starkwang
Copy link
Contributor

@juggernaut451
Copy link
Contributor Author

can someone help me in understanding what exactly is failing?

@gibfahn
Copy link
Member

gibfahn commented Mar 15, 2018

@juggernaut451 if you click on the CI link and scroll down to the bottom you'll see a link to node-test-commit:

image

If you click on that link you'll see that it failed, so you need to go to the Console Output on the right:

image

If you click that you'll see this:

+ git rebase --committer-date-is-author-date cd7d7b15c1eeccfe2facdf9a671034d93b6bf467
First, rewinding head to replay your work on top of it...
Applying: test : millions and thounsand changed to n in benchmark
Using index info to reconstruct a base tree...
M	benchmark/buffers/buffer-read-float.js
M	benchmark/buffers/buffer-read-with-byteLength.js
M	benchmark/buffers/buffer-read.js
M	benchmark/buffers/buffer-write.js
Falling back to patching base and 3-way merge...
Auto-merging benchmark/buffers/buffer-write.js
CONFLICT (content): Merge conflict in benchmark/buffers/buffer-write.js
Auto-merging benchmark/buffers/buffer-read.js
CONFLICT (content): Merge conflict in benchmark/buffers/buffer-read.js
Auto-merging benchmark/buffers/buffer-read-with-byteLength.js
CONFLICT (content): Merge conflict in benchmark/buffers/buffer-read-with-byteLength.js
Auto-merging benchmark/buffers/buffer-read-float.js
CONFLICT (content): Merge conflict in benchmark/buffers/buffer-read-float.js
error: Failed to merge in the changes.
Patch failed at 0001 test : millions and thounsand changed to n in benchmark
The copy of the patch that failed is found in: .git/rebase-apply/patch

I know that this PR isn't showing that there are conflicts, but the CI does the rebase in a different way.

I'm pretty sure this commit is the issue:

image

Basically what you need to do is to squash all your commits into one commit, and then rebase that on top of the upstream master branch.

@juggernaut451
Copy link
Contributor Author

Thank you @gibfahn

@juggernaut451
Copy link
Contributor Author

@starkwang can you please re run the CI

@richardlau
Copy link
Member

CI is currently locked down for the security release: #19642

Copy link
Member

@richardlau richardlau left a comment

Choose a reason for hiding this comment

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

"thousands" is misspelled in the commit message.

@ChALkeR
Copy link
Member

ChALkeR commented Mar 28, 2018

Perhaps var should be changed to let in the touched lines?
That works down to 6.x and I don't think this is going to be backported to 4.x.

@BridgeAR
Copy link
Member

BridgeAR commented Apr 9, 2018

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

@ChALkeR there are only very few lines that touch var in this PR. So I believe we should go ahead and land this instead of delaying it further for that.

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 9, 2018
@BridgeAR
Copy link
Member

BridgeAR commented Apr 9, 2018

Landed in b80da63 🎉

@BridgeAR BridgeAR closed this Apr 9, 2018
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Apr 9, 2018
PR-URL: nodejs#18917
Fixes: nodejs#18778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
targos pushed a commit that referenced this pull request Apr 12, 2018
PR-URL: #18917
Fixes: #18778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
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. benchmark Issues and PRs related to the benchmark subsystem. buffer Issues and PRs related to the buffer subsystem. module Issues and PRs related to the module subsystem. process Issues and PRs related to the process subsystem. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants