-
Notifications
You must be signed in to change notification settings - Fork 91
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
Open
i4ki
wants to merge
6
commits into
main
Choose a base branch
from
i4k-optimize-tm-alltrue
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
i4ki
force-pushed
the
i4k-optimize-tm-alltrue
branch
from
December 6, 2023 00:33
fd2a9b0
to
46848f3
Compare
Signed-off-by: Tiago Natel <[email protected]>
i4ki
force-pushed
the
i4k-optimize-tm-alltrue
branch
from
December 6, 2023 17:57
46848f3
to
a819810
Compare
✅ Deploy Preview for docs-terramate-io canceled.
|
wmalik
approved these changes
Dec 7, 2023
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
|
zied-elouaer
previously approved these changes
Oct 24, 2024
snakster
previously approved these changes
Oct 24, 2024
i4ki
dismissed stale reviews from snakster and zied-elouaer
October 24, 2024 12:20
The base branch was changed.
soerenmartius
approved these changes
Oct 24, 2024
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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