Comments (5)
加锁后资源消耗会增加,性能会下降很多,所以是加锁确保池数量还是不加锁保证性能呢?
from ants.
并发量不大的情况下还是建议直接用goroutine,不然池化未必比裸用goroutine性能好,甚至会下降。
from ants.
from ants.
那个compare操作的确不是原子操作,一种潜在的可能是:在比较过程中,某个worker结束任务了,把running数减一了,这可能导致pool有轻微的goroutine数量溢出。但是,
第一,发生的概率很小而且也只会是轻微溢出,我觉得在容忍限度以内;
第二, 如果要完全保证数据强正确的话,得再加锁,但这样不仅会让代码更加复杂,而且性能也会有比较大的下降,我觉得有点舍本逐末了。
目前我没想到既能保证性能又能保证数值绝对正确的实现方法,这个我后续有空再思考下,要是你有好的方法的话也欢迎提个PR我们一起讨论下😀,我先把issue设置成enhancement,以后慢慢优化。
from ants.
from ants.
Related Issues (20)
- [Question]: 主动kill任务 HOT 1
- [Bug]: ants.NewPoolWithFunc(1000, dorequest),当dorequest函数中不使用fmt.Println时,CPU耗尽;当使用打印函数时,CPU正常 HOT 6
- [Question]: can you please confirm the proper way for variables to be sent using ants? HOT 1
- [Question]: 清理过期worker一点疑问 HOT 1
- [Bug]: go.mod 中的go version(1.13)和ants.go存在不匹配 HOT 2
- [Bug]: Potential goroutine leak in pool.go HOT 3
- [Question]: How can I verifier the max goroutine count in pool is correct HOT 2
- [Question]: 为什么不提供一个任务包装,等待,获取任务结果 HOT 1
- [Question]: How to get meaningful statistics on a function pool? HOT 2
- [Question]: ants.Submit() question HOT 4
- [Question]: set max block task, but not return err when block task num more than set value HOT 1
- [Feature]: Add panicHandlerBuilder HOT 3
- [Question]: Can ants execute tasks in order? HOT 1
- [Bug]: 设置了ants.WithExpiryDuration(5*time.Second) 没起作用,导致pool满后一直未释放worker,阻塞新task HOT 1
- [Question]: 在mac上运行自带的压测代码,antspool的并发不如原生的goroutine HOT 1
- 使用ants嵌套并发无法正确取消上下文
- [Feature]: 144bytes allocated consistently just using ants.Submit( without doing anything HOT 2
- [Bug]: Crashed running this in 192 core cpu aws c6a 384 gb ram cloud instance HOT 2
- [Question]: possible to provide advise on when should we use this gopool vs ants? HOT 1
- [Bug]: A potential goroutine leak in pool.go HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ants.