Creepsky / creepMiner

Burstcoin C++ CPU and GPU Miner
GNU General Public License v3.0
172 stars 64 forks source link

Optimised Shabals #442

Closed harryjph closed 5 years ago

harryjph commented 5 years ago

Adds dependency on libShabal and calls it only when mining and trying to find the lowest deadline.

harryjph commented 5 years ago

Sorry, source code link is hidden in the original comment. Will get a benchmark soon.

harryjph commented 5 years ago

Testing methodology:

auto start = std::chrono::high_resolution_clock::now();
// Perform calculation
auto end = std::chrono::high_resolution_clock::now();
std::cerr << "Run took " << std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count() << " nanoseconds" << std::endl;

Test was performed on 1GB plotfile on NVMe SSD (Read speed should not be an issue anyway) CPU: Core i7-8550U (AVX2) RAM: 16GB LPDDR3 Results were taken from first block mined after startup. Miner seems to divide each plotfile into multiple runs...

Optimised results

Run took 101783 nanoseconds
Run took 58088 nanoseconds
Run took 72996 nanoseconds
Run took 47807 nanoseconds
Run took 66827 nanoseconds
Run took 60145 nanoseconds
Run took 58602 nanoseconds
Run took 64771 nanoseconds
Run took 86875 nanoseconds
Run took 64771 nanoseconds
Run took 47807 nanoseconds
Run took 52434 nanoseconds
Run took 42667 nanoseconds
Run took 42153 nanoseconds
Run took 43181 nanoseconds
Run took 42891 nanoseconds

Unoptimised results

Run took 92016 nanoseconds
Run took 66827 nanoseconds
Run took 62715 nanoseconds
Run took 95615 nanoseconds
Run took 107952 nanoseconds
Run took 89446 nanoseconds
Run took 100755 nanoseconds
Run took 88932 nanoseconds
Run took 86362 nanoseconds
Run took 93559 nanoseconds
Run took 62201 nanoseconds
Run took 95614 nanoseconds
Run took 68884 nanoseconds
Run took 60659 nanoseconds
Run took 82763 nanoseconds
Run took 59117 nanoseconds

Total optimised: 953798 nanoseconds Total unoptimised: 1313417 nanoseconds

Representing a 27.4% speed increase in my extremely rudimentary benchmark.

Bear in mind that this does not represent AVX512f-enabled CPUs, which were previously not accounted for at all.

Creepsky commented 5 years ago

Please tell me if im right: you made a rust binding lib between the shabal code in Scavanger <-> C, then used the binding lib in creepMiner?

If so, would it not be easier to use the optimized shabal files from https://github.com/PoC-Consortium/scavenger/tree/775b0ea52fdc22c81ad2cc0ec20a787c20922aef/src/c?

Correct me if im wrong.

harryjph commented 5 years ago

It uses those files and those files only - the only reference to the scavenger directory is in build.rs, pointing to the c directory. the link to the repo is just there for transparency when updating and to make it clear where the source is from.

harryjph commented 5 years ago

Rebased onto development