rieMiner - Solo + pooled Riecoin mining

Current existing mining softwares
Post Reply
Rockhawk
Posts: 48
Joined: 29 Oct 2018, 21:12

Re: rieMiner - Solo + pooled Riecoin mining

Post by Rockhawk » 05 Dec 2018, 00:18

The feature-ispc branch is pretty much ready to merge. I'll continue testing overnight with gdb attached and submit a PR tomorrow.

Comparing performance on a 16T/8C server, sieving to 2^33 at difficulty 1400:

Code: Select all

Current master (0.9RC3): BENCHMARK RESULTS: 278.269222 primes/s with ratio 24.205976 -> 2.893116 block(s)/day
ISPC branch, AVX2:       BENCHMARK RESULTS: 293.273713 primes/s with ratio 24.088900 -> 3.123935 block(s)/day
ISPC branch, AVX512:     BENCHMARK RESULTS: 353.827797 primes/s with ratio 23.747676 -> 4.047624 block(s)/day
The AVX2 result was obtained by forcibly disabling AVX512 - all those runs were done on the same sever. I was only testing to 10000 2-tuples so the ratio difference is just random variation.

In addition to the AVX2 and 512 implementations of the prime test and the AVX2 implementation of the remainder calculation, this branch also has throughput fixes from testing on a 36T/18C server. There were massive stalls with the old code when you have that many threads, and also there was very serious lock contention updating the segment offsets which I've managed to resolve using a lockfree approach to filling the segment array. This provides a moderate boost even when you "only" have 16 threads.

Pttn, it might be worth switching your testing to this branch - let me know if you see any issues!

Pttn
Posts: 133
Joined: 24 Aug 2018, 13:37

Re: rieMiner - Solo + pooled Riecoin mining

Post by Pttn » 05 Dec 2018, 01:00

Impressive! This is definitively worth including in the Stable Release!
If only AMD included AVX512... A 27% improvement for a given set of parameters is just insane! And 5% for AVX2 is still nice.
I will switch to your branch before going to sleep, I just want to finish the Segwit implementation first (seems working for now) and maybe try some softforks in Testnet.

I caught again this, but this time I did try to print old and sieveSize. Tell me if you need something else. This bug seems to be somewhat reproducible if I could get this a second time.

Code: Select all

[0011:45:39] 4-tuple found
[0011:46:18] (1-3t/s) = (319.6 12.79 0.547) ; (2-6t) = (570081 23120 964 31 2) | 8.46 h
rieMinerNew: Miner.hpp:121: void Miner::_addToPending(uint8_t*, uint32_t*, uint64_t&, uint32_t): Assertion `old < _parameters.sieveSize' failed.

Thread 20 "rieMinerNew" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffb0ff9700 (LWP 30695)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) print old
No symbol "old" in current context.
(gdb) print _parameters.sieveSize
No symbol "_parameters" in current context.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff75382f1 in __GI_abort () at abort.c:79
#2  0x00007ffff752fa8a in __assert_fail_base (fmt=0x7ffff7683ec8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5555555c3a3d "old < _parameters.sieveSize", file=file@entry=0x5555555c3a33 "Miner.hpp", 
    line=line@entry=121, 
    function=function@entry=0x5555555c3f80 <Miner::_addToPending(unsigned char*, unsigned int*, unsigned long&, unsigned int)::__PRETTY_FUNCTION__> "void Miner::_addToPending(uint8_t*, uint32_t*, uint64_t&, uint32_t)")
    at assert.c:92
#3  0x00007ffff752fb02 in __GI___assert_fail (assertion=assertion@entry=0x5555555c3a3d "old < _parameters.sieveSize", file=file@entry=0x5555555c3a33 "Miner.hpp", line=line@entry=121, 
    function=function@entry=0x5555555c3f80 <Miner::_addToPending(unsigned char*, unsigned int*, unsigned long&, unsigned int)::__PRETTY_FUNCTION__> "void Miner::_addToPending(uint8_t*, uint32_t*, uint64_t&, uint32_t)")
    at assert.c:101
#4  0x0000555555567a05 in Miner::_addToPending (ent=<optimized out>, pos=<optimized out>, pending=<optimized out>, sieve=<optimized out>, this=<optimized out>) at Miner.hpp:141
#5  Miner::_addRegToPending (mask=<optimized out>, reg=..., pos=<optimized out>, pending=<optimized out>, sieve=<optimized out>, this=<optimized out>) at Miner.hpp:130
#6  Miner::_processSieve6 (this=<optimized out>, sieve=<optimized out>, offsets=<optimized out>, start_i=<optimized out>, end_i=28192750) at Miner.cpp:426
#7  0x000055555556c20f in Miner::_runSieve(SieveInstance&, unsigned int) () at Miner.cpp:472
#8  0x000055555556cf31 in Miner::_verifyThread() () at Miner.cpp:558
#9  0x000055555556edd8 in Miner::process (this=this@entry=0x55555561aff0, block=...) at Miner.cpp:661
#10 0x00005555555882d1 in WorkManager::minerThread() () at /usr/include/c++/8/bits/char_traits.h:285
#11 0x00007ffff794aaff in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#12 0x00007ffff76c5f2a in start_thread (arg=0x7fffb0ff9700) at pthread_create.c:463
#13 0x00007ffff75f8edf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) print old
No symbol "old" in current context.
(gdb) print _parameters.sieveSize
No symbol "_parameters" in current context.
rieMiner - Riecoin solo + pooled miner
Personal Riecoin page (links, download,...)
freebitco.in - earn up to $200 in BTC each hour!

Pttn
Posts: 133
Joined: 24 Aug 2018, 13:37

Re: rieMiner - Solo + pooled Riecoin mining

Post by Pttn » 05 Dec 2018, 03:06

I just updated rieMiner to include SegWit support (at least experimental for now). rieMiner is now able (if the segwit Rule is set in the options, like below) to mine Segwit transactions between "t" addresses in TestNet, and also blocks with mixed segwit + legacy transactions, so I assume that rieMiner is now SegWit ready in case it ever gets actived. It also worked with legacy transactions produced by 0.10.2 in Testnet too, so current normal mining should be unaffected.

I added a "Rules" option where one can add rules for the GetBlockTemplate call. For example,

Code: Select all

Rules = segwit
Will send

Code: Select all

{"method": "getblocktemplate", "params": [{"rules":["segwit"]}], "id": 0}
While

Code: Select all

Rules = segwit, csv
Would send

Code: Select all

{"method": "getblocktemplate", "params": [{"rules":["segwit", "csv"]}], "id": 0}
Both instead of

Code: Select all

{"method": "getblocktemplate", "params": [], "id": 0}
More testing is welcome. And as I am not an expert in this domain, knowledgeable developers about Bitcoin Core code, in particular for softforks, are welcome to give me tips and comment on the update.
rieMiner - Riecoin solo + pooled miner
Personal Riecoin page (links, download,...)
freebitco.in - earn up to $200 in BTC each hour!

Pttn
Posts: 133
Joined: 24 Aug 2018, 13:37

Re: rieMiner - Solo + pooled Riecoin mining

Post by Pttn » 05 Dec 2018, 03:51

Rockhawk wrote:
05 Dec 2018, 00:18
Pttn, it might be worth switching your testing to this branch - let me know if you see any issues!
Hmmm... For some reason, I mine much slower with your new code with my 2700X (AVX2), using the same configuration file (Sieve 2^32, actual mining at current Difficulty, 16 Threads, 3 Workers). Before (Master with Segwit code, 62cf9ef):

Code: Select all

[0000:00:00] Started mining at block 998882, difficulty 1370
[0000:00:15] (1-3t/s) = (276.8 10.80 0.524) ; (2-6t) = (165 8 0 0 0) | 11.1 h
[0000:00:23] 4-tuple found
[0000:00:30] (1-3t/s) = (304.3 12.44 0.495) ; (2-6t) = (377 15 1 0 0) | 7.98 h
[0000:00:45] (1-3t/s) = (305.5 12.12 0.574) ; (2-6t) = (549 26 2 0 0) | 9.27 h
[0000:00:45] 4-tuple found
[0000:01:00] (1-3t/s) = (309.2 12.68 0.613) ; (2-6t) = (765 37 2 0 0) | 7.75 h
[0000:01:01] 4-tuple found
[0000:01:12] 4-tuple found
[0000:01:15] (1-3t/s) = (307.3 12.46 0.584) ; (2-6t) = (939 44 4 0 0) | 8.23 h
[0000:01:30] (1-3t/s) = (314.5 13.05 0.653) ; (2-6t) = (1179 59 4 0 0) | 7.18 h
After (Feature Ispc, b16126e):

Code: Select all

[0000:00:00] Started mining at block 998881, difficulty 1370
[0000:00:15] (1-3t/s) = (144.6 6.61 0.262) ; (2-6t) = (101 4 0 0 0) | 9.64 h
[0000:00:30] (1-3t/s) = (185.0 7.99 0.297) ; (2-6t) = (242 9 0 0 0) | 10.0 h
[0000:00:42] 4-tuple found
[0000:00:45] (1-3t/s) = (191.4 7.88 0.309) ; (2-6t) = (357 14 1 0 0) | 12.3 h
[0000:01:00] (1-3t/s) = (196.6 7.82 0.315) ; (2-6t) = (472 19 1 0 0) | 14.2 h
[0000:01:15] (1-3t/s) = (206.3 7.88 0.332) ; (2-6t) = (594 25 1 0 0) | 16.5 h
[0000:01:30] (1-3t/s) = (211.9 8.20 0.343) ; (2-6t) = (741 31 1 0 0) | 15.1 h
Even if this comparison was very short, there is no way that I can get such difference statistically, and it is reproductible.

However, I seem to enjoy the performance boost in my 6700K (AVX2) with same parameters (Sieve 2^31).
What is happening?
rieMiner - Riecoin solo + pooled miner
Personal Riecoin page (links, download,...)
freebitco.in - earn up to $200 in BTC each hour!

Rockhawk
Posts: 48
Joined: 29 Oct 2018, 21:12

Re: rieMiner - Solo + pooled Riecoin mining

Post by Rockhawk » 05 Dec 2018, 08:19

Wow - I had thought there could be a difference in performance on AMD, but hadn't expected it would be worse with this branch than master, let alone 35% worse!

I think the basic problem is that the Zen architecture doesn't have true 256-bit wide integer units, and the ISPC optimized prime test has enough independent instructions in it that the CPU is mostly throughput bound.

I spun up an AWS instance with an EPYC chip and see similar performance degredation, so at least I can use that for testing. From a quick go there seems to be very little improvement in the updateRemainders performance from using AVX2 either - although that is at least slightly better.

For now, I think I'll just disable the ISPC prime test unless the CPUID reports an Intel processor. I'm not going to have much more time to work on improvments for the rest of the month, but if I do get some I'll investigate if there's anything we can do to help perf on Zen.

Pttn
Posts: 133
Joined: 24 Aug 2018, 13:37

Re: rieMiner - Solo + pooled Riecoin mining

Post by Pttn » 05 Dec 2018, 09:02

Ah, this is a shame :|... Ok, good enough.

Also, I did a MemTest and did not find any error after some passes. There really should not be any hardware error in this computer, so I am confident that there are bugs somewhere.
Rockhawk wrote:
05 Dec 2018, 08:19
I'm not going to have much more time to work on improvments for the rest of the month
We both deserved some break after all that work :D ! I will be too busy to work on rieMiner after half December. I hope that we will be able to fix all remaining bugs until then.
rieMiner - Riecoin solo + pooled miner
Personal Riecoin page (links, download,...)
freebitco.in - earn up to $200 in BTC each hour!

Rockhawk
Posts: 48
Joined: 29 Oct 2018, 21:12

Re: rieMiner - Solo + pooled Riecoin mining

Post by Rockhawk » 05 Dec 2018, 09:46

I've disabled the ISPC prime test on AMD, merged up with your branch and submitted the pull request.

I still haven't seen any unexplained seg faults/asserts in my testing. I'll continue to run in gdb and hopefully I'll be able to debug it if I hit it!

czakris
Posts: 20
Joined: 16 Sep 2018, 05:03

Re: rieMiner - Solo + pooled Riecoin mining

Post by czakris » 05 Dec 2018, 10:44

$ make
g++ -Wall -Wextra -std=gnu++11 -O3 -march=native -c -o main.o main.cpp
g++ -Wall -Wextra -std=gnu++11 -O3 -march=native -c -o Miner.o Miner.cpp
In file included from WorkManager.hpp:6,
from Miner.hpp:8,
from Miner.cpp:5:
Miner.cpp: In member function 'void Miner::_updateRemainders(uint32_t, uint64_t, uint64_t)':
Miner.cpp:273:70: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
DBG_VERIFY(if (remainder >> cnt != mpz_tdiv_ui(tar, p)) { printf("Remainder check fail %lu != %lu\n", remainder >> cnt, mpz_tdiv_ui(tar, p)); abort();});
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
main.hpp:26:40: note: in definition of macro 'DBG_VERIFY'
#define DBG_VERIFY(x) if (DEBUG > 1) { x; };
^
Miner.cpp:289:39: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
if (index != indexCheck) { printf("Index check fail, p=%ld, i=%ld, start_i=%ld\n", p, i, start_i); abort(); }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~
main.hpp:26:40: note: in definition of macro 'DBG_VERIFY'
#define DBG_VERIFY(x) if (DEBUG > 1) { x; };
^
Miner.cpp:289:39: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
if (index != indexCheck) { printf("Index check fail, p=%ld, i=%ld, start_i=%ld\n", p, i, start_i); abort(); }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~
main.hpp:26:40: note: in definition of macro 'DBG_VERIFY'
#define DBG_VERIFY(x) if (DEBUG > 1) { x; };
^
Miner.cpp:289:39: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
if (index != indexCheck) { printf("Index check fail, p=%ld, i=%ld, start_i=%ld\n", p, i, start_i); abort(); }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~
main.hpp:26:40: note: in definition of macro 'DBG_VERIFY'
#define DBG_VERIFY(x) if (DEBUG > 1) { x; };
I had few warnings while compiling but somehow managed to compile and run this miner. Looks better now.

Pttn
Posts: 133
Joined: 24 Aug 2018, 13:37

Re: rieMiner - Solo + pooled Riecoin mining

Post by Pttn » 05 Dec 2018, 14:24

Rockhawk, I merged your work, thank you a lot! I did not find issues other than that AMD specific slowdown.

czakis, this has been fixed.
rieMiner - Riecoin solo + pooled miner
Personal Riecoin page (links, download,...)
freebitco.in - earn up to $200 in BTC each hour!

Rockhawk
Posts: 48
Joined: 29 Oct 2018, 21:12

Re: rieMiner - Solo + pooled Riecoin mining

Post by Rockhawk » 05 Dec 2018, 23:39

Awesome. I think we can both be pretty happy with where we've got to over the last couple of months. The performance is up by over 20% on 0.9-beta2.3, which was already a well regarded implementation from dga. For the release it would be great if you could do a direct comparison of the block rate and share rate compared to xptMiner to be clear about the performance win.

A top performing, open source miner implementation that can work both directly with GetBlockTemplate and with Stratum is a great thing to have available. I hope the improvements in this miner might attract enough attention to push the difficulty up a bit, which would be help move Riecoin towards record breaking territory again!

Post Reply