-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Even less allocs #7190
Even less allocs #7190
Conversation
**main** ``` BenchmarkLintAllEnabled-10 1 2640715625 ns/op 6385110200 B/op 116296633 allocs/op ``` **pr** ``` BenchmarkLintAllEnabled-10 1 2597179708 ns/op 6183614112 B/op 108421141 allocs/op ``` (I renamed the benchmark, but this is the same as "regal linting itself" used in the past) Another 8 million allocations cut off from `regal lint bundle`, and a whopping 10% improvements to wall clock time! The most significant improvement is the Equal implementation for refs, since that is called all over the place. But there are many other fixes here, and they all contribute something substantial (and fixes that only have had marginal impact have been left out). Signed-off-by: Anders Eknert <anders@styra.com>
✅ Deploy Preview for openpolicyagent ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -403,7 +406,8 @@ func (e *eval) evalStep(iter evalIterator) error { | |||
}) | |||
} | |||
case *ast.Term: | |||
rterm := e.generateVar(fmt.Sprintf("term_%d_%d", e.queryID, e.index)) | |||
// generateVar inlined here to avoid extra allocations in hot path | |||
rterm := ast.VarTerm(fmt.Sprintf("%s_term_%d_%d", e.genvarprefix, e.queryID, e.index)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that the compiler couldn't inline that itself 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it was possible for the compiler to inline, but it’s a little more elaborate, as our manual inlining also reduces 2 sprintf calls to one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just curious about the compiler not being able to inline generateVar itself; it looks simple enough...
main
pr
(I renamed the benchmark, but this is the same as "regal linting itself" used in the past)
Another 8 million allocations cut off from
regal lint bundle
, and a whopping 10% improvements to wall clock time!The most significant improvement is the Equal implementation for refs, since that is called all over the place. But there are many other fixes here, and they all contribute something substantial (and fixes that only have had marginal impact have been left out).