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
executor: add cache for approximate table count #44979
Conversation
c3c9255
to
230e027
Compare
// GetApproximateTableCountFromStorage gets the approximate count of the table. | ||
func (p *PDHelper) GetApproximateTableCountFromStorage(sctx sessionctx.Context, tid int64, dbName, tableName, partitionName string) (float64, bool) { | ||
key := approximateTableCountKey(tid, dbName, tableName, partitionName) | ||
if item := p.cacheForApproximateTableCountFromStorage.Get(key); item != nil { |
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.
GetApproximateTableCountFromStorage
is the same as the old. but we add cache here.
/retest |
1 similar comment
/retest |
tidb-server/main.go
Outdated
@@ -760,6 +761,7 @@ func setGlobalVars() { | |||
} else { | |||
executor.GlobalMemoryUsageTracker.SetBytesLimit(int64(cfg.Performance.ServerMemoryQuota)) | |||
} | |||
executor.Start() |
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 do we put this in setGlobalVars
?
Seems a bit confusing.
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 hope it is globally unique.
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 not in main()?
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.
+1. My main points are:
- Currently, we only set up global states, i.e. setting global variables in
setGlobalVars
. Butexecutor.Start()
starts a background goroutine, which is quite different. - If we call
executor.Start()
here andexecutor.Stop()
inmain()
, they won't pair up and will make the code a bit confusing.
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.
Done
@@ -183,6 +184,16 @@ func init() { | |||
CheckTableFastBucketSize.Store(1024) | |||
} | |||
|
|||
// Start the backend components |
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 suggest add some comments since we are introducing the "backend components" new concept to this package.
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.
Done
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.
There's no ut in this PR, please do functional testing for this cache.
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chrysan, time-and-fate 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 |
[LGTM Timeline notifier]Timeline:
|
What problem does this PR solve?
Issue Number: close #44978
Problem Summary:
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.