Skip to content
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

do gc parallel #5832

Closed
wants to merge 1 commit into from
Closed

do gc parallel #5832

wants to merge 1 commit into from

Conversation

wentaoxu
Copy link
Contributor

@wentaoxu wentaoxu commented Feb 8, 2018

as title says

@wentaoxu
Copy link
Contributor Author

wentaoxu commented Feb 8, 2018

@zhangjinpeng87
Copy link
Contributor

Any test?

err error
}

func getNextGCTask(store tikv.Storage, bo *tikv.Backoffer, safePoint uint64, lastKey kv.Key) (*gcTask, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/getNextGCTask/genNextGCTask

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


log.Infof("[gc worker] %s start gc, safePoint: %v.", identifier, safePoint)
startTime := time.Now()
func doGCForOneRange(ctx goctx.Context, store tikv.Storage, task *gcTask, identifier string) *gcResult {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems you should use a range as the input args from the function name.

}
}

func doGCTask(ctx goctx.Context, store tikv.Storage, identifier string, resChan chan *gcResult, task *gcTask) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should wait on a task queue and handle task one by one util receive nil.

}()

var key []byte
gcResultChan := make(chan *gcResult, gcDefaultGCConcurrency)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcTaskQueue := make(chan gcTask, gcDefaultGCConcurrency)
gcTaskCh := make(chan gcTask, 1024)
for i = 0; i < gcDefaultGCConcurrency; i++ {
go runGcTaskWorker(gcTaskQueue, gcResultCh)
}
var key []byte
for {
task, err := genNextGCTask(...)
if err != nil {...}
if task == nil {
send N nil to gcTaskQueue, notify all workers to quit
break;
}
gcTaskQueue <- task

...receive task results if have
}
reveive task results util N nil

@ngaut
Copy link
Member

ngaut commented Feb 11, 2018

Duplicate with #5850

@ngaut ngaut closed this Feb 11, 2018
@sre-bot sre-bot added the contribution This PR is from a community contributor. label Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution This PR is from a community contributor.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants