test_mpz_poly is very slow with many threads if some CPU cores are busy
My AMD Ryzen 5 5600G has 6 physical cores and 12 with hyperthreading. When all cores are idle, test_mpz_poly is quite fast with the default 12 threads:
alex@lily:~/build/cado-nfs/normal> killall -STOP ecm
alex@lily:~/build/cado-nfs/normal> time /home/alex/build/cado-nfs/normal/tests/utils/test_mpz_poly
Using random seed=1714768751
0
17
17+42*x
17+42*x-3*x^2
f=3+3*x+3*x^2+3*x^3+2*x^4+2*x^5+2*x^6+2*x^7+3*x^8
real 0m0,713s
user 0m0,970s
sys 0m0,218s
When some (in this example, two) cores are busy (ecm), it becomes very slow:
alex@lily:~/build/cado-nfs/normal> killall -CONT ecm
alex@lily:~/build/cado-nfs/normal> time /home/alex/build/cado-nfs/normal/tests/utils/test_mpz_poly
Using random seed=1714769125
0
17
17+42*x
17+42*x-3*x^2
f=3+3*x+3*x^2+3*x^3+2*x^4+2*x^5+2*x^6+2*x^7+3*x^8
real 1m36,970s
user 15m42,763s
sys 0m0,501s
This causes the unit test to fail due to timeout. When reducing the number of threads to the number of free cores, it's fast again:
alex@lily:~/build/cado-nfs/normal> OMP_NUM_THREADS=10 time /home/alex/build/cado-nfs/normal/tests/utils/test_mpz_poly
Using random seed=1714768868
0
17
17+42*x
17+42*x-3*x^2
f=3+3*x+3*x^2+3*x^3+2*x^4+2*x^5+2*x^6+2*x^7+3*x^8
0.87user 0.09system 0:00.70elapsed 139%CPU (0avgtext+0avgdata 6272maxresident)k
0inputs+0outputs (0major+524minor)pagefaults 0swaps
I have not looked into what causes this at all.