-
Notifications
You must be signed in to change notification settings - Fork 54
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
Excessive time spent in ast.(*parser).parseExpr #78
Comments
A quick look at where the OPA eval happens (I think? Correct me if I'm wrong on this): https://github.com/forseti-security/config-validator/blob/258b9eb9e8e6d6e91da8edbcab771d19ece3fad8/pkg/gcv/cf/cf.go#L214-L222 it appears that the query is passed in as a string for each evaluation. If the actual eval is fast it wouldn't be super surprising to see that a large chunk of time is spent parsing the query on each of the benchmark loop iterations. I see the More recently in OPA we have added a set of new API's on the Again, just from a quick look. I might have totally missed some other spot that is doing additional parsing. |
@maxsmythe, as discussed, to parse the query ahead of time you'd use https://godoc.org/github.com/open-policy-agent/opa/ast#ParseBody and then use this option to pass in the parsed query https://godoc.org/github.com/open-policy-agent/opa/rego#ParsedQuery |
I wrote a FCV benchmark test and profiled it using
go test -cpuprofile cpu.prof -bench BenchmarkReviewJSON -benchtime 60s ./pkg/gcv
and it looks like it's spending quite a bit of time in the opa AST parser. This seems odd since the rego is only added during benchmark setup.The text was updated successfully, but these errors were encountered: