Bill Allombert on Sun, 22 Sep 2024 16:03:43 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Suspicious average timing of isprime() (maybe a bug?!)


On Sun, Sep 22, 2024 at 06:50:24AM -0700, Ilya Zakharevich wrote:
> On Sat, Sep 21, 2024 at 10:00:24PM +0200, Bill Allombert wrote:
> > > THE RESULT:
> > > 
> > > # Start     Time       Checked primes
> > > 1e19    118.700	  457665
> > 
> > This one make sense.
> 
> This is why I did not exclude it. ;―)
> 
> > > 2e19    5323.600        449605
> > > 4e19    6414.950        443260
> > > 8e19    8459.400        437461
> > > 1e20    8443.400        434090
> > > 2e20    8546.700        427974
> > > 4e20    8610.000        422382
> 
> Every batch shows a gradual growth with variation of about 1%. 

Numbers such that p-1 is hard to factor should be significantly
slower than other.

> > So maybe compute the standard deviation for each batchs ?
> 
> See above.  Completely negligible variation, then a ∼2x growth/decay
> on an interval of width less than twice the width of averaging. 

You can try to change the threshold in

src/basemath/prime.c: 554
static GEN
BPSW_try_PL(GEN N)
{
  ulong B = minuu(1UL<<19, maxprime());

Replace 19 by DEBUGVAR, then in GP do 
install(setdebugvar,vL)
setdebugvar(19)

Cheers,
Bill