Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinPython 64 bit with PyPy #966

Open
15 of 17 tasks
stonebig opened this issue Apr 19, 2021 · 33 comments
Open
15 of 17 tasks

WinPython 64 bit with PyPy #966

stonebig opened this issue Apr 19, 2021 · 33 comments

Comments

@stonebig
Copy link
Contributor

@stonebig stonebig commented Apr 19, 2021

To celebrate the arrival of PyPy on Windows 64 bit, Let see if we can build a WinPython with PyPy.

Interception course with cPython:

  • interesting spot is: PyPy + VSCode + Jupyterlab + Cython + HPy , on 64 bit, maybe pyside6-6.1
  • WinPython 2021-03: PyPy-7.3.5 for Python3.7+ VSCode + Jupyterlab + Cython, on 64 bit only
  • WinPython 2021-04: Matplotlib-3.5.0 + PySide-6.1 + HPy and performances fixes
  • WinPython 2021-05: PyPy for Python-3.8, beta seems coming this summer 2021
  • WinPython 2022-02: PyPy for Python-3.9
  • WinPython 2022-04: PyPy for Python-3.10
  • WinPython 2023-02: PyPy for Python-3.11

so far:

  • WinPython 'dot' version; Yes but missing WPPM GUI (the Qt Problem)
  • SQLite_bro : Yes but slightly different behavior, 6x slower
  • VScode without Jupyter: ... works by updating VSCode settings per menu, to tell where pypy3.exe is
  • SQLite_bro-0.9.2 fixes PyPy compatibility
  • a small Speed-Center table (below)
  • Adapt Build System to automate PyPy builds like the cPython builds
  • SQLite-3.35.5 in PyPy-7.3.5rc1 (becoming level with CPython)
  • Numpy, Matplotlib, Pandas, scikit-learn
  • Pywinpty
  • a cython wheel (but compiling to cython slows things 2.5x, currently)
  • statsmodels (after statsmodels made a compatibility patch)
  • pyzmq fix (per Christoph Gohlke)
  • Jupyter compatibility (since May 25th morning ... to integrate in a release)

Roadblocks or Hacks :

  • Qt Stack: needs
    • COMPATIBLE PySide6-6.1 with PyPy,
    • COMPATIBLE Matplotlib-3.5.0 with PySide6-6.1 (end october june ?)

Other:

Speed-Center:

speed test (seconds) Cpython-3.9 Pypy-7.3.5 3.7.10 PyPy-7.3.6 3.8.10 nightly comment
SQLite_bro 13 85 35 seems linked to 'import' not being cached , but now SQLite-3.35.0 with math functions included, and PyPy-7.3.6 will cache imports (200x speed-up, but apparently no effect)
sudoku_norvig_for_comparison_of_complexity.py 0.09 0.51
sudoku_norvig_for_comparison_of_complexity.py (hard1) 89 42 65 python-3.10a7 = 89s, numba can't, cython = 47s
speed_basic.py (code below or there) 25.5 0.27
pyconumpy the microbench to prove or not that Pypy is a scientific option (should become good with HPy)

the Nbody experiment became good in PyPy with type freezing
at CGO ’20, February 22–26, 2020, San Diego, CA, USA

Climate Impact
image

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Apr 19, 2021

build a0 (2021-04-19 'PyPy')

WinPython-3.7.10.0a0 with PyPy-3.7 v7.4.3

What shall work:

  • IDLE,
  • IDLEX,
  • WinPython Command Prompt,
  • WinPython Interpreter.exe,
  • WinPython Powershell Prompt
  • the scripts:
    • make_winpython_movable (by necessity of WinPython)
    • make_winpython_fix.bat
  • and so, it seems ... movable like any WinPython.

Areas of particular interest for testers::

  • well well, certainly lot of bugs and speed to discover,
  • help PyPy and WinPython project to iron them out
  • the fact that the demo page of SQLite_bro is not working exactly like for cpython is a first issue to dig

