-
Notifications
You must be signed in to change notification settings - Fork 96
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
chore(perf): optimise tm_alltrue() and tm_anytrue(). #1282
base: main
Are you sure you want to change the base?
Conversation
|
fd2a9b0
to
46848f3
Compare
Signed-off-by: Tiago Natel <[email protected]>
46848f3
to
a819810
Compare
✅ Deploy Preview for docs-terramate-io canceled.
|
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.
Nice one!
really well done @i4ki |
…mate into i4k-optimize-tm-alltrue
…mate into i4k-optimize-tm-alltrue
Signed-off-by: i4k <[email protected]>
|
Preview of ubuntu-focal/go1.21 tests in cf4a062🔍 View Details on Terramate Cloud globals
stdlib
|
… i4k-optimize-tm-alltrue
Preview of macos-ventura/go1.21 tests in cf4a062🔍 View Details on Terramate Cloud globals
stdlib
|
The base branch was changed.
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
@i4ki can this be merged? |
The last consensus was that the behavior change was desirable. I will revamp this PR and make it r4r again. |
What this PR does / why we need it:
PROPOSAL: This PR optimises
tm_alltrue()
andtm_anytrue
but introduces a non-breaking behavior change that could be undesirable, so it requires discussion.It optimises the
tm_alltrue()
andtm_anytrue()
by lazy evaluating the function's arguments using thecustomdecode.ExpressionClosureType
and then only evaluating the needed argument elements as below:For
tm_alltrue()
the function returns as soon as afalse
element is found.For
tm_anytrue()
the function returns as soon as atrue
element is found.Benchmark results:
The
TmAllTrueLiteralList*
benchmark tests the case where expensive expressions are provided in the function arguments, then the expensive part is not evaluated, that's why the huge performance win.Which issue(s) this PR fixes:
Special notes for your reviewer:
This implementation does not match 100% the original, see below:
Does this PR introduce a user-facing change?
Checklist