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

chore: Replace benchmark with cronometro for benchmarking. #751

Merged
merged 3 commits into from
Apr 20, 2021
Merged

chore: Replace benchmark with cronometro for benchmarking. #751

merged 3 commits into from
Apr 20, 2021

Conversation

ShogunPanda
Copy link
Contributor

This PR closes #715 and #736 by replacing benchmark with cronometro.

I also refactored the benchmark NPM scripts to use wait-on instead of a flat timeout for better reliability.

@ShogunPanda
Copy link
Contributor Author

@ronag If you run the new benchmark on the reference machine I'll update the README as well.

Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

Excellent work!

@codecov-commenter
Copy link

codecov-commenter commented Apr 20, 2021

Codecov Report

Merging #751 (ab5e0f0) into main (fb67839) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #751   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines         1904      1904           
=========================================
  Hits          1904      1904           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb67839...ab5e0f0. Read the comment docs.

@ronag
Copy link
Member

ronag commented Apr 20, 2021

It's a bit weird that http - keepalive is slowest?

@ShogunPanda
Copy link
Contributor Author

To be honest I have no idea. I've checked the code and everything seems to be fine. I wonder if the socket buffers are filled up and thus performance decrease.

@ronag
Copy link
Member

ronag commented Apr 20, 2021

What results do you get if you run it locally? Also what order are they run in? Could it be some kind of warm up thing? Should we run each test in a separate node instance?

@ronag
Copy link
Member

ronag commented Apr 20, 2021

Also the multiple socket results seem weird. Maybe they always have. Do we need those? @mcollina

I think in this case pipelining is seems to a disadvantage against core http that doesn't use pipelingin.

@ShogunPanda
Copy link
Contributor Author

Cronometro runs with "warmup" mode by default. For each test, it executes twice, the first time discarding results.
Tests are run in series and each is run in a separate worker thread so no interaction should be possible.

Here's my results:

╔════════════════════════════════════════════╤═════════╤═══════════════╤═══════════╤═════════════════════════╗
║ Slower tests                               │ Samples │        Result │ Tolerance │ Difference with slowest ║
╟────────────────────────────────────────────┼─────────┼───────────────┼───────────┼─────────────────────────╢
║ http - keepalive                           │     100 │  61.35 op/sec │  ± 1.08 % │                         ║
║ http - no agent                            │     100 │ 201.87 op/sec │  ± 2.03 % │ + 229.03 %              ║
║ http - keepalive - multiple sockets        │     100 │ 302.28 op/sec │  ± 1.92 % │ + 392.69 %              ║
║ undici - pipeline                          │     100 │ 377.43 op/sec │  ± 2.33 % │ + 515.18 %              ║
║ undici - pool - request - multiple sockets │     100 │ 392.54 op/sec │  ± 1.99 % │ + 539.80 %              ║
║ undici - request                           │     100 │ 395.92 op/sec │  ± 1.97 % │ + 545.32 %              ║
║ undici - stream                            │     100 │ 421.28 op/sec │  ± 1.91 % │ + 586.65 %              ║
║ undici - dispatch                          │     100 │ 426.49 op/sec │  ± 1.89 % │ + 595.14 %              ║
╟────────────────────────────────────────────┼─────────┼───────────────┼───────────┼─────────────────────────╢
║ Fastest test                               │ Samples │        Result │ Tolerance │ Difference with slowest ║
╟────────────────────────────────────────────┼─────────┼───────────────┼───────────┼─────────────────────────╢
║ undici - noop                              │     100 │ 538.81 op/sec │  ± 1.81 % │ + 778.21 %              ║
╚════════════════════════════════════════════╧═════════╧═══════════════╧═══════════╧═════════════════════════╝

@ronag
Copy link
Member

ronag commented Apr 20, 2021

Maybe http - no agent should be called http - no agent - multiple sockets? Or maybe just remove the no agent test as it is a bit confusing. I think it uses unlimited number of sockets by default.

@dnlup
Copy link
Contributor

dnlup commented Apr 20, 2021

It's a bit weird that http - keepalive is slowest?

That option uses 1 socket if I am not mistaken, so I suspect that requests are run sequentially in that case.

@ronag
Copy link
Member

ronag commented Apr 20, 2021

It's a bit weird that http - keepalive is slowest?

That option uses 1 socket if I am not mistaken, so I suspect that requests are run sequentially in that case.

Yea, I think it's the no agent case which is misleading.

@ronag
Copy link
Member

ronag commented Apr 20, 2021

@ShogunPanda can we split the benchmarks into multi socket and single socket ones? That way the relative values make more sense.

@dnlup
Copy link
Contributor

dnlup commented Apr 20, 2021

It's a bit weird that http - keepalive is slowest?

That option uses 1 socket if I am not mistaken, so I suspect that requests are run sequentially in that case.

Yea, I think it's the no agent case which is misleading.

I think so too because it's using the default Agent behind the scenes.

Copy link
Contributor

@dnlup dnlup left a comment

Choose a reason for hiding this comment

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

Awesome work

benchmarks/index.js Outdated Show resolved Hide resolved
benchmarks/index.js Outdated Show resolved Hide resolved
@ronag
Copy link
Member

ronag commented Apr 20, 2021

Is it possible to skip the grouping headers? The fastest test is always in the bottom so it's just noise, no?

@ShogunPanda
Copy link
Contributor Author

Is it possible to skip the grouping headers? The fastest test is always in the bottom so it's just noise, no?

Unfortunately not, that's fixed in cronometro.

I'll update benchmarks soon.

@ShogunPanda
Copy link
Contributor Author

Benchmarks updated. We have two different suites now. Let me know if I set everything correct.

@ronag
Copy link
Member

ronag commented Apr 20, 2021

Not related to this to this Pr per se. It’s interesting that the multi socket version has less diff between core and undici. Maybe the server should run cluster?

@ronag ronag merged commit 2968207 into nodejs:main Apr 20, 2021
@ShogunPanda ShogunPanda deleted the cronometro branch April 20, 2021 19:27
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
* chore: Replace benchmark with cronometro for benchmarking.

* chore: Spelling.

* chore: Separated tests in single and multiple sockets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make benchmarks relative to node core
4 participants