-
Notifications
You must be signed in to change notification settings - Fork 294
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
evaluator: performance regression on 0.6.0 #2559
Comments
0554d4e is a bit slower but no as bad as 97d7109
when using export all of them are fast
|
We are currently focusing on v0.7, whose main goal is performance improvements. Marcel already has some big changes coming up in that direction, so I'm inclined to let them hit master first and then see where we stand with your benchmark. |
Sure, let me know if there is any early dev branch to test. Im willing to help. |
I know that 0.7.0 has no performance improvements, but just to keep you updated, here is a performance test on the current 0.7.0-rc.1 tag:
|
I'm looking at this again after @mxey provided some more information on Slack and also started helping with the debugging. Thank you again @MarcWort for the information above, and apologies that I hadn't had the time to come back to this before. Starting from your helpful example at https://github.com/MarcWort/example-cue, I've been able to build a worst case scenario reproducer:
With CUE as of master (3f84ba6) this takes about 7s:
@mxey looked at https://review.gerrithub.io/c/cue-lang/cue/+/556460 and https://review.gerrithub.io/c/cue-lang/cue/+/557477 and suggested this surgical fix that seems to not cause any test failures and seems to speed up your command quite a lot: diff --git tools/flow/tasks.go tools/flow/tasks.go
index 019a218f..cf684da5 100644
--- tools/flow/tasks.go
+++ tools/flow/tasks.go
@@ -257,7 +257,7 @@ func (c *Controller) markTaskDependencies(t *Task, n *adt.Vertex) {
return nil
}
c.nodes[d.Node] = cycleMarker
- d.Recurse()
+ c.markTaskDependencies(t, d.Node)
c.nodes[d.Node] = nil
}
return nil And it indeed helps with my reproducer massively, by a factor of nearly 100x:
I still can't really tell why there is such a big performance difference between the two very similar versions of the code. Funnily enough, my reproducer causes a stack overflow with CUE v0.5.0, so I can't really validate whether this is the same regression that you saw with v0.6.0. |
I should note that the reproducer above is akin to a worst case benchmark for the current code, so we can't really use it as a regression test, but we could still add it to the test suite and trust that, if we were to cause a similar slow-down in the future, we would notice by virtue of |
Tentative fix with test at https://review.gerrithub.io/c/cue-lang/cue/+/1198566; I will need to talk through it with Marcel to verify it's sane. |
The method calls markTaskDependencies, which in some cases like the addded test would mean more evaluator work, but those counters were not being added to the task's stats. The added test would fail before the fix: stats: task totals different from controller: [...] task totals - controller totals: Leaks: -1 Freed: -5 Reused: -3 Allocs: -3 Retain: -5 Unifications: -6 Conjuncts: -5 Disjuncts: -9 For #2559. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I0e7e441b27a3cebad2669fe729cf5805eee019f7 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198616 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
The added CUE takes 7s to test with tools/flow or run with `cue cmd`, as it's adapted from https://github.com/MarcWort/example-cue to show the worst case scenario of tools/flow being slow by nesting many references to non-task nodes which do some underlying work. Thanks to Marc W for providing the original reproducer on GitHub. For #2559. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I25543e7c22b1dda6a8a8528198d2d7b4a63bb411 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198565 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Roger Peppe <[email protected]>
Should be resolved now in master, as well as the upcoming alpha release. Thanks again! |
@mvdan is there any chance this fix might be cherry picked back into the 0.9 releases and result in a 0.9.3 release? |
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest stable release?
Yes also running on 0.6.0.
What did you do?
I noticed that when running cue 0.6.0 that it was approximately 10x slower on my rules.
Bisecting led me to commit 97d7109 where the performance regression started but only when using a "_tool.cue" file.
but not when directly using
cue export
You can reproduce my tests with my example repo: https://github.com/MarcWort/example-cue
What did you expect to see?
Not such a strong performance impact. My actual project now takes 4 minutes instead of 30secs. I tried some changes on the ruleset but havent found any particular section where the performance hit appears.
The text was updated successfully, but these errors were encountered: