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

Reduce benchmark test run time #18778

Closed
BridgeAR opened this issue Feb 14, 2018 · 20 comments
Closed

Reduce benchmark test run time #18778

BridgeAR opened this issue Feb 14, 2018 · 20 comments
Labels
benchmark Issues and PRs related to the benchmark subsystem. good first issue Issues that are suitable for first-time contributors. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. test Issues and PRs related to the tests.

Comments

@BridgeAR
Copy link
Member

BridgeAR commented Feb 14, 2018

Right now our benchmarks often contain millions or thousands as iteration step. This should be changed to n (in case of a conflict e.g. iterations) where the concrete number is given.

This allows our tests to significantly run faster, since the minimum iteration will not be a million times but a single time. The corresponding benchmark tests should be changed as well therefore.

Another benefit of it is that it is easier to read how fast the operation really was.

It would be great if a PR would change all entries at once or all entries of a subsystem to prevent conflicting changes. If someone starts working on this, please leave a note when you do so and on what you work so others know.

As soon as the benchmarks and the tests get fixed there would be a follow up task to check how long each individual sequential benchmark tests takes that was changed and if it would be possible to move them from sequential to parallel.

I will gladly assist as a mentor in case help is needed.

Update: I "removed the parts that do not apply anymore. The rest is still up to date and open.

@BridgeAR BridgeAR added help wanted Issues that need assistance from volunteers or PRs that need help to proceed. test Issues and PRs related to the tests. benchmark Issues and PRs related to the benchmark subsystem. good first issue Issues that are suitable for first-time contributors. mentor-available labels Feb 14, 2018
@apapirovski
Copy link
Member

This allows our tests to significantly run faster, since the minimum iteration will not be a million times but a single time. The corresponding benchmark tests should be changed as well therefore.

I don't believe this is correct. We set thousands to 0.001 to counteract that problem.

@BridgeAR
Copy link
Member Author

BridgeAR commented Feb 14, 2018

@apapirovski seems like we missed to add the argument for the buffers test. That does not contain the millions entry even though it should. I stumbled across it when looking at the coverage. After seeing that some operations where executed over a million times, I expected it to be the test.

@apapirovski
Copy link
Member

@BridgeAR good eye. Should be an easy change if someone wants to make a very simple but impactful first commit.

@juggernaut451
Copy link
Contributor

i would like to take this up @BridgeAR @apapirovski

@juggernaut451
Copy link
Contributor

@BridgeAR can you please tell exactly which file to work on?

@BridgeAR
Copy link
Member Author

So the test file is /test/sequential/test-benchmark-buffer.js. So you can either add a millions = 1/1e6 entry. Or you work on the benchmarks and remove the millions entries there and switch to n instead. Just look for all millions and thousands entries in the /benchmark folder.

@juggernaut451
Copy link
Contributor

@BridgeAR can i put millions = 0.000001 rather than 1/1e6 as Benchmark in common/benchmark.js set 1/1e6 as NaN

@BridgeAR
Copy link
Member Author

@juggernaut451 yes, for me it was only a way of writing the number that should be passed in.

@AndreasMadsen
Copy link
Member

I would definitely prefer the consistency only using n.

@BridgeAR
Copy link
Member Author

I would also prefer to consistently use n. So this is definitely still up as good first/second contribution.

@juggernaut451
Copy link
Contributor

juggernaut451 commented Feb 17, 2018

@BridgeAR working on it..

@juggernaut451
Copy link
Contributor

@BridgeAR in some cases n is already defined. Which may give arise to conflict when renaming millions -> n. For example in benchmark/es/spread-assign.js.

@AndreasMadsen
Copy link
Member

In that case n is the number you want, so that shouldn't cause any problems.

const bench = common.createBenchmark(main, {
  method: ['spread', 'assign', '_extend'],
  count: [5, 10, 20],
- millions: [1]
+ n: [1e6]
});

- function main({ millions, context, count, rest, method }) {
+ function main({ n, context, count, rest, method }) {
-   const n = millions * 1e6;

@juggernaut451
Copy link
Contributor

thank you @AndreasMadsen :)

@juggernaut451
Copy link
Contributor

juggernaut451 commented Feb 21, 2018

In benchmark/process/next-tick-depth-args.js there is already variable n that is being manipulate inside the file and bench.end is passing millions. Will there be conflict if i change millions -> n ?

@BridgeAR
Copy link
Member Author

@juggernaut451 please always check how the variables are used. In this particular case it is that n is what we want to have. So you just have to replace millions with n and you are done.

diff --git a/benchmark/process/next-tick-depth-args.js b/benchmark/process/next-tick-depth-args.js
index 1c1b95bdc8..52c6f4f431 100644
--- a/benchmark/process/next-tick-depth-args.js
+++ b/benchmark/process/next-tick-depth-args.js
@@ -2,13 +2,12 @@
 
 const common = require('../common.js');
 const bench = common.createBenchmark(main, {
-  millions: [12]
+  n: [12e6]
 });
 
 process.maxTickDepth = Infinity;
 
-function main({ millions }) {
-  var n = millions * 1e6;
+function main({ n }) {
 
   function cb4(arg1, arg2, arg3, arg4) {
     if (--n) {
@@ -21,7 +20,7 @@ function main({ millions }) {
       else
         process.nextTick(cb1, 0);
     } else
-      bench.end(millions);
+      bench.end(n);
   }
   function cb3(arg1, arg2, arg3) {
     if (--n) {
@@ -34,7 +33,7 @@ function main({ millions }) {
       else
         process.nextTick(cb1, 0);
     } else
-      bench.end(millions);
+      bench.end(n);
   }
   function cb2(arg1, arg2) {
     if (--n) {
@@ -47,7 +46,7 @@ function main({ millions }) {
       else
         process.nextTick(cb1, 0);
     } else
-      bench.end(millions);
+      bench.end(n);
   }
   function cb1(arg1) {
     if (--n) {
@@ -60,7 +59,7 @@ function main({ millions }) {
       else
         process.nextTick(cb1, 0);
     } else
-      bench.end(millions);
+      bench.end(n);
   }
   bench.start();
   process.nextTick(cb1, true);

@juggernaut451
Copy link
Contributor

ok thanks was just confirming so that things don't mess up

@juggernaut451
Copy link
Contributor

juggernaut451 commented Feb 21, 2018

@BridgeAR benchmark/process/next-tick-breadth-args.js file already contain n and millions value is being allocated to N which is giving conflict as n is already defined

@juggernaut451
Copy link
Contributor

juggernaut451 commented Feb 21, 2018

ignore the last comment. Figured out the solution

@juggernaut451
Copy link
Contributor

I have raised the pull request. Please review it

targos pushed a commit that referenced this issue 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
benchmark Issues and PRs related to the benchmark subsystem. good first issue Issues that are suitable for first-time contributors. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. test Issues and PRs related to the tests.
Projects
None yet
Development

No branches or pull requests

4 participants