Bitcoin Forum
November 14, 2018, 05:41:24 AM
 News: Latest Bitcoin Core release: 0.17.0 [Torrent].
 Home Help Search Login Register More
 Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 [42] 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 ... 133
 Author Topic: [XPM] [ANN] Primecoin High Performance | HP14 released!  (Read 396683 times)
mikaelh
Sr. Member

Offline

Activity: 301
Merit: 250

 July 19, 2013, 09:29:58 AM

Just wanted to say great miner!  I feel like this is probably the most optimized miner on the market right now.  Looking over the source code of the original miner and yours I think I see a way to make the miner (potentially much) faster from a mathematical standpoint rather than a code-optimization standpoint.  My optimization centers around the Primorial and the loop that occurs in main.cpp on line 4622.

Before getting into the code, it is important to realize why a primorial is helpful (if you already understand this, skip this paragraph).  With numbers on the order of 2256 there is about a 1 in 177 chance that a random number is prime.  If you select 8 random numbers, then, the odds of all of them being prime is about 1 in 1 quintillion--impractically low.  If you limit your search to only odd numbers, though, the odds shoot up tremendously.  Further limiting your search to numbers not divisible by 3, 5, 7, and so on can cause the odds of finding a prime number to become much, much better.  If the hash value is divisible by lots of these small numbers then multiples of that hash ± 1 will not be divisible by any of those numbers.  Thus, it is convenient to use a hash that is already a multiple of 2 * 3 * 5 * 7 * ... as it will produce far more primes than another hash.

As I understand the aforementioned loop, the program is searching for a hash that is divisible by a primorial.  Each iteration of this loop requires a hash to be generated as it increments the nonce value.  In the present form the primorail is of degree 7 (line 4579: static const unsigned int nPrimorialHashFactor = 7).  I suspect that this value is carefully chosen and it's probably ideal with the way that it is written.  However, I think there's an additional step that can be added to make the process much faster.  Increasing the degree of the primorial is incredibly expensive as it gets larger, since adding the 8th prime requires 19 times as many hashes to be checked; the 9th prime requires 23 times as many, and so on.  There is another way, though.

Prime origins are required to be in the form O = H * N where O is the origin, H is the hash, and N is any integer; H is selected to be divisible by p#7 (the primorial shown above).  If we extend this to O = H * N * P2 where P2 is 19 * 23 * 29 * ... * 51--a product of primes starting after the last prime used in the existing search--then the checked origin is still valid (an integer times an integer is still an integer).  This grants the benefits of searching with a higher degree primorial while not requiring a longer search for a working hash.

Nothing is free, though, as this method inflates the size of the primes to be checked.  If the fast modular exponentiation is implemented through the same method as is used on the Fermat Primality Test Wikipedia page then the algorithmic efficiency is O(log2(n) * log(log(n)) * log(log(log(n))) ).  There should be some sweet spot of how large of a primorial to use where the increased frequency of primes more than offsets the extra time required for the fast modular exponentiation.  It's possible that the sweet spot is 0 extra primes, but I think it's worth looking into.

Definitely a great. I haven't had the time to study the code from a mathematical perspective, so this is helping me understand the code better.

Unfortunately it seems that Sunny King was ahead of you here. The code is already doing what you proposed. It uses something called a round primorial which is dynamically adjusted. You can see these round primorials in debug.log if you enable the debugging options -debug -printmining. A fixed multiplier is calculated through division by the first primorial used to choose the hash value. This fixed multiplier corresponds to your P2.

I think some improvements could be made to the dynamic adjustment system. It seems to be picking lots of different values.
1542174084
Hero Member

Offline

Posts: 1542174084

Ignore
 1542174084

1542174084
 Report to moderator
1542174084
Hero Member

Offline

Posts: 1542174084

Ignore
 1542174084

1542174084
 Report to moderator
1542174084
Hero Member

Offline

Posts: 1542174084

Ignore
 1542174084

1542174084
 Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1542174084
Hero Member

Offline

Posts: 1542174084

Ignore
 1542174084

1542174084
 Report to moderator
1542174084
Hero Member

Offline

Posts: 1542174084

Ignore
 1542174084

1542174084
 Report to moderator
mikaelh
Sr. Member

Offline

Activity: 301
Merit: 250

 July 19, 2013, 09:33:33 AM

aws cc2.8xlarge,
primecoin-0.1.1-hp5 two changes:

1) prime.cpp
const unsigned int nPrimes = (uint64)nTotalPrimes * 8 / 100;  // down from 10

2) main.cpp
static const unsigned int nPrimorialHashFactor = 9; // up from 7

You seem to be testing two changes at the same time. The first change will definitely affect performance while the second change shouldn't as people have already pointed out. It's likely you're only seeing the effects of the first change you did.
arnuschky
Hero Member

Offline

Activity: 516
Merit: 500

 July 19, 2013, 09:55:13 AM

Huh. If this chart is correct, me and a friend are collectively mining 10% of all blocks in the past 24 hours. Kind of cool to be a big fish for once.

Sunny and Mikael are going to be seeing a huge donation from me if this goes well.
You're claiming you found 400 blocks in the last 24 hours?
Each of us has collected over 2k XPM in the past day. 200 blocks*

Just out of curiosity: How much pps are you fielding for that?
paulthetafy
Hero Member

Offline

Activity: 815
Merit: 1000

 July 19, 2013, 10:03:49 AM

aws cc2.8xlarge,
primecoin-0.1.1-hp5 two changes:

1) prime.cpp
const unsigned int nPrimes = (uint64)nTotalPrimes * 8 / 100;  // down from 10

2) main.cpp
static const unsigned int nPrimorialHashFactor = 9; // up from 7

You seem to be testing two changes at the same time. The first change will definitely affect performance while the second change shouldn't as people have already pointed out. It's likely you're only seeing the effects of the first change you did.
mikael, knowing your work I'll take your word for it, do you agree that 1) is a change for the better and will not negatively effect block finding?

Joe13
Newbie

Offline

Activity: 18
Merit: 0

 July 19, 2013, 10:06:32 AM

Sorry i am new to all this ...
But there is one thing i dont get.
I tryed to run it with a primecoin.conf file and changed parameters like rpcuser ... rpcpassword ... gen=0 gen=1 and also with rpcport=9910 rpcallowip=127.0.0.1 with server=1 and daemon=1.
I did not receive any block in earlier stages ... difficulty was past 8 to this stage ...
as i deleted the conf file and run the wallet without it i received two blocks in two hours ...
How can that be ... Luck ? I was using hp3 ...
So my question is is the conf file needed or not ??

Thx
mikaelh
Sr. Member

Offline

Activity: 301
Merit: 250

 July 19, 2013, 10:36:38 AM

aws cc2.8xlarge,
primecoin-0.1.1-hp5 two changes:

1) prime.cpp
const unsigned int nPrimes = (uint64)nTotalPrimes * 8 / 100;  // down from 10

2) main.cpp
static const unsigned int nPrimorialHashFactor = 9; // up from 7

You seem to be testing two changes at the same time. The first change will definitely affect performance while the second change shouldn't as people have already pointed out. It's likely you're only seeing the effects of the first change you did.
mikael, knowing your work I'll take your word for it, do you agree that 1) is a change for the better and will not negatively effect block finding?

The first parameter he changed definitely has a huge impact on performance, that's for sure. The parameter is based on sieve round limit implemented by Sunny King. As you probably know, that resulted in a pretty big performance boost. I'm using a static percentage value in my code instead of counting microseconds.

Changing that percentage may indeed improve performance on some system. It depends on the efficiency difference between the sieve and the primality tester. I may change the percentage into a configuration parameter in the future.
mikaelh
Sr. Member

Offline

Activity: 301
Merit: 250

 July 19, 2013, 10:41:57 AM

Sorry i am new to all this ...
But there is one thing i dont get.
I tryed to run it with a primecoin.conf file and changed parameters like rpcuser ... rpcpassword ... gen=0 gen=1 and also with rpcport=9910 rpcallowip=127.0.0.1 with server=1 and daemon=1.
I did not receive any block in earlier stages ... difficulty was past 8 to this stage ...
as i deleted the conf file and run the wallet without it i received two blocks in two hours ...
How can that be ... Luck ? I was using hp3 ...
So my question is is the conf file needed or not ??

Thx

That is indeed called pure luck.
maco
Sr. Member

Offline

Activity: 294
Merit: 250

 July 19, 2013, 10:44:51 AM

