Repository navigation
Add ASP.NET Core RAW MySQL test - #6566
Conversation
025e77c to
a5e3c6b
Compare
|
@roji The UPDATE statement counter for PostgreSQL seems flaky (as it seems to be for MySQL without the margin that was added to it in the past). Also fails from time to time in my local TFB verification runs. Is that a known issue? Made the checks failing here. This PR should not have had any impact on the Npgsql/PostgreSQL tests at all. |
|
It is not, it is the RAW update test that failed. So the following is still valid: @roji The UPDATE statement counter for PostgreSQL seems flaky (as it seems to be for MySQL without the margin that was added to it in the past). Also fails from time to time in my local TFB verification runs. Is that a known issue? |
|
For the platform benchmarks, one of the goals is to get rid of the virtual dispatches involved in using the System.Data abstraction (DbConnection, DbCommand) so this PR would slow that down a bit (this also introduces boxing by switching to DbParameter, so no more use of the Npgsql-specific generic I don't really know anything about any UPDATE statement counter - are you referring to a TechEmpower mechanism for verifying how many actual updates were performed on the database side? If so, would that be flaky for all TechEmpower tests, regardless of .NET? |
Yeah, I expected a slight drop for the Npgsql run due to the couple of statements added. So if the platform benchmarks are meant as the fastest possible execution, and the usual benchmarks are meant as a typical scenario, it makes sense for MySQL and MariaDB to duplicate the code and use the MySqlConnector classes directly, instead of the common abstractions. So I will change that.
I am just talking about the instrumentation code in the It is the one, that can return fewer update statements as expected for Postgres, MySQL and MariaDB under high load, and what I am talking about in #6568 (comment) and #6568 (comment). I suspect the database server implementation for incrementing this counter to be inaccurate in high concurrency scenarios. |
|
Thanks for the clarification - I admit I'm not familiar with that aspect of the TE infrastructure. So this would be a global TE problem as opposed to something specific to .NET right? |
I suspect this to be a database server implementation bug, that counts incorrectly in high concurrency situations, and not a .NET specific or TE specific issue. It could still be a TE specific issues, if some databases like Postgres or MySQL might update their update statements counters in a delayed fashion. Then, TE would need to accommodate for that (e.g. query the counter again after some time, if it is less than the expected count the first time). To be a .NET specific issue, it would need to be some very weird async related concurrency issue on the ADO.NET layer, which I think is unlikely, or an even weirder general async related issue (highly unlikely). |
@roji I updated the PR in a way, that abtracts with as little impact as possible, by introducing an Otherwise, we would already need to differentiate between database providers within the endpoint URI, and we would need to measure, whether parsing additional characters in the endpoint string is slower or faster than the vtable call. |
b007f76 to
c76815c
Compare
|
Once someone approves the workflow run (the most recent one is enough, older ones can be skipped/cancelled), this PR can be squashed & merged. |
FYI, the "Raw" MySQL benchmark existed for quite some time until it was deleted (without warning or notice) here: 77fd805#r41825500 Thanks for restoring it! (I do see there's still an |
roji
left a comment
There was a problem hiding this comment.
@lauxjpn @bgrainger I think the point of the platform benchmark was a stripped-down, ultra-high-speed benchmark showing the maximum that .NET can get to; this is why it is Npgsql-only - this happens to be the setup that's fastest. The point wasn't to do an extensible benchmark across databases and technologies, but to squeeze every bit of perf out for .NET as a platform.
So I'm not sure there's a lot of value of adding a MySQL implementation of the platform benchmark - the regular database benchmarks should provide a good place for measuring different databases etc. I'm not saying it shouldn't be done and that this change will slow things down - although I have been seeing virtual calls slowing down perf slightly in some scenarios.
What do you think?
@roji I don't see how we can know that it is the fastest, if we don't compare its benchmark to other implementations.
I think the platform test for MySQL makes a lot of sense, as it demonstrates the contrast between what is achievable and what is typical. When looking at the locally run benchmarks referenced in PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#1408 (comment), it can be seen that the middleware benchmark has only 90% of the performance of the raw benchmark, but it is a much smaller gap than between the PostgreSQL raw and middleware benchmarks.
I expect, that for the worst case, which is that the vtable is not cached at the moment the call needs to be made, the virtual call results in an additional memory read operation. For some reason, the generated IL contains a In general however, if a vtable call does matter, than the current implementation is likely to loose a lot of time with its endpoints calling other methods in the first place (and even multiple times). In which case, all those method calls should either be inlined by the compiler (unless they already are by a command line switch or something) or manually by flattening the call tree in the code.
@bgrainger As far as I can see, the We could duplicate the endpoints or just manually branch between database implementations within them, if the vtable call turns out to be significant. But branching would still require a read operation in its worst case scenario, so there should be no benefit over a vtable call. Deciding with the endpoint URI would need to be measured, as additional characters would need to be parsed. Since we have now worked out the potential expectations and concerns, I think its much easier to just run the benchmark on Citrine, and see what the results are. We can always revert the PR or optimize it after the run, when we know what is what. |
One way is to do a one-off comparison, rather than merging a permanent change. I'll just say that I noticed virtual dispatch making a different recently in another benchmark, and as this specific benchmark pretty much represents .NET on the global scale of these benchmark, I'd be wary of making changes here. Once again, the question is exactly what this is meant to achieve; if the point is to get a number at a point in time, I'll gladly help you by running any benchmarks on the ASP.NET platform (https://github.com/aspnet/Benchmarks/) - that's a great place to do any experimentation without affecting .NET's place in the rankings etc. |
Sounds good to me. How is this process being done on Citrine?
I am not. That is what benchmarks are for. We should just measure it. If its significant, we can just revert it, or optimize something else along the hot path, that compensates for it. We should be still far off from the next official Round.
The point is to demonstrate what is possible with a minimalist approach on ASP.NET using MySQL without any approaches like MW or MVC in its way. It is of interest to anyone who needs to squeeze everything out of the platform and database they are using, which is pretty much in line with what TFB measures in general (concurrent web access). It is the extreme ASP.NET with MySQL usage.
We can run the benchmarks there first and measure them if you think this is really necessary. If I remember correctly, they use the same hardware etc. as the TFB machines. (I did asked about the ASP.NET platform benchmarks a couple of days ago, but the general vibe seemed to be, that they are MySQL unrelated, at least at this point in time.) Now, what I am interested in is: What are your actual concerns about testing this PR on Cetrine in one of its ongoing runs? |
I guess I'm not too used to the approach of trying out and reverting things in the official TechEmpower benchmark repo. This creates a lot of churn, result history is going to be messy and difficult to interpret, you're asking for TE people's time to review and merge, and there's a chance we'd accidentally forget and leave something in that regresses performance (not that I mistrust you specifically - I mistrust myself after a long and painful experience with perf experimentation), etc. To summarize, I see this repo as a production repo, where stability is important, and not as a playground for experiments. But I do definitely agree that you need a way to do perf experiments, and ideally on TE hardware. We should see what we can do to help you do stuff on the aspnet, but I guess until then I don't have a better solution. |
|
The unreachable MySQL server (in general, not just for the platform tests), which made the PR fail, should not be related to anything of this PR (as it hasn't touched a single file that influences the MySQL server in any way, and only changed platform related files in general). |
|
@lauxjpn I just discussed with @sebastienros, and I can run jobs for you on our platform if you want. You can do your tweaks in your fork of the TE repo, and then I can send a job on our platform against that fork. For example, the config for the TE benchmarks on the ASP.NET is https://github.com/aspnet/Benchmarks/blob/main/scenarios/te.benchmarks.yml - you can have your own Docker of MySQL too. How does sound? That should hopefully provide you reactive experience (after all, we're in the same timezone 🤣), and at the same time keep this repo cleaner from experimentation etc... |
Because I am wondering how non ASP.NET related projects are doing this, who cannot afford the luxury of having a duplicated setup of the TFB hardware available for internal testing, before being absolutely sure, that a change will indeed not negatively alter all possible related benchmarks. Because if you cannot test it on TFBs hardware, you can only guess, which is bad when it comes to optimizing complex systems. (I had a second paragraph here, but I decided to not post it.)
Can this even be achieved on Citrine? I was under the impression (but might remember this incorrectly) that there is only a five-minute gap between ongoing rounds (probably for restarting or resetting).
If this cannot be tested on Citrine and therefore has to be tested using the ASP.NET Core benchmark repo to get this merged at some point into TFB, so be it. (I had a second paragraph here, but I decided to not post it.) |
If that's the purpose, I can understand leaving a MySQL implementation off (because it complicates the code paths and we can be pretty certain from all TFB entrants that a MySQL-based solution is never going to be as fast as PG). I'm happy to put effort into improving
Is the best way to open an issue? I have one! aspnet/Benchmarks#1676 |
@roji Thanks, that works for me! |
I think we are kind of moving in circles around this one. If this introduces overhead, the benchmark will tell us, in which case, I am obviously changing the PR to use a conditional. Otherwise, there should be no need, since if the JIT deoptimizes this particular case in the future (for whatever reason), this benchmark would show it. So its a good thing. Therefore, lets really first run the benchmark, and then draw final conclusions here. It is likely to perform worse, but we don't know until we test it. At this point, the new debate whether this benchmark should even be run on the ASP.NET Citrine hardware, has likely taken more time than just running it. Your solution for us, to work around the apparently very tight coupling of the ASP.NET and EF Core teams to even the in-between benchmark runs of the TFB, was to let us run more experiment type PRs on the ASP.NET Citrine hardware. I think it is good solution. |
|
@lauxjpn we're indeed moving around in circles - I've already written my opinion here, several times. Regardless of what the benchmark runs will show, I am against this change, so I don't see the point of running it. |
|
Alright, if that's how it is, then that's how it is. Though the solution you offered to open source contributions lost a lot of their sexiness with this. (BTW, locally run vtable call/direct call benchmarks showed, that the vtable call (0.8398 ns) is about twice as costly as the direct call (0.4182 ns). For 400,000 RPS, it should have resulted in an additional overhead of 168.640 ns in total, so a drop of about 67 RPS, resulting in 399,933 RPS instead of 400,000 on average, assuming TFB runs a consumer grade processor like mine. Just to provide some perspective to others on what we were initially talking about.) Anyway, then let's at least get the process down, so it is clear what the rules are and when they apply.
What is not clear so far is, to what contributions these rules apply (the scope):
Once this has been defined, I think it needs to be part of some official issue here, so it is clear what the rules and processes are for open source contributions (at least in regards to ASP.NET Core benchmarks) and they can be looked-up at any time. (Because discovering and extracting all this piece by pieces has been a very slow and time consuming process so far.) |
@lauxjpn maybe the source of the confusion is this... You are free to create your own benchmark implementations and submit them to TechEmpower (cloning the existing ASP.NET ones, or otherwise). Various people have done that (see ben, beetlex) and run experiments in their own corner, without affecting the official .NET ones. You wouldn't need anyone's permission for that, and you could iterate as much as you want directly with the TechEmpower folks (like in other frameworks). What you're asking in this PR is to introduce your changes into the "official" .NET platform benchmark - the most high-perf one, where we already go to extreme lengths to avoid any extra processing that isn't needed. I'd rather we avoided that on principle; an extra virtual call that doesn't appear on a benchmark run today could become important at some future point, if other things are optimized by then. And no, I prefer not to wait to see that virtual call in a profiler, at that point - I'd rather we just kept the platform benchmark minimal, on principle. I think the "rules and processes" here are really very simple:
I really hope the above explains things clearly, and makes sense. I'm available to answer any further question on this. |
Thanks, that is what was missing from the picture. I will ping you for related PRs then and wait until they get approved.
Yes, it's clear now and fine. I was asking about it, so issues don't get blocked unnecessarily by waiting for approval in cases where no approval is needed.
I know. I just though since we talked in length about the potential impact and you offered to run it earlier on the ASP.NET Core Citrine hardware (before you later changed your mind), it would have been interesting to actually measure the impact, so informed decisions can be made based of those findings in the future for Citrine. I would have been completely fine with a compromise like: "Let's run it, so we know what the impact of a virtual method call is on Citrine, even though the outcome will not change our position on not making it part of the official repo, because we think it's overall too risky." Anyhow, I will implement a preprocessor condition based approach. |
|
@roji Alright, take a look at it and give it a spin if you like. |
This reverts commit 6b048be
f044298 to
d586fde
Compare
|
Since this hasn't been merged yet, I added a commit with a very minor project file cleanup/simplification. |
|
Sorry @lauxjpn, I've been deep into something - will definitely get around to this today or tomorrow. |
Clarify exception message.
|
LGTM Have you found optimal connection string arguments? There is a default pool size of 1024, isn't it impacting perf since it will never reach this amount? |
roji
left a comment
There was a problem hiding this comment.
Finally got around to this... Thanks, this looks good to me too!
@sebastienros I have started some local perf checks in regards to connection string parameter and config values a couple of weeks ago. I will ping @roji from time to time over the next few weeks, to test some changes on the ASP.NET Core Citrine, so we can get this optimized before the next official run. But I agree, with a maximum of 512 concurrent web request calls, a maximum of 1024 pooled connections seems excessive. I just copied the connection string over form |
|
Yeah, we can definitely tweak this in future PRs if we need to. |
The failing CI seems to be some non-deterministic MySQL server setup issue (we had this randomly in other PRs as well). Does it need to be triggered again until it succeeds, or can it be merged anyway? |
Looks like I found the root cause for this. As expected, it is unrelated to this issue here. |
|
Okay, looks like #6611 did the trick. @nbrady-techempower This PR can be squashed & merged now. |
Adds support for an ASP.NET Core MySQL RAW benchmark, that was already partially setup.