Skip to content

Miner hashrate

David Vorick requested to merge miner-hashrate into master

This should be merged after the ux pr.

I reorganized the miner a bit. Now it uses the consensus package as a module instead of importing the state directly. Other smaller organizations were made, mostly that reduce dependency on locking.

Though it probably wasn't the best use of my time, I ran the miner through a profiler and optimized it. As it happens, the call crypto.HashAll(b.ID, b.Nonce, blockRoot) was taking the vast majority of the time, as one might expect, except that the hashing portion was only active 20% of the time. Garbage collection was taking up something like 70% of the time??? So I rewrote it, bypassing the HashAll function and the encoding package and instead encoding it manually. The result was a 3x speedup to our miner. My desktop is running this code and it's working very much to my favor.

Then I added some code to give the miner awareness of how fast it's hashing. The old code would get all the way up to about 1.1 Mhash/s on 7+ threads. To my surprise, 20 threads were just as efficient as 7, there didn't seem to be overhead with having too many threads. The new code runs at about 3.1 Mhash/s on my desktop, which is comparable to Forest's single 100mhz fpga core.

Finally, I added a tool to convert hashrate to blocks per month. The math took me a while but that's probably a calculation we're going to want to keep. It would probably be nice to have some api call that allows external miners to report their hashrate.

I plan on integrating these 2 new statistics with the UI. The only thing that's missing now is some indicator of how many blocks total you've found, (this indicator should probably also have an orphan count), and additional information about how long it will be until you get your payments.

Merge request reports