Error running concurrent process and storing results in array

data pulverizer data.pulverizer at gmail.com
Wed May 6 06:43:03 UTC 2020


On Wednesday, 6 May 2020 at 05:50:23 UTC, drug wrote:
> General advice - try to avoid using `array` and `new` in hot 
> code. Memory allocating is slow in general, except if you use 
> carefully crafted custom memory allocators. And that can easily 
> be the reason of 40% cpu usage because the cores are waiting 
> for the memory subsystem.

I changed the Matrix object from class to struct and timing went 
from about 19 seconds with ldc2 and flags `-O5` to 13.69 seconds, 
but CPU usage is still at ~ 40% still using 
`taskPool.parallel(iota(n))`. The `.array` method is my method 
for the Matrix object just returning internal data array object 
so it shouldn't copy. Julia is now at about 34 seconds (D was at 
about 30 seconds while just using dmd with no optimizations), to 
make things more interesting I also did an implementation in 
Chapel which is now at around 9 seconds with `--fast` flag.


More information about the Digitalmars-d-learn mailing list