-
Notifications
You must be signed in to change notification settings - Fork 720
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
Optimize heartbeat - async process statistics #7898
Conversation
Skipping CI for Draft Pull Request. |
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
193c2b5
to
b3c59b1
Compare
b3c59b1
to
e334d81
Compare
0ef7f0d
to
25e0c99
Compare
Signed-off-by: nolouch <[email protected]>
25e0c99
to
ac40311
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #7898 +/- ##
==========================================
+ Coverage 73.47% 73.58% +0.11%
==========================================
Files 436 437 +1
Lines 48349 48642 +293
==========================================
+ Hits 35523 35793 +270
- Misses 9765 9787 +22
- Partials 3061 3062 +1
Flags with carried forward coverage won't be shown. Click here to find out more. |
if opt.Limit != nil { | ||
token, err = opt.Limit.Acquire(ctx) | ||
} |
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.
if opt.Limit != nil { | |
token, err = opt.Limit.Acquire(ctx) | |
} | |
token, err = opt.Limit.Acquire(ctx) |
runner.RunTask( | ||
ctx, | ||
ratelimit.TaskOpts{ | ||
TaskName: "UpdateSubTree", |
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.
Should we put all the tasknames into a constant list?
|
||
func (s *AsyncRunner) recover() { | ||
if r := recover(); r != nil { | ||
log.Error("panic in runner", zap.Any("error", r)) |
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.
Should we add more information? such as task name.
return overlaps, nil | ||
} | ||
|
||
// CheckAndPutSupTree checks if the region is valid to put to the root, if valid then return error. | ||
// Usually used with CheckAndPutSubTree together. | ||
func (r *RegionsInfo) CheckAndPutSupTree(ctx context.Context, region *RegionInfo) ([]*RegionInfo, error) { |
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.
func (r *RegionsInfo) CheckAndPutSupTree(ctx context.Context, region *RegionInfo) ([]*RegionInfo, error) { | |
func (r *RegionsInfo) CheckAndPutSubTree(ctx context.Context, region *RegionInfo) ([]*RegionInfo, error) { |
l.mu.RLock() | ||
defer l.mu.RUnlock() | ||
func (l *ConcurrencyLimiter) getCurrent() uint64 { | ||
l.mu.Lock() |
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 change it?
|
||
// GetWaitingTasksNum returns the number of waiting tasks. | ||
func (l *ConcurrencyLimiter) GetWaitingTasksNum() uint64 { | ||
l.mu.Lock() |
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.
rlock?
@@ -0,0 +1,114 @@ | |||
// Copyright 2022 TiKV Project Authors. |
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.
// Copyright 2022 TiKV Project Authors. | |
// Copyright 2024 TiKV Project Authors. |
if opt.Limit != nil && atomic.LoadInt64(&s.numTasks) >= int64(s.maxPendingTasks) { | ||
return ErrMaxWaitingTasksExceeded | ||
} | ||
s.addTask(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.
Will it keep adding without executing the defer?
will split this pr, close. |
What problem does this PR solve?
Issue Number: Ref #7897
What is changed and how does it work?
Check List
Tests
Before:
After:
The duration of the pending state on tikvs has been reduced from 10 minutes to 3 minutes
Release note