On Sat, Nov 22, 2025 at 8:11 AM Michael Orlitzky <
mic...@orlitzky.com> wrote:
>
> On 2025-11-21 12:16:36, '
Tobia...@gmx.de' via sage-devel wrote:
> > I compared the execution times of the ubuntu vs macos runs (for the linked
> > PR, Python 3.12).
> >
> > In general, the tests take more or less the same time on macos as on ubuntu.
>
> Thanks, that's helpful.
>
>
> > Most of them seem to be related to curves / polyhedron. So perhaps its only
> > a certain db that is way slower to init/query on macos?
>
> There are others that don't fit this explanation though. For example,
>
> sage: x,y,z = SR.var('x,y,z')
> sage: [d] = solve_mod([5*x + y == 3, 2*x - 3*y == 9],
> 3*5*7*11*19*23*29,
> solution_dict = True)
On an Intel Mac, latest beta (10.8.beta9) Homebrew Python 3.13:
(Darwin xxxxxx.local 24.6.0 Darwin Kernel Version 24.6.0: Wed Oct 15
21:12:21 PDT 2025; root:xnu-11417.140.69.703.14~1/RELEASE_X86_64
x86_64)
%prun solve_mod([5*x + y == 3, 2*x - 3*y == 9], 3*5*7*11*19*23*29,
solution_dict = True)
9495 function calls (9365 primitive calls) in 13.489 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
2039 13.336 0.007 13.339 0.007 relation.py:1818(<genexpr>)
35 0.076 0.002 0.076 0.002 {built-in method
_functools.reduce}
14 0.042 0.003 0.121 0.009
expression_conversions.py:978(relation)
7 0.008 0.001 0.008 0.001
polynomial_ring_constructor.py:837(_multi_variate)
2 0.007 0.004 0.007 0.004 {method '__exit__' of
'sqlite3.Connection' objects}
7 0.004 0.001 13.457 1.922
relation.py:1734(_solve_mod_prime_power)
1 0.004 0.004 0.004 0.004 {method 'execute' of
'sqlite3.Connection' objects}
Thus, dog-slow symbolic ring "relation" code.
(profiles on a modern Intel CPU, Linux, look similar, but are just
50-100 times faster)
On M1 Mac Studio (machine hosted by William), latest beta (10.8.beta9)
Homebrew Python 3.13, it's almost as bad as on Intel
(Darwin studio.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14
11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000 arm64)
9632 function calls (9513 primitive calls) in 9.672 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
2039 9.565 0.005 9.566 0.005 relation.py:1818(<genexpr>)
35 0.054 0.002 0.054 0.002 {built-in method
_functools.reduce}
14 0.031 0.002 0.079 0.006
expression_conversions.py:978(relation)
112/14 0.007 0.000 0.086 0.006
expression_conversions.py:152(__call__)
2 0.005 0.003 0.005 0.003 {method '__exit__' of
'sqlite3.Connection' objects}
1 0.003 0.003 0.003 0.003 {method 'execute' of
'sqlite3.Connection' objects}
7 0.001 0.000 9.633 1.376
relation.py:1734(_solve_mod_prime_power)
> is consistently slow (~13 cpu seconds) on macOS, but takes ~1.3s on my
> slow CPU with an empty cache.
>
> In finite fields, there's
>
> sage: p = 141 * 2^141 + 1
> sage: S.<x> = GF(p)[]
> sage: f = S.irreducible_element(2)
> sage: k.<y> = S.quotient_ring(f)
> sage: k in Fields()
> True
> sage: k(2).sqrt(algorithm="cipolla")^2 == k(2)
> True
>
> that is consistently slower (~9s) on macOS than on my very slow CPU
> (~3s). A %prun of one of these tests on a machine where it's slow
> would hopefully identity the problem.
from the last example:
%prun k(2).sqrt(algorithm="cipolla")^2 == k(2)
122239 function calls (122238 primitive calls) in 9.261 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
307 4.847 0.016 9.157 0.030
polynomial_quotient_ring_element.py:385(__invert__)
614 4.260 0.007 4.264 0.007
multi_polynomial_sequence.py:213(PolynomialSequence)
7960 0.029 0.000 0.042 0.000
polynomial_ring.py:335(_element_constructor_)
4303 0.020 0.000 0.039 0.000
polynomial_quotient_ring_element.py:108(__init__)
Thus, dog-slow arithmetic in polynomial quotient rings.
Not much better on M1 Mac.
(roughly the same picture as in the previous example, i.e. a bit
faster, but not much)
HTH
Dima