-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Improve aspcore DB benchmarks #4015
Conversation
bgrainger
commented
Aug 25, 2018
•
edited
Loading
edited
- Updates MySqlConnector and npgsql to latest published versions
- Improves MySqlConnector connection string
- Uses explicitly prepared commands (MySqlConnector only)
@@ -64,6 +64,8 @@ DbCommand CreateReadCommand(DbConnection connection) | |||
id.Value = _random.Next(1, 10001); | |||
cmd.Parameters.Add(id); | |||
|
|||
(cmd as MySql.Data.MySqlClient.MySqlCommand)?.Prepare(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebastienros Based on 14ad208 I decided to only opt MySqlConnector into this. It doesn't have npgsql's auto-prepare capability, so this improves performance by 10-15% (in my local Docker testing).
I tested changing this to just cmd.Prepare()
with aspcore-ado-pg
and got these results:
Test | Before | After | Change |
---|---|---|---|
Fortunes | 43492.60 | 43695.85 | -0.47% |
DB | 46917.18 | 47240.47 | +0.69% |
I'm not sure if this is significant, or just within the experimental margin-of-error.
Perhaps @roji has an opinion on whether explicit Prepare()
should be used for both npgsql and MySqlConnector or left like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we should probably update npgsql from 4.0.0-rc1 to 4.0.2, but I didn't address that in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle an explicit Prepare()
should be best for Npgsql. But IIRC there was some unexplained weirdness at some point where using auto-prepare was actually faster than explicit Prepare()
. I didn't have any time to look into it (and don't have any right now either...), but maybe @sebastienros can re-confirm this...
I confirm autoprepare increased the perf significantly over Prepare(). |
@sebastienros Once this is merged, can you change the four instances of
to
and check to see if you can still repro a performance decrease in |
Or instead measure before doing this change? |
That's fine if you want to measure before and after this change; based on my local testing I'm pretty confident in the net effect being about +20%. However, I really don't know if |
That's my concern, regression npgsql because I tested it by the past. Maybe there used to be an issue with how I will test this branch today for both dbs and update here. |
@sebastienros For npgsql specifically, can you test bgrainger@b4c23df as the baseline (that's updating npgsql to the latest version) then bgrainger@d501e97 as a variant (that's calling |
My local results:
Note I wasn't able to test it on the same infra as TE (for reasons I have to investigate). Conclusion is that
I'd say we go with this PR for now, and you can update the Npgsql version or we do it in a separate one. |
b4c23df
to
13ac7aa
Compare
Thanks for measuring the Npgsql side, this is really odd. In a couple months I will start getting more free and will try to investigate why explicit |
@roji I just want to insist on the fact that this table has |
Oh, ok... Is it possible to do a run with explicit Yeah, |
@sebastienros Looks like your benchmark suite is much more accurate than my local Docker results. Here's what I got from comparing the before and after runs:
One interesting thing is comparing I don't understand the "Update" benchmarks at all (but we've discussed that separately). |
* Update .NET MySQL benchmarks to latest MySqlConnector version. * Update optimized connection string settings for MySqlConnector. * Use prepared commands with MySqlConnector. * Update npgsql to latest version.
@patricka2 please only comment on old PRs if the comment is about the PR. In this case you could just create a new issue and we'd talk on it. You can delete the other duplicated comments as I answered already. |