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

feat: add idle channel #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yangchnet
Copy link

@yangchnet yangchnet commented Jun 25, 2021

增加了空闲信号channel,Put方法执行时检查是否存在空闲worker,若存在空闲worker,则不再创建新的worker。

benchmark数据如下:

优化前:BenchmarkPut-4   	  815876	      1460 ns/op	       0 B/op	       0 allocs/op
优化后:BenchmarkPut-4   	  948046	      1323 ns/op	       0 B/op	       0 allocs/op

优化前: BenchmarkPutTimelife-4   	 1000000	      1287 ns/op	       0 B/op	       0 allocs/op
优化后: BenchmarkPutTimelife-4   	  930015	      1356 ns/op	       0 B/op	       0 allocs/op

优化前: BenchmarkPoolPutSetTimes-4   	       1	1433118500 ns/op	   12104 B/op	      52 allocs/op
优化后: BenchmarkPoolPutSetTimes-4   	       1	1474117300 ns/op	    8504 B/op	      42 allocs/op

优化前: BenchmarkPoolTimeLifeSetTimes-4   	       1	1277515600 ns/op	   10208 B/op	      47 allocs/op
优化后: BenchmarkPoolTimeLifeSetTimes-4   	       1	1279696300 ns/op	    7928 B/op	      39 allocs/op

耗时与内存分配均有些许下降。

Signed-off-by: yangchnet 1048887414@qq.com

@yangchnet yangchnet marked this pull request as draft June 25, 2021 10:50
@yangchnet yangchnet marked this pull request as ready for review June 25, 2021 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant