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
Performance of tokio-postgres
worse than postgres
?
#469
Comments
The current postgres crate is just a little wrapper over tokio-postgres. I guess there are a couple of places the throughput difference could be coming from:
|
After experiments I realized that I was essentially benchmarking
When switching back to
I haven't tested Could all this be caused by a performance regression of |
I'm by no means an expert writing benchmarks and async code but after having invested so much time into this whole affair I decided to write a benchmark showing the performance regression of https://github.com/bikeshedder/rust-postgres-benchmark Results:
DisclaimerI had a hard time benchmarking the async code and |
Thanks for those numbers! Is the first result ordered backwards, though?
It's not super surprising to me that we'd be regressing a bit from There have been some other performance reports about the RC releases, but they've dealt with large data volumes: #450 where the small constant costs don't really matter. |
Whops. I fixed the comment. That's indeed what I meant. |
I wrote up a quick criterion benchmark to get some more precise numbers: https://gist.github.com/sfackler/4188bf8789ac6eee50502f6331392711. Here are the numbers, at least on my local Linux VM:
Interestingly, query preparation is actually faster now, but we've lost some ground on making the query itself. |
I'm in the process of moving across the country, so I probably won't be able to spend too much time on this for the next week or two. However, given that prepare is now faster than it used to be, I'm hopeful we can make the same thing happen for query. |
Hey @sfackler -- you're planning to address these query performance issues prior to v16, correct? |
I'm not sure - from profiling it appears that much of the time is being spent allocating and managing channels per request. There are more options to fix that with std::futures than old futures. |
I moved from a static multi-threaded runtime to per-connection runtimes for a 20% improvement: 09a63d6. |
I updated the benchmark repository and rerun it. I might be doing something wrong but it performance wise it doesn't look like 09a63d6 did have any effect: https://github.com/bikeshedder/rust-postgres-benchmark postgres-0.15.2
postgres-0.16-rc.2
tokio-postgres-0.3.0
tokio-postgres-0.4.0-rc.3
tokio-postgres-0.5.0-alpha.2
tokio-postgres-0.5.0-09a63d6
|
That commit isn't in a published release. |
The benchmark tokio-postgres = { git = "https://github.com/sfackler/rust-postgres", commit = "09a63d62553da1625c0f8385ab15e815b78d587d", features = ["with-uuid-0_7"] } |
That commit doesn't change any code in |
While I see a ton of variance across runs, the performance of querying one row from a pre-prepared statement is roughly the same in the current master branch and postgres 0.15. |
I think this one can be closed. The performance of |
I just started dipping my feet into
actix
water and wanted to go full async. After having a look at existing connection pools I tried bothbb8
and the experimentall337
connection pool just to find that they both perform worse thanr2d2
+postgres
+web::block
:https://bitbucket.org/bikeshedder/actix_web_async_postgres/src/master/
I did not expect those results and wonder if I'm doing anything wrong? I surely did expect
tokio-postgres
to outperformpostgres
with ease. Am I doing anything wrong? Are the pools causing the performance drop or istokio-postgres
the culprit?I have yet to create a benchmark between
tokio-postgres
andpostgres
without the use of connection pools. Just posting this here to document my progress in the hope someone can tell if I'm doing anything wrong.The text was updated successfully, but these errors were encountered: