Ok, so I'm probably hurting my income, but sharing some hints for optimizations:
A quick'n'dirty profiling run showed that we spend very much time in memory allocations, so I am trying to eliminate some of them.
-did the headerhash mod outlined earlier
-did the time limit on Weave() from Sunny King
-removed some printf's , especially
printf("MineProbablePrimeChain() : new sieve (%u/%u) ready in %uus\n", psieve->GetCandidateCount(), nMaxSieveSize, (unsigned int) (GetTimeMicros() - nStart));
from prime.cpp since it's the only call to the rather expensive GetCandidateCount
-after creating vPrimes array in prime.cpp, store vPrimes.size() in a static variably and replace all calls to it with the variable
-in prime.cpp, PrimeTableGetNextPrime and PrimeTableGetPreviousPrime: Use upper_bound/lower_bound instead of linear search:
// Get next prime number of p
bool PrimeTableGetNextPrime(unsigned int& p)
{
std::vector<unsigned int>::iterator foundelement=upper_bound(vPrimes.begin(), vPrimes.end(),p);
if (foundelement!=vPrimes.end()){
p=*foundelement;
return true;
}
return false;
}
// Get previous prime number of p
bool PrimeTableGetPreviousPrime(unsigned int& p)
{
std::vector<unsigned int>::iterator foundelement=lower_bound(vPrimes.begin(), vPrimes.end(),p);
if (foundelement!=vPrimes.end()){
p=*--foundelement;
return true;
}
return false;
}
- in prime.cpp, CSieveOfEratosthenes::Weave() :
Split the for loop into two for loops, one going up to nChainLength, the other one going up to 2*nChainLength
Thus, you can safe the first first if+for clause in the first loop and leave away the if, and leave the if+for completely away in the second loop.
Also,
if (((nBiTwinSeq & 1u) == 0))
...
if (((nBiTwinSeq & 1u) == 1u))
can be substituted by
if (((nBiTwinSeq & 1u) == 0))
....
else
.....
-prime.h: Removed nSieveSize and replaced all occurrences with nMaxSieveSize. Removed nSieveSize from the initializer as it's become obsolete.
-prime.h: Changed
< std::vector<bool> vfCompositeCunningham1;
< std::vector<bool> vfCompositeCunningham2;
< std::vector<bool> vfCompositeBiTwin;
---
> bool vfCompositeCunningham1[1000000];
> bool vfCompositeCunningham2[1000000];
> bool vfCompositeBiTwin[1000000];
Thus, we should save on quite a few mallocs.
-prime.h: Removed nSieveSize and replaced all occurrences with nMaxSieveSize. Removed nSieveSize from the initializer as it's become obsolete.
-prime.h: Changed
< std::vector<bool> vfCompositeCunningham1;
< std::vector<bool> vfCompositeCunningham2;
< std::vector<bool> vfCompositeBiTwin;
---
> bool vfCompositeCunningham1[1000000];
> bool vfCompositeCunningham2[1000000];
> bool vfCompositeBiTwin[1000000];
Thus, we should save on quite a few mallocs.
Don't forget to initialize the array by adding the following below in place of the other initialization
for (int i = 0; i<1000000; ++i){
vfCompositeCunningham1[i] = false;
vfCompositeCunningham2[i] = false;
vfCompositeBiTwin[i] = false;
}
I think it'd be ideal to use a 2D array with the three composite values stored sequentially in memory as single bits each
Probably should be a std::bitset datatype too
+1
Or somebody could not be a greedy dick! And at least show the noob that wants to attempt to help out ur network with more miners which files to add all this too.. or code to replace this with.. any explanation to a non coder how to implement.. Or hopefully I have found a dev in this community that is willing to have a young grasshopper!!! to the greedy people!? killurselvessry to be an ass but some of you coders are shitting on my big smile i had when i woke up today! and to think the people I am talking about... I have randomly spoken very positive about in different place in the coin community! psh!