Ilya Zakharevich on Sat, 21 Sep 2024 20:46:35 +0200


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

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


THE METHOD: run isprime() on all pseudoprimes in an interval of length
    	    20M.  Inspect the timing.

THE RESULT:

# Start     Time       Checked primes
1e19    118.700		457665
2e19    5323.600        449605
4e19    6414.950        443260
8e19    8459.400        437461
1e20    8443.400        434090
2e20    8546.700        427974
4e20    8610.000        422382
8e20    16720.000       415756
1e21    16717.400       414056
2e21    17102.800       408566
4e21    8673.450        401265
8e21    8743.950        396126
1e22    8885.250        393752
2e22    9042.050        389569
4e22    9118.450        384823
8e22    9209.950        379336
1e23    9168.000        377295
2e23    9203.750        372843
4e23    14615.250       368239
8e23    14644.800       363116

SUMMARY: after 4e19, the timing is ∼8.5sec slowly growing to
∼9.2sec — but this is intermixed with two intervals where the timing
is ∼17sec (or ∼14.5sec) instead.

    I ZOOM IN on the start of the first interval (unfortunately, this
              run landed on a slower core, so the numbers are larger): 

403183920138050000000   11421.500       422392
403183920142400000000   11357.350       421271
403183920142890000000   11532.600       421294
403183920143380000000   11453.900       421131
403183920143630000000   11498.700       421879

403183920143760000000   13235.200       422138
403183920143770000000   18626.950       422175

403183920143820000000   22177.450       421722
403183920143880000000   22410.400       422102
403183920146740000000   22040.600       421478
403183920151070000000   22132.650       420946

SUMMARY: we average over an interval of length 20M, and when this
interval is positioned within 20M of the middle number above, the
timing grows from ∼11.4K (stable for ranges of quintillions) to ∼22.2K
sec.  (Cannot find anything special about this number: 0x15 db4d 0735 f6df 1a80!)

   LIKEWISE at end of the same interval (yet another core, numbers are smaller):

2027230320051310000000  17371.600       408387
2027230320051360000000  17357.650       408374
2027230320051430000000  17394.550       407942
2027230320051440000000  17317.900       407576
2027230320051450000000  17333.400       407835

2027230320051460000000  13476.600       407255	  0x6d e578 e35c 38b8 4900

2027230320051470000000  9220.250        407794
2027230320051500000000  8756.400        408230
2027230320052010000000  8656.500        407301
2027230320053470000000  10098.800       408204
2027230320057780000000  12074.250       407508


Puzzled (this reeks of a bug!),
Ilya