Next build a1:

  • SQLite3.35
  • patch SQLite_bro (L763) to avoid multi-empty tab / keep same effect (not sure it's a 'bug' of PyPy per say)
MD5 SHA-1 SHA-256 Binary Size
9bd25e501d70ceac13e3d14f7ff01673 947b16ccffb2299fe48b1b12ea70b03309015ad0 291cfc0837107be82a09a08444450ce63b4bb892603e1581bc3467d2dd73344a Winpython64-3.7.10.0dotpypya0.exe 25 063 625 Bytes

Included Package:

  • WinPython
  • sqlite_bro
  • pip-20.1.0dev

Location: https://sourceforge.net/projects/winpython/files/WinPython_3.7/3.7.10.0/alphas/

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Apr 20, 2021

speed measures

  • using sqlite_bro:
pydef py_sin(s):
    "sinus function : example loading module, handling input/output as strings"
    import math as py_math
    return ("%s" %  py_math.sin(s*1));
WITH RECURSIVE
  cnt(x) AS (
     SELECT 1
     UNION ALL
     SELECT x+1 FROM cnt
      LIMIT 3000000
  )

select sum(py_sin(x))  from cnt  

to get the same number of tabs we need to replace in SQLite_bro:
https://github.com/stonebig/sqlite_bro/blob/dcbbd810d0cea2be40c5c56d02e312be350a81dd/sqlite_bro/sqlite_bro.py#L739

if cur.description is not None:
per
if cur.description is not None and len(cur.description)>0: #pypy needs the second test

  • mandelbrot (when necessary wheels in place)

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Apr 20, 2021

VSCode does the sudoku with pypy3.7-v7.3.4-win64

  • echo %time% & pypy3 C:\WinP\bd37\budotpypy\wpy64-37100\notebooks\docs\Solvers_Raymond_Hettinger\python\sudoku_norvig_for_comparison_of_complexity.py
  • echo %time% & python C:\WinP\bd37\budotpypy\wpy64-37100\notebooks\docs\Solvers_Raymond_Hettinger\python\sudoku_norvig_for_comparison_of_complexity.py

image

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Apr 20, 2021

speed_basic.py test

  • echo %time% & pypy3 C:\WinP\bd37\budotpypy\wpy64-37100\notebooks\speed_basic.py
  • echo %time% & python C:\WinP\bd37\budotpypy\wpy64-37100\notebooks\speed_basic.py
import time

start_time = time.time()

total = 0
for i in range(1, 10000):
    for j in range(1, 10000):
        total += i + j

print(f"The result is {total}")

end_time = time.time()
print(f"It took {end_time-start_time:.2f} seconds to compute")

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Apr 20, 2021

PyPy build a1 (2021-04-20 'SQLite-0.35.5')

change from build a0:

  • SQLite-0.35.5 (math functions included)
  • sqlite-bro-0.9.2 fixes to become compatible with PyPy
  • a few clean-ups

Areas of particular interest for testers:

  • sqlite_bro-0.9.2 is much more compatible with PyPy (fullly ?)
  • well:
    • the pleasure of discovering the mythical PyPy 'JIT' Python
    • contributing bug hunting and fixing in PyPy for Windows

Next build a2:

  • modify build system, so it's no more manual work
  • wait the 64bit binary wheel problem is solved (so PyPy 7.3.5, expected in two weeks)
  • hope is PyPy 7.3.5 will include:
    • the windows 64 bit wheel naming problem fix,
    • SQLite-0.35.5 with math and json functions activated, (or may patch)
    • with a strech of luck, the 'import' performance fix. (not expected)
MD5 SHA-1 SHA-256 Binary Size
338cdc161b2bc091a9f2184621681860 81e5d38c1ccc90746ad089ce975d1cc3e834a76d 52c207f2916399a3f222b9d0b87e80f7ccf5cdcbf2a9ba40d08746b173394026 Winpython64-3.7.10.0dotpypya1.exe 25 034 421 Bytes

Included Package:

  • WinPython
  • sqlite_bro-0.9.2
  • pip-20.1.0dev

Location: https://sourceforge.net/projects/winpython/files/WinPython_3.7/3.7.10.0/alphas/

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Apr 24, 2021

PyPy build a2 (2021-04-24 'automated build')

Change from build a1:

  • Infrastructure work:
    • standard automation ... and so back to the old SQLite shipped per PyPy-7.3.4
    • sha3-256 added
    • unchecked; "associate" function, or future Qt integration

Location: https://sourceforge.net/projects/winpython/files/WinPython_3.7/3.7.10.0/alphas/

Areas of particular interest for testers:

  • it works as any other WinPython, except you must type "pypy3" instead of python
  • for experts knowing what they do:
    • check the associate function, (Winpython in the windows menu)
    • look ahead on Qt integration.
MD5 SHA-1 SHA-256 Binary Size SHA3-256
a657d064fb851af79863a0deb72627b6 586ddbddf7953fb6325eb58c87acaefbb54fd93e e4b007158c382308806785ca9fcab2699e3dd166917a4f256e3ed674812ae767 Winpython64-3.7.10.0dotPyPya2.exe 24 470 818 Bytes d43b68240b527c35d2c86f65e96542d83c977bc229780ecb207ac7e74fda720b

WinPython 3.7.10.0dotPyPy

The following packages are included in WinPython-64bit v3.7.10.0dotPyPy a2.

Tools

Name Version Description

Python packages

Name Version Description
Python 3.7.10 Python programming language with standard library
cffi 1.14.5 Foreign Function Interface for Python calling C code.
greenlet 0.4.13 Lightweight in-process concurrent programming
pip 21.1 The PyPA recommended tool for installing Python packages.
readline 6.2.4.1
setuptools 56.0.0 Easily download, build, install, upgrade, and uninstall Python packages
sqlite_bro 0.9.2 a graphic SQLite Client in 1 Python file
wheel 0.36.2 A built-package format for Python
winpython 4.2.20210422 WinPython distribution tools, including WPPM

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented May 8, 2021

looking at Cython CI, it seems Pypy-3.7 is (8m 10 s/ 5m 18s) 35% slower than Python-3.7 on this exercise ... room for improvement

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented May 22, 2021

cython source wheel is compatible with PyPy, on more package, but fails to compile statsmodels extensions. so flight domain is currently constrained per:

  • jupyter_core needing pywin32
  • failing to build wheels for statsmodels, pywinpty
  • pyside6 wheel (on the road from Qt, but not there).

on PyPy3 side:

  • "import package speed-up" is only coming for 7.3.6, (to check if performance with sqlite test improves widely)
  • hpy talk or article at pycon 2021 is not yet available.
  • python-3.8 compat is slow to come

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented May 23, 2021

may 23rd morning status;

  • works: numpy, matplotlib, pandas, seaborn, scipy, lmfit, cython, sympy, holoviews, bokeh
  • packages : 408 included (working well or not) out of 520
  • last night improvement:
    • wheels for statsmodels, pywinpty provided per cgohlke, but statsmodels has a practice incompatible with PyPy3 statsmodels/statsmodels#7460)
    • switch to a fresher numpy+mkl solved the "import pandas" (was old) issue

Flight domain is currently constrained per:

  • "Jupyter":
    • PROBLEM NARROWED: jupyter_core needing pywin32 => cgohlke did "empty" pywin32 wheel, suggests a solution is easy to replace the 3 missing functions.
    • PyPy3 is missing a python-3.5 (windows) change: https://foss.heptapod.net/pypy/pypy/-/issues/3469
  • "science":
  • "Qt":
    • pyside6 wheel on the alpha road from Qt Company, but not there yet.
  • "Deep Learning":
    • out of scope for now, need to have the rest flying.

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented May 24, 2021

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented May 25, 2021

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Jun 5, 2021

Flight domain is currently constrained per:

  • in "Jupyter":
    • shapely: in need for a few geograhic packages cartopy and ipyleaflet
    • orjson: missing to ipycanvas
  • "science":
  • "Deep Learning":
    • out of scope for now, need to have the rest flying.
  • "Qt": no PySide6-6.1 yet

@stonebig stonebig mentioned this issue Jun 6, 2021
6 tasks
@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Jun 6, 2021

milestone 1 "credibility" is now reached "WinPython 2021-03: PyPy-7.3.5 for Python3.7+ VSCode + Jupyterlab + Cython, on 64 bit only".

Next milestone 2 is about more natural "performance" vs cPython (as PyPy can perform, but you need often to tweak your code)

@DStauffman
Copy link

@DStauffman DStauffman commented Jun 10, 2021

Hey @stonebig, what's the best place to report errors on these builds? Is it to the individual libraries? I can get matplotlib to crash the interpreter with the following script. It works with cPython but not Pypy. Changing the backend to Agg instead of the default TkAgg also works. I usually use Qt5Agg and plan to use that once Qt is integrated in.

"""Pypy crashes on plot closure."""

import unittest

#import matplotlib
#matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np

class Test_plots(unittest.TestCase):
    def setUp(self):
        self.x = np.arange(5)
        self.y = 10 * self.x
        self.figs = None

    def test_plotting1(self):
        fig = plt.figure()
        plt.plot(self.x, self.y)
        fig2 = plt.figure()
        plt.plot(self.y, self.x)
        self.figs = [fig, fig2]

    def test_plotting2(self):
        fig = plt.figure()
        plt.plot(self.x, self.y)
        fig2 = plt.figure()
        plt.plot(self.y, self.x)
        self.figs = [fig, fig2]

    def tearDown(self):
        if self.figs is not None:
            for fig in self.figs:
                plt.close(fig)

if __name__ == '__main__':
    unittest.main(exit=False)

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Jun 11, 2021

You may report ithe problem on pypy with the code and crash report, asking if it's a pypy bug, a way of writing not tolerated per pypy, or an incompatibility from matplotlib or tk

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Jun 11, 2021

Do it also on stackoverflow

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Jun 12, 2021

hum, launched this way, it doesn't blow up with Winpython64-3.7.10.0PyPycodb4.exe

image

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Jun 12, 2021

this way:
image

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Jun 12, 2021

Updated Flight domain seems now currently constrained per:

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Jun 19, 2021

Updated Flight domain (13% not possible packages) seems now currently constrained per:

  • in "Jupyter":
    • a pyproj binary compatibility bug ??
  • "science":
    • numba: forecast is it will remain missing till the python-3.11 (june 2022 ?)
    • pyside6 wheel on the alpha road from Qt Company, guess it will need PyPy-3.8 (sept 2021 ?)
    • solvers may need a pure python version: ecos, qldl, qpsolvers, pycosat, cvxopt , osqp, nlopt
  • "Deep Learning":
    • out of scope for now, need PyPy to have the rest flying, ep numba. (dec 2022 ?)
  • Cpython eco-system compatibility:
    • Python-3.8 compatibility to get type-ast, mypy, (alpha around september)
  • VSCode-python better compatiblity, as not super friendly with pypy3 per default

Performance (-10x to 30x) is constrained per:

  • PyPy3 team slowly removing performance problems on standard python code. Next improvement = PyPy-7.3.6 (sept 2022)
  • asking cpython library to not force systematically Cython or C-packages (like ipycanvas not forcing orjson anymore).
  • hpy Cython compatibility to get same performance

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Aug 3, 2021

Update of PyPy progress, testing on PyPy3-3.8 nightly of July 29th:

  • MyPy is working, if you comment the gc.set_threshold() line (purely non-functional, used to gain 4% on cPython)
  • Black is installable, because MyPy is now installable.
  • the Sqlite test is performed in 30 seconds in PyPy3-3.8 vs 85 seconds in PyPy-7.3.6 and 13 seconds in cPython (suspecting the "import" caching improvement backported from cPython3 code)

image

... not bad

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Aug 12, 2021

PyPy Nightly for Python3.8 build a0 (2021-08-12, from PyPy3-3.8 nightly of July 29th:)

Infrastructure work:

MD5 SHA-1 SHA-256 Binary Size SHA3-256
78dad874bee910c74b78fe3692d99a1d be2defd71f6da7fde270ebee3f56813b1469ee84 6fad49119e0f7753318239c7671388f450bac58d20d6cd21686ffbabda7e9cd9 Winpython64-3.8.10.0dotPyPyNighta0.exe 26 623 538 Bytes 3c5aaa75da5f3d491ee9a57112cbcdba678286b3ceb2b49c52c4de3cbf710ef6

next step:

  • correct release version (.1 vs .0)
  • integrate an msvc_runtime
  • push on the interesting new bits:
    • mypy
    • ...

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Aug 28, 2021

Flight domain, as of August 28th, is currently constrained per:

... a little late to 'dreamed' roadmap speed, but momentum is growing

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Aug 29, 2021

Speed-Center: (2021-12-04 version of PyPy 3.8)

speed test (seconds) Cpython-3.9 Pypy-7.3.6 3.7.12 PyPy-7.3.6 3.8.12 PyPy-7.3.8rc2 3.8.12 cPython-3.11a3 comment
SQLite_bro 13 28 28 32 12
sudoku_norvig_for_comparison_of_complexity.py 0.09 0.46 0.56 0.47 cpython-3.11.0a2 slow to start ??
sudoku_norvig_for_comparison_of_complexity.py (hard1) 89 42 50 45 89 numba can't, cython = 47s
speed_basic.py (code below or there) 25.5 0.27 0.27 27
pyconumpy the microbench to prove or not that Pypy is a scientific option (should become good with HPy)

the Nbody experiment became good in PyPy with type freezing
at CGO ’20, February 22–26, 2020, San Diego, CA, USA

Sqlite_Bro test: performance of 'import' and SQlite interactions

measures PyPy internal weaknesses reduction like 'import' not being cached
run this in interactive sqlite_bro

pydef py_sin(s):
    "sinus function : example loading module, handling input/output as strings"
    import math as py_math
    return ("%s" %  py_math.sin(s*1));
WITH RECURSIVE
  cnt(x) AS (
     SELECT 1
     UNION ALL
     SELECT x+1 FROM cnt
      LIMIT 3000000
  )

select sum(py_sin(x))  from cnt 

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Aug 29, 2021

PyPy Nightly for Python3.8 build a0b (2021-08-28, from PyPy3-3.8 nightly of August 28th:)

Changes from Winpython64-3.8.10.0dotPyPyNighta0.exe :

  • Infrastructure:
    • adds msvc_runtime
    • PyPy nightly version:
     Python 3.8.10 (3e3aadd1e1d0, Aug 28 2021, 00:05:42)
[PyPy 7.3.6-alpha0 with MSC v.1929 64 bit (AMD64)] on win32
  • PyPy nightly has corrected nearly all its Tcl/tk bugs,
  • latest version has:
    • a further 20% speed-up in SQlite test, now only 2x slower than cpython vs 6x slower on 3.7
    • still a 20% regression sudoku_norvig_for_comparison_of_complexity.py (hard1)
MD5 SHA-1 SHA-256 Binary Size SHA3-256
4c057a6df3fe3e818cd507b5a01c9c1b bf0a29de1710247bd643e51669241e874405ade3 49c804921f110afdf8ea7961a00f591f79b70960dbeccc9c2666d6166cfa7cb5 Winpython64-3.8.10.0dotPyPyNighta0b.exe 27 356 866 Bytes 1f0218b9ff05c15d8224e036f188f5aeafe805e640920895ceec4de836f1cb6d

next step:

  • gently push on the apparent speed regression test of PyPy 3.8 nightly
  • check for Qt compatibility for PyPy

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Sep 3, 2021

PyPy v7.3.6 rc is very soon (unless waiting for Hpy-0.0.3)
https://foss.heptapod.net/pypy/pypy/-/blob/eed30f5374249b5652278e3b3b83de694b693712/pypy/doc/release-v7.3.6.rst

Pythonnet is waiting Hpy to mature to do the compatibility effort pythonnet/pythonnet#330 (comment)

image

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Sep 18, 2021

2021-09-18 news:

  • down to 60 missing packages (11%):
    • 15 related to Qt (but ctismer of Qt/PySide, and stackless pope, working hard on it)
    • 5 needing PyPy-3.8 (mypy, black, ...)

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Nov 6, 2021

testing cpython-3.11.0a2: not yet a truly visible speed-up at first try.

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Nov 14, 2021

testing Pyjion: not yet a truly visible speed-up at first try on the sudoku example.

on "elegant classic" code, for now:

  • PyPy gets the same 2x speed-up as cython,
  • the other fail to improve anything

Educated guess is:

  • working hard on JIT only is not enough to solve the Python "slowness" on executing existing code,
  • a minuscule touch on the code should bring a 5x larger improvement,
  • designing both JIT improvement and a PEP-JIT-performance-enabler-touch should result on:
    • 2x less heroic effort on JIT,
    • 10x better performance result,
    • no split in the community on what that "minuscule" changes shall be, so we have a "Tweaked Classic Elegant" way to write Fast Python Code, and preferably only one.

Something like the data API standard but for JIT ?

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Dec 11, 2021

december 11th news:

  • cpython-3.11.0a3 improves and goes up to cpython-3.9.0 speed on old PC, claim is 19% speed-up (halfway to 50% target), if you knon how to read https://speed.python.org/
  • the same shall be true for Pyjion-1.2.1
MD5 SHA-1 SHA-256 Binary Size SHA3-256
1b80723ab8c70552c689a7b5e4235662 2e1208020fffa1c48114c571064bdbdc34fbaa19 0675eef00402739fdc85fe167bdfd4f9f061ad50e81a50a4d36640f1d3b5b1c6 Winpython64-3.11.0.0dota3.exe 27 581 528 Bytes 02f59662be5e9c464dc25b593cdad8a53420aa1fde6c1b62e4c744eb26d39aef

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Jan 2, 2022

January 2nd:

  • new in PyPy-3.8: opencv, mypy, papermill, ... maybe numpy-1.22.0
  • still missing from PyPy-3.7: osqp, gdal, pandas-1.4

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Jan 22, 2022

January 22nd:

  • new in PyPy-3.8: pandas-1.3.5 with fix, gdal, osqp

@stonebig
Copy link
Contributor Author

@stonebig stonebig commented Feb 27, 2022

February 27th, 2022:

  • PyPy-3.8-7.3.8 with Python-3.8 official compatibility
  • Python-3.9-7.3.8 beta, seems on track for a Q2 official release (moving from 3.7 to 3.9 in 1 year would be awesome)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants