-
-
Notifications
You must be signed in to change notification settings - Fork 978
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
Problems with default UnrollFactor in V0.11.0 #837
Comments
@Tornhoof, thank you very much for the report. You correctly described the problem: BenchmarkDotNet ignores the Pilot stage (where we should choose the best amount of invocation) because I think we should always run the Pilot stage if the jitting (cold start) took a reasonable amount of time (e.g., < 20 sec). It should automatically fix the invocation count and solve your problem. Currently, we compare the As a temporary workaround, you can manually set the invocation count or increase the IterationTime value. |
Thank you for the workaround. |
@Tornhoof big thanks for the bug report and a clear repro case! I will try to find some solution and fix it during the next weekend |
@adamsitnik do you have any progress with this issue? |
@AndreyAkinshin Great idea! So far I have observed that this issue happens only for benchmarks that rely heavily on |
In fact, there are too many factors that can slow down the first iteration (from heavy assembly loading to custom user logic). |
Totally agree! Would you like to implement it? |
Yes. |
Need to perform a warmup so the workload jitting doesn't take too long dotnet/BenchmarkDotNet#837
Hello, any update on this? I just ran into this issue (and given the list of mentions, I guess this is widespread). Any way I could help? |
Please excuse me for the delay. I've sent a fix: #1573 |
…n lasts longer than IterationTime (#1573) * add the test * if the Jitting took more than IterationTime but still less than 1s (a magic number based on observations of the reported bug) we call it one more time to see if Jitting itself has not dominated the first invocation if it did, it shoud NOT be a single invocation engine (fixes #837, fixes #1337 and fixes #1338)
* Update Cursively benchmark code. - VisitPartialFieldContents is required for correctness - Use the original byte array, since we have one, instead of forcing a stream around it - Set iteration time to 1 second, to work around dotnet/BenchmarkDotNet#837 while we wait for a version of this package that includes dotnet/BenchmarkDotNet#1573 * Change the order of this check Whether or not this is the optimal order is almost certain to depend on the data: data sets that would almost never use the pool would likely hurt more by doing it this way, especially if this were a real-world application since this would likely push a line out of the CPU cache for no reason. Then again, a real-world application probably wouldn't use the pool conditionally like this, so there's not much of a reason NOT to either.
I thought that I've solved this problem in #1573, but today I've run into this problem again when benchmarking PowerShell (PowerShell/PowerShell#15242) We should most probably implement the approach described by @AndreyAkinshin :
Having said that, I am going to reopen the issue. |
It was most probably fixed with #1949 |
Description
I just upgraded SpanJson to v0.11 of Benchmark.NET and the new UnrollFactor logic does not work for codegen-heavy benchmarks.
Actual Behaviour
The workloadActual lines then repeat around 90 times with quite a large variation in timings.
Expected behaviour
I get a larger amount of ops with a more consistent timing, the 1 op benchmark is wrong on a large large scale.
I think that's bececause the WorkloadJitting is taking that long (yeah it's codegen heavy), as soon as I change the Unrollfactor to 2 it works as expected (atleast as far as I've run the benchmarks).
The benchmark is that codegen heavy, because I initialize ~480 serializers statically in that class (the whole benchmark class is one large t4 script, see https://github.com/Tornhoof/SpanJson/blob/master/SpanJson.Benchmarks/ModelBenchmark.cs)
Repro
The text was updated successfully, but these errors were encountered: