m*****n 发帖数: 3575 | 1 四个核,八线程的CPU
假设有64个任务需要算
Py开四个进程算16轮、Java开八个线程算8轮、与GO开64个协程只算一轮
孰快? |
h*i 发帖数: 3446 | 2 I think Java will win in your case.
You said it's a computation only task, so the most efficient method is to
use the same number of threads as the number of cores. No waste on context
switch here.
Go still use threads in the end, so it will still involve context switch
cost. GOMAXPROCS defaults to be the same as the number of cores, so the only
additional overhead would be that of the goroutine scheduler, so it is not
zero cost compared with Java case.
python cannot compete in speed with the other two languages, so you shouldn'
t even try to compare them.
【在 m*****n 的大作中提到】 : 四个核,八线程的CPU : 假设有64个任务需要算 : Py开四个进程算16轮、Java开八个线程算8轮、与GO开64个协程只算一轮 : 孰快?
|
h*i 发帖数: 3446 | 3 In my mind, CSP is not for concurrency, it is for programming convenience.
Pretend to program synchronously, while doing things asynchronously.
Raw concurrency wise, nothing, I do mean nothing, beats java.util.
concurrent classes.
【在 m*****n 的大作中提到】 : 四个核,八线程的CPU : 假设有64个任务需要算 : Py开四个进程算16轮、Java开八个线程算8轮、与GO开64个协程只算一轮 : 孰快?
|
n******t 发帖数: 4406 | 4 coroutine,thread不是用來加速的。。。你之前的帖子一直沒把這件事情搞清楚。
【在 m*****n 的大作中提到】 : 四个核,八线程的CPU : 假设有64个任务需要算 : Py开四个进程算16轮、Java开八个线程算8轮、与GO开64个协程只算一轮 : 孰快?
|
g****t 发帖数: 31659 | 5 Java最大的問題是framework是針對低級用戶的。用時間長了導致人腦子出問題。
昨天我叫一個4年經驗的中國developer。寫一個android app。這個app launch時候錄
音,關閉前存為1.wav。下一次launch 存為2.wav。Use case是實驗室錄一個機器的聲
音。
就這麼簡單的事。這個developer听不懂。我解释了半天。他
非常震驚為什麼不加几个record,Save的button。这就是framework一知半解的用多了
,建立事情始末的過程模型的能力就沒了。
: I think Java will win in your case.
: You said it's a computation only task, so the most efficient
method is
to
: use the same number of threads as the number of cores. No waste
on
context
: switch here.
: Go still use threads in the end, so it will still involve
context
switch
: cost. GOMAXPROCS defaults to be the same as the number of cores,
so
the only
: additional overhead would be that of the goroutine scheduler,
so it
is not
: zero cost compared with Java case.
: python cannot compete in speed with the other two languages, so
you
shouldn'
: t even try to compare them.
【在 h*i 的大作中提到】 : In my mind, CSP is not for concurrency, it is for programming convenience. : Pretend to program synchronously, while doing things asynchronously. : Raw concurrency wise, nothing, I do mean nothing, beats java.util. : concurrent classes.
|
g****t 发帖数: 31659 | 6 假如64个任务不是同样的。golang的scheduler可能有帮助。
Java, C plus 等等手工分配线程难度大。
例如我有不同的size大矩阵求逆。如何分配线程和切换。这还真不是一个简单的问题。
: I think Java will win in your case.
: You said it's a computation only task, so the most efficient method is
to
: use the same number of threads as the number of cores. No waste on
context
: switch here.
: Go still use threads in the end, so it will still involve context
switch
: cost. GOMAXPROCS defaults to be the same as the number of cores, so
the only
: additional overhead would be that of the goroutine scheduler, so it
is not
: zero cost compared with Java case.
: python cannot compete in speed with the other two languages, so you
shouldn'
: t even try to compare them.
【在 h*i 的大作中提到】 : In my mind, CSP is not for concurrency, it is for programming convenience. : Pretend to program synchronously, while doing things asynchronously. : Raw concurrency wise, nothing, I do mean nothing, beats java.util. : concurrent classes.
|
m*****n 发帖数: 3575 | 7 这不就是个不等重的负载均衡问题吗?
能者多劳,谁完了活儿马上给它派下一个,不就结了?
我敢说Java的8轮比GO的1轮更擅长这个问题
is
【在 g****t 的大作中提到】 : 假如64个任务不是同样的。golang的scheduler可能有帮助。 : Java, C plus 等等手工分配线程难度大。 : 例如我有不同的size大矩阵求逆。如何分配线程和切换。这还真不是一个简单的问题。 : : : I think Java will win in your case. : : You said it's a computation only task, so the most efficient method is : to : : use the same number of threads as the number of cores. No waste on : context : : switch here.
|
m*****n 发帖数: 3575 | 8 那是用来干嘛地?
找乐子?
【在 n******t 的大作中提到】 : coroutine,thread不是用來加速的。。。你之前的帖子一直沒把這件事情搞清楚。
|
m*****n 发帖数: 3575 | 9 谢谢,我也这么觉得
一帮开发脑子被驴踢了,用GO就要把协程全开满,觉得自己多先进似的
结果经常计算超时严重,也不知道原因
我提醒一句,他还说不超过100个协程难道还算多?
【在 h*i 的大作中提到】 : In my mind, CSP is not for concurrency, it is for programming convenience. : Pretend to program synchronously, while doing things asynchronously. : Raw concurrency wise, nothing, I do mean nothing, beats java.util. : concurrent classes.
|
g****t 发帖数: 31659 | 10 先放哪个task?
Load balancing是NP complete。你觉得简单是错觉。
: 这不就是个不等重的负载均衡问题吗?
: 能者多劳,谁完了活儿马上给它派下一个,不就结了?
: 我敢说Java的8轮比GO的1轮更擅长这个问题
: is
【在 m*****n 的大作中提到】 : 谢谢,我也这么觉得 : 一帮开发脑子被驴踢了,用GO就要把协程全开满,觉得自己多先进似的 : 结果经常计算超时严重,也不知道原因 : 我提醒一句,他还说不超过100个协程难道还算多?
|
|
|
h*i 发帖数: 3446 | 11 I can bet that java.util.concurrent has better implemented thread pool
executor services than go's scheduler.
java.util.concurrent is done by a guy whose life's work is in that. I doubt
anybody in go has that kind of experience and dedication in concurrency as
Doug Lea
【在 g****t 的大作中提到】 : 先放哪个task? : Load balancing是NP complete。你觉得简单是错觉。 : : : 这不就是个不等重的负载均衡问题吗? : : 能者多劳,谁完了活儿马上给它派下一个,不就结了? : : 我敢说Java的8轮比GO的1轮更擅长这个问题 : : is :
|
h*i 发帖数: 3446 | 12 who said you will manually allocate threads in Java? Everyone is using a
thread pool where the allocation is managed by the system, which is written
by a very experienced guy, far more experienced by anybody in go community.
is
【在 g****t 的大作中提到】 : 假如64个任务不是同样的。golang的scheduler可能有帮助。 : Java, C plus 等等手工分配线程难度大。 : 例如我有不同的size大矩阵求逆。如何分配线程和切换。这还真不是一个简单的问题。 : : : I think Java will win in your case. : : You said it's a computation only task, so the most efficient method is : to : : use the same number of threads as the number of cores. No waste on : context : : switch here.
|
m*****n 发帖数: 3575 | 13 前提是task的工作量都差不多,或者至少从表面上能大致推测出工作量的比
如果这两个都不满足
在足够多工作量(远超过64个)的情况下,在统计学大数定律的作用下,不满足没多大
关系
【在 g****t 的大作中提到】 : 先放哪个task? : Load balancing是NP complete。你觉得简单是错觉。 : : : 这不就是个不等重的负载均衡问题吗? : : 能者多劳,谁完了活儿马上给它派下一个,不就结了? : : 我敢说Java的8轮比GO的1轮更擅长这个问题 : : is :
|
g****t 发帖数: 31659 | 14 就算队列是自动管理的。参数总要人工设置吧。pool size, alive time之类的,我怀
疑一般的typical設置未必就比golang 的scheduler好用。Java基本优势是测试覆盖充
分。别的方面我不认为比新的系统强。这个和开发者有多少年的工龄关系不大。本身两
个系统的setup不同。
另外Java似乎是对IO bound问题优化过的。
要么就是我不熟悉JVM优化的细节。對CPU密集問題性能不穩定。
我的设置如下:
一核一线程跑不同参数的遗传算法,都迭代一亿次
然後我發現JVM的速度时快时慢。非常不稳定。有时候相差很远。
(每一千次迭代,我把调试信息写入一個CSv文件。
事後根據CSV畫圖看速度)
: who said you will manually allocate threads in Java? Everyone is
using
a
: thread pool where the allocation is managed by the system, which
is
written
: by a very experienced guy, far more experienced by anybody in go
community.
: is
【在 h*i 的大作中提到】 : who said you will manually allocate threads in Java? Everyone is using a : thread pool where the allocation is managed by the system, which is written : by a very experienced guy, far more experienced by anybody in go community. : : is
|
g****t 发帖数: 31659 | 15 誰寫個64個2000-4000 size的正定陣求逆的測試代碼看一下就知道答案了。(用
cholesky decomposition)
還是要實證為第一。 |
m*****n 发帖数: 3575 | 16 你们谁有兴趣可以做个实验
然后撸篇论文
可惜诸位好像都是产业界的,对论文不大感冒
可以召唤 菌斑的 李药师 老将来
如果他真是学校的IT教授,不是轮子的枪手
【在 g****t 的大作中提到】 : 誰寫個64個2000-4000 size的正定陣求逆的測試代碼看一下就知道答案了。(用 : cholesky decomposition) : 還是要實證為第一。
|