Sorry i am new to all this ...
But there is one thing i dont get.
I tryed to run it with a primecoin.conf file and changed parameters like rpcuser ... rpcpassword ... gen=0 gen=1 and also with rpcport=9910 rpcallowip=127.0.0.1 with server=1 and daemon=1.
I did not receive any block in earlier stages ... difficulty was past 8 to this stage ...
as i deleted the conf file and run the wallet without it i received two blocks in two hours ...
How can that be ... Luck ? I was using hp3 ...
So my question is is the conf file needed or not ??

Thx

That is indeed called pure luck.

Any news with HP5 and if its doing any good?

What has your results shown from all different versions?
Plazma
Full Member

Offline

Activity: 224
Merit: 100

 July 19, 2013, 10:52:54 AM

2 dedicated rigs mining with 1500pps each since 9days.
One got 9 blocks last block 3 days ago.
other got 0 blocks.
random is random.

BTC: 1A1Mwjfw2mTko4N2UuVQ3RK4hXJunsPA3j
XMP: AcT3PK4wofjCMt6irN4HXENUqPvoBJRWk3
svirus
Member

Offline

Activity: 72
Merit: 10

 July 19, 2013, 11:17:34 AM

primecoin@HP5 ... just finded block
4k pps

minerstorm
Full Member

Offline

Activity: 200
Merit: 100

 July 19, 2013, 11:56:32 AM

29 hours is not found block. The rate has increased by 200-300pps, but no blocks.
How are you?
Sorry my english.
jammertr
Member

Offline

Activity: 100
Merit: 10

 July 19, 2013, 12:22:27 PM

same here 3 pc setup,  4000/3500/1700 pps  all on hp5  no luck more than 24 hours
jammertr
Member

Offline

Activity: 100
Merit: 10

 July 19, 2013, 12:24:21 PM

to be honest .... almost 24 hours

same here 3 pc setup,  4000/3500/1700 pps  all on hp5  no luck more than 24 hours
ivanlabrie
Hero Member

Offline

Activity: 812
Merit: 1000

 July 19, 2013, 12:34:38 PM

Day one, 1400pps, 8 core nehalem rig running HP5.
0 blocks.
bitrich
Member

Offline

Activity: 109
Merit: 10

 July 19, 2013, 01:14:45 PM

running i5 at 2000pps. got about 5% more pps from hp4 to hp 5. Only found 2 blocks since release of first client. got them in the first few days, havent had one since on solo. ypool sucks had a second pc pool mining with ypool way too many server rejected shares.
Krusher33
Newbie

Offline

Activity: 37
Merit: 0

 July 19, 2013, 01:16:45 PM

Sorry i am new to all this ...
But there is one thing i dont get.
I tryed to run it with a primecoin.conf file and changed parameters like rpcuser ... rpcpassword ... gen=0 gen=1 and also with rpcport=9910 rpcallowip=127.0.0.1 with server=1 and daemon=1.
I did not receive any block in earlier stages ... difficulty was past 8 to this stage ...
as i deleted the conf file and run the wallet without it i received two blocks in two hours ...
How can that be ... Luck ? I was using hp3 ...
So my question is is the conf file needed or not ??

Thx

Sounds like coincidence.

But why did you have both gen=0 and gen=1 in there?
Joe13
Newbie

Offline

Activity: 18
Merit: 0

 July 19, 2013, 01:32:35 PM

Nah, tryed it once with gen=0 and then another time with gen=1 but i never maintained to get a block...
That is why i am asking if the conf file is important for the mining, if yes how must it be configured then....
thx
nmersulypnem
Full Member

Offline

Activity: 238
Merit: 100

 July 19, 2013, 01:41:54 PM

Does anyone have a guide for building on Windows.  I can't get the static libraries to bind using MingW.
ig0tik3d
Legendary

Offline

Activity: 1246
Merit: 1000

 July 19, 2013, 01:49:29 PM

Does anyone have a guide for building on Windows.  I can't get the static libraries to bind using MingW.
https://bitcointalk.org/index.php?topic=149479.0
ReCat
Sr. Member

Offline

Activity: 406
Merit: 250

 July 19, 2013, 02:25:35 PM

I just mined 3 blocks in a row... holy crap.

BTC: 1recatirpHBjR9sxgabB3RDtM6TgntYUW
Hold onto what you love with all your might, Because you can never know when - Oh. What you love is now gone.
 Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 [42] 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 ... 133