Repository navigation
Enable decimal benchmarks in the suite (MANIFEST) - #491
skirpichev wants to merge 3 commits into
Conversation
They were not added here in python#341 for no reasons. Tune bench_decimal_factorial() to support pure-Python decimal module on PyPy. See also python/cpython#155198. Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Closes python#473
StanFromIreland
left a comment
There was a problem hiding this comment.
decimal_factorial now runs two different workloads under one name, 10000! and 100000! at MAX_PREC with _decimal, but 1000! and 5000! at prec = 20000 without it, so results from CPython and PyPy (or a CPython built without _decimal) aren't comparable and nothing in the output says which one ran.
Fair enough. Here the whole picture. Without the patch for python/cpython#140036 we can't just set context's prec to MAX_PREC on pure-Python module. Instead we should set it to something "big enough". For 100000 it will be: >>> from mpmath import log10, fac
>>> from mpmath import log10, fac, ceil
>>> ceil(log10(fac(100000)))
mpf('456574.0')And with such explicit big settings for prec - computations are very slow. E.g. for prec=50000 on my system it's around 81sec. For 10x prec it will be ~hour (I canceled run after several minutes). But with the patch (and prec = MAX_PREC) I've on CPython: >>> start_calc = time.time(); x = factorial(P.Decimal(10000), 0); end_calc = time.time(); end_calc - start_calc
13.344191074371338
>>> start_calc = time.time(); x = factorial(C.Decimal(10000), 0); end_calc = time.time(); end_calc - start_calc
0.5661253929138184
>>> start_calc = time.time(); x = factorial(C.Decimal(100000), 0); end_calc = time.time(); end_calc - start_calc
4.615884304046631
>>> start_calc = time.time(); x = factorial(P.Decimal(100000), 0); end_calc = time.time(); end_calc - start_calc
128.01505613327026And with the patch on the latest PyPy3.12: >>>> start_calc = time.time(); x = factorial(P.Decimal(1000), 0); end_calc = time.time(); end_calc - start_calc
0.6504781246185303
>>>> start_calc = time.time(); x = factorial(P.Decimal(10000), 0); end_calc = time.time(); end_calc - start_calc
1.0633630752563477
>>>> start_calc = time.time(); x = factorial(P.Decimal(100000), 0); end_calc = time.time(); end_calc - start_calc
5.9123358726501465I think we should convince PyPy people to apply the patch. Then make settings same for all implementations (C and pure-Python): Or we can treat python/cpython#140036 as a security issue... Though, it would be a very liberal interpretation. |
|
The fix for python/cpython#140036 won't be picked up by PyPy's stdlib sync. Could you open a PR with the CC @mattip |
Also drop all custom settings for pure-Python module.
They were not added here in #341 for no reasons.
Tune bench_decimal_factorial() to support pure-Python decimal module on PyPy. See also python/cpython#155198.
Co-authored-by: Hugo van Kemenade 1324225+hugovk@users.noreply.github.com
Closes #473
// N.B.: this is essentially a rebirth of #453.