panjf2000 / ants

🐜🐜🐜 ants is the most powerful and reliable pooling solution for Go.
https://ants.andypan.me/
MIT License
12.83k stars 1.36k forks source link

求问pool中running()方法返回的数字的含义 #229

Closed imDpeng closed 1 year ago

imDpeng commented 2 years ago

我的代码中有一个生产者,两个消费者。他们分属三个池子。 生产者。读文件,解析对象,根据业务逻辑分别提交给消费者1和消费者2。协程池大小=16. 消费者1。cpu计算。协程池大小=64 消费者2。GPU计算。协程池大小=64

使用如下方法监听协程池正在运行数量: go func() { for { time.Sleep(time.Duration(1000) * time.Millisecond) fmt.Println( "RealCallPool:" + strconv.Itoa(RealCallPool.Running()) + "-" + strconv.Itoa(RealCallPool.Waiting()) + "\tRd2PileupOnGpuPool:" + strconv.Itoa(Rd2PileupOnGpuPool.Running()) + "-" + strconv.Itoa(Rd2PileupOnGpuPool.Waiting()) + "\tRd2pileupOnGoPool:" + strconv.Itoa(Rd2pileupOnGoPool.Running()) + "-" + strconv.Itoa(Rd2PileupOnGpuPool.Waiting())) } }()

输出的内容: 生产者协程池 :running=16,waiting=1;稳定不变 消费者1/2,running = 30-64 动态稳定,waiting=0

我的疑问: 在上述运行状态中,cpu利用率只有30-40核。请问running()和waiting()方法返回的数字的含义。

panjf2000 commented 2 years ago

https://pkg.go.dev/github.com/panjf2000/ants/v2#Pool.Running https://pkg.go.dev/github.com/panjf2000/ants/v2#Pool.Waiting