Neptune-Crypto / neptune-core

anonymous peer-to-peer cash
Apache License 2.0
23 stars 7 forks source link

Mining should be multi-threaded #123

Open dan-da opened 3 months ago

dan-da commented 3 months ago

Presently mining uses only a single CPU.

Mining is an "embarassingly parallel" task, and it should be threaded to take advantage of available CPU cores.

I've already made an implementation using rayon that parallelizes the core mining loop. So I'm opening this issue for tracking purposes.

This article from 2018 describes 3 strategies for parallelizing cryptocurrency mining with rayon. I've implemented the 2nd one, which is perhaps not quite as fast as the 3rd, but simpler as it uses rayon's parallel iterator functionality.

https://www.innoq.com/en/blog/2018/06/blockchain-mining-embarrassingly-parallel/

With --unrestricted-mining flag all 4 cores are pegged on my dev laptop.