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

util/goroutine_pool: add a goroutine pool package utilities #3752

Merged
merged 10 commits into from Sep 12, 2017

Conversation

Projects
None yet
5 participants
@tiancaiamao
Contributor

tiancaiamao commented Jul 13, 2017

Reuse goroutine in a pool can avoid runtime.morestack. It may be useful sometimes.

BenchmarkGoPool-4          	 5000000	       392 ns/op
BenchmarkGo-4              	10000000	       161 ns/op
BenchmarkMorestackPool-4   	 2000000	       706 ns/op
BenchmarkMoreStack-4       	  500000	      3018 ns/op
@shenli

Please test this with sysbench.

Show outdated Hide outdated util/goroutine_pool/gp.go
Show outdated Hide outdated util/goroutine_pool/gp_test.go
@tiancaiamao

This comment has been minimized.

Show comment
Hide comment
@tiancaiamao

tiancaiamao Jul 18, 2017

Contributor

I've test in another branch, using pool mechanism can totally eliminate runtime.morestack.
PTAL @shenli @ngaut @winkyao

Contributor

tiancaiamao commented Jul 18, 2017

I've test in another branch, using pool mechanism can totally eliminate runtime.morestack.
PTAL @shenli @ngaut @winkyao

@zimulala zimulala added the status/DNM label Jul 19, 2017

Show outdated Hide outdated util/goroutine_pool/gp.go
Show outdated Hide outdated util/goroutine_pool/gp.go
Show outdated Hide outdated util/goroutine_pool/gp.go
Show outdated Hide outdated util/goroutine_pool/gp.go
ret := head.next
head.next = ret.next
if ret == pool.tail {

This comment has been minimized.

@coocood

coocood Sep 9, 2017

Member
pool.count--
if pool.count == 0 {
  pool.tail = head
}

is easier to read.

@coocood

coocood Sep 9, 2017

Member
pool.count--
if pool.count == 0 {
  pool.tail = head
}

is easier to read.

This comment has been minimized.

@tiancaiamao

tiancaiamao Sep 9, 2017

Contributor

I didn't intent to maintain count, it's added later just for testing purpose.

@tiancaiamao

tiancaiamao Sep 9, 2017

Contributor

I didn't intent to maintain count, it's added later just for testing purpose.

tiancaiamao added some commits Sep 9, 2017

@coocood

This comment has been minimized.

Show comment
Hide comment
@coocood

coocood Sep 9, 2017

Member

LGTM

Member

coocood commented Sep 9, 2017

LGTM

@winkyao

LGTM

@coocood coocood added status/LGT2 and removed status/DNM labels Sep 12, 2017

@tiancaiamao tiancaiamao merged commit 3245d49 into master Sep 12, 2017

4 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@tiancaiamao tiancaiamao deleted the tiancaiamao/goroutine-pool branch Sep 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment