-
-
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
Issue with "run one iteration for long operations", it's flaky and considers many nano-operations as "long", leading to one op per cycle #1338
Comments
@adamsitnik, this issue keeps popping up, could we have a look at this? The calculation for skipping the iterations seems (very) off. Another case with just C# code was here: #1505, see my comment there. |
@adamsitnik, here's another case, this time encountered by @cartermp, see this comment for detailed output: dotnet/fsharp#9218 (comment) Here, settings are default, and should lead to some 70 ops per run, but this doesn't happen. |
Thanks for filing and noticing @abelbraaksma - in my benchmark I couldn't find a good |
@adamsitnik Hello? Not even a response? |
A weird workaround is to place a long-running benchmark (>=100ms) as the first benchmark and place microbenchmarks after. |
Please excuse me for the delay. I've sent a fix: #1573 |
@adamsitnik, great! That's awesome, I'll give it a try after the weekend 👍. |
…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)
This PR: #760, introduced a bug that proved to be notoriously hard to diagnose.
The issue at hand seems to be that the metric used to determine whether something should run once or go through the pilot phase, is flaky. In fact, it appears that the JIT time is taken into account.
In short: if one invocation is ~7ns (this example) and the
IterationTime
is set to 120ms, the change in #760 assumes that it can skip the pilot phase and sets invocation and unroll to1
.I think JIT'ing is skewing the metric, because once you change
sprintf "test %A" "test"
tosprintf "test %s" "test"
, the problem goes away (and the difference is the JIT time). It also goes away when givingfoo
a body withsprintf "test %A" "test"
. I don't know why.Proposal
@adamsitnik, I can see a few ways forward:
Add a line in the output why the pilot phase is skipped. I spend two days searching for a cause, it is very puzzling if one irrelevant change in your own code leads to attributes being ignored
Improve the metric. Hopefully the two examples here and in Trivial methods can cause BDN to run only 1 iteration, skip pilot phase, and ignore most attributes #1337 will help analyzing the cause
Perhaps simplest of all: add an attribute, like
ForcePilotPhase
to override behavior of don't execute long operations more than once per iteration #760, or allowUnrollFactor
as an attribute, which would also override it, if I understand the PR correctly.Minimal working example
Here's an example:
Output
The output shows that the pilot stage is skipped. However, the iteration time was set to 120ms, and there isn't any metric in the output below that tops that.
Once I change the
IterationTime
to 150ms, I get the expected output:The text was updated successfully, but these errors were encountered: