-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
perf: reduces transformArg allocation without multimatch #1198
Conversation
@@ -242,8 +242,17 @@ func (r *Rule) doEvaluate(logger debuglog.Logger, phase types.RulePhase, tx *Tra | |||
} | |||
vLog.Debug().Msg("Expanding arguments for rule") | |||
|
|||
args := make([]string, 1) |
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.
it seems worth removing this allocation as well I guess?
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.
Yes, I have some a WIP with further refactoring, but so far I've not been able to achieve more performance / fewer allocations, even removing this line. I would merge this first to get some optimizations in and iterate over for further ones
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.
i see, nice try anyways!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1198 +/- ##
==========================================
+ Coverage 81.63% 81.64% +0.01%
==========================================
Files 168 168
Lines 9630 9637 +7
==========================================
+ Hits 7861 7868 +7
Misses 1519 1519
Partials 250 250
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Avoids allocations when calling
transformArg()
withoutMultimatch
. This has been done by specializing thetransformArg
into:transformArg(..)
: which returns just an individual string with all the transformations computed. It permits to avoid allocating slices with just one element.transformMultiMatchArg
: which returns a slice of strings that include all the unique intermediate transformationsBefore:
After: