-
Notifications
You must be signed in to change notification settings - Fork 322
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
Tide without TCP_NODELAY performs unfavorably in benchmarks #814
Comments
Maybe same to this issue #781 |
try this. Use this patch to your
|
Hi flag, thanks for the patch, and actually .... the result is quite funny...:) After adding your patch to # Actually I also delete the `Cargo.Lock` file
cargo update
cargo clean && cargo build --bin benchmark_server --release So I run the release version and test it again: After that, test the node version again: And here is the result, I took a screenshot and then align them together which easier to compare: As you can see above, the Rust SHOULD fast than the node version, as the latency is low and balabala... which highlighted in the green colour. But somehow the node version can handle a lot of connections than the Rust one. That's why the Final result shows the node version got more throughput... (And btw, I use my iMac to run the above test, that's why the result is different from the very beginning when I created this issue which runs on my MacBookPro). I've already considered that the Node version spawns a few child processes (even the |
Also, I got another same situation and comparison result in my production service. I built a Binary Protocol Parser for encoding/decoding the hardware network data which transfers via TCP. I made a performance test for both Typescripts (run in Node) and Rust version (release binary). The test very simple: Just run the decode function in a for loop to parse the same lines of binary protocol data (basically, just a brunch of byte[] / [u8]). But the result is pretty funny which is the TypeScript one got more throughput than the Rust one. I consider that: Maybe in every for loop scope, the Rust version always re-allocate and de-allocate all the local var memories (should be almost a few million operations during the test), as I saw the rust binary memory footprint can keep around But the node version, it uses around Is that the same potential reason for the tide test result above? |
@wisonye might be out of scope, but I'd be curious to see how other web frameworks written in rust perform here, and if they produce similar results. Might be out of scope, but it made me curious |
Yup, it's not out of scope:) And I also want to see how other frameworks perform as well. If you have time then add a minimal demo here and see what happen:) |
I found |
Sorry, I've been too busy using Tide in prod to dig into this. I can tell you from production experience: it is orders of magnitude faster than Node.js for common workloads. |
autocannon against your node.js example:
Autocannon against Tide (--release):
That's kinda odd. It's definitely not what we observe but we also don't stress our Rust processes much (because they are plenty fast to carry our load). Notes: This was done by running the benchmarker on my laptop (a slower machine) against the server examples on my desktop (a faster machine). Everything is wired together on gigabit ethernet. |
Linux perf counter stats seem to indicate this is artificial (possibly
Of note there, Tide does a bunch more context switching, but it's not too bad, I think. Tide however uses less than a third of the cpu cycles. |
With tcp no_delay enabled via @jbr's draft PR (#823) I get:
Which is about on-par. I think my laptop is now the limiting factor. I'll try to run the benchmark in reverse. |
Also, for that last example, we're still using only about half the cpu cycles for the same number of requests as Node.
|
I am going to caution that no_delay may be ideal for this benchmarking workload but may not be ideal in the real world. |
tide
http server is slow than NodeJS
http server, plz :)
I run
Comparing with..
The result looks really strange. I'm not familiar with this topic, but I think the following link will help.
Also currently warp has a more satisfying result on my computer.
It's understandably microbenchmark doesn't reflect the whole real word. But the result can't persuade me that tide is good enough like other web app framework. |
@Fishrock123 @wisonye @slhmy Are there any tools to inspect where time is spent when the server is running, might offer some clues as to what you were seeing @wisonye |
Don't know if flamegraph(https://github.com/flamegraph-rs/flamegraph) will help... I'm kind of busy nowadays. |
I want to take bottom-up perf stacks but don't know how to offhand with rust (and I am super busy). |
autocannon to benchmark_server.js
autocanon tide --release, with TCP_NODELAY
And make a flamegraph. |
@slhmy |
@fiag .....That's funny:) But I remember that I did give it a try based on your patch branch for the |
🦀 Maybe more comparisons need to be made. I currently made I also found there is a huge performance loss if I put a async-sever into a docker machine. Combining to the above relate, I guess maybe |
@slhmy Thanks for that:) Also, here is my personal opinion:
|
Thanks a lot for your help, actually it''s related the issue I have post.
The 20s problem only appears in docker machine build by |
I wrote 2 performance testing minimal HTTP servers, one for
tide
(1.6) and one forNode.JS
, what I expect is that thetide
one should faster than theNode.JS
one. But the result is the opposite..., anyone has a try on this?:)Testing environment:
Here are the source code for both versions:
Both HTTP server have the same routes and responses below:
HTML
response (Benchmark testing
) for the default route/
:JSON
response for the/json-benchmark
route:Here is my
ulimit -a
output:Here is the test result:
NodeJS version:
recreate node project:
Node spwan 6 cluster workers to serve:
Rust version:
recreate node project:
The text was updated successfully, but these errors were encountered: