-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
expression: refactor cache logic for builtinRegexpSubstrFuncSig
#49584
Conversation
83c572d
to
7e6ed39
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #49584 +/- ##
================================================
+ Coverage 71.0039% 71.5769% +0.5730%
================================================
Files 1368 1423 +55
Lines 399378 420521 +21143
================================================
+ Hits 283574 300996 +17422
- Misses 96012 100609 +4597
+ Partials 19792 18916 -876
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/retest |
7e6ed39
to
a3da958
Compare
/retest |
func (c *builtinFuncCache[T]) getOrInitCache(ctx EvalContext, constructCache func() (T, error)) (T, error) { | ||
intest.Assert(constructCache != nil) | ||
ctxID := ctx.GetSessionVars().StmtCtx.CtxID() | ||
if item, ok := c.getCache(ctxID); ok { |
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.
Why we double check the cache outside of the lock protection?
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.
To achieve a better performance, ensure a concurrent call of getOrInitCache
will not block each other.
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
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
@xzhangxian1008: adding LGTM is restricted to approvers and reviewers in OWNERS files. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: XuHuaiyu, xzhangxian1008, YangKeao The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What problem does this PR solve?
Issue Number: close #49583
Problem Summary:
See #49583 and #49464
What changed and how does it work?
CtxID
toStatementContext
to return a unique ID for statement context.builtinFuncCache
to provide a cache mechanism for built function. It uses context ID to separate cache between different statements so that we can still cache some immediate states even if plan cache is enabled now.regexpNewBaseFuncSig
as a new base for regex related functions. We'll useregexpNewBaseFuncSig
to replace the oldregexpBaseFuncSig
in the next several PRs.builtinRegexpSubstrFuncSig
to useregexpNewBaseFuncSig
to manage the cache, so that:*regexp.Regexp
when plan cache is on and regex pattern is read from a variableCheck List
Tests
We did a benchmark test and the performance of
regexp_substr
increased:Master:
This PR:
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.