Post
Topic
Board Altcoin Discussion
Re: [XPM] Primecoin Built-in Miner Sieve Performance Issue
by
AgentME
on 12/07/2013, 23:49:32 UTC
The rationale for the weave timing parameter instead of the weave count parameter is because the weave timing parameter requires only a call to "GetTimeMicros()" whereas determining the weave count parameter is far more intensive to calculate.  To calculate it requires looping through all three arrays to find the values that are still false:

from prime.h:

Code:
   unsigned int GetCandidateCount()
    {
        unsigned int nCandidates = 0;
        for (unsigned int nMultiplier = 0; nMultiplier < nSieveSize; nMultiplier++)
        {
            if (!vfCompositeCunningham1[nMultiplier] ||
                !vfCompositeCunningham2[nMultiplier] ||
                !vfCompositeBiTwin[nMultiplier])
                nCandidates++;
        }
        return nCandidates;
    }

the vfComposite arrays are all start out as "0" and when a value is found that is not a prime compatible with Sunny's algorithm, that value gets set to 1.  All vfComposite arrays are nMaxSieveSize in length:

Code:
static const unsigned int nMaxSieveSize = 1000000u;

So to calculate a weave count parameter requires 3 million boolean tests, plus the costs of a loop plus the increment operator for each time the if statement returns true.
No, I meant only a counter of how many times the Weave() function is called, not related to GetCandidateCount().