Skip to content

Conversation

paugier
Copy link

@paugier paugier commented May 14, 2025

I updated the benchmarks, Makefiles, pyproject.toml and CI. I think such benchmarks are important to show the potential of HPy. They are not representative of most real life programs but the results are strongly dependent of the efficiency of C calls and using in Python native objects defined in C extensions.

So I think this would be useful to merge this in the default branch (hpy).

Locally, I was able to build, install, test and run benchmarks with CPython, PyPy and GraalPy. (However, I didn't try to run the full benchmarks using Pythran in GraalPy).

This is now very simple for anyone to reproduce these benchmarks, without direct calls to setup.py which are deprecated.

The results can be summarized as (data from the CI):

{'cache_tag': 'cpython-312',
 'version': sys.version_info(major=3, minor=12, micro=10, releaselevel='final', serial=0)}
hostname: fv-az1112-292
Julia                      :     1 * norm = 0.015 s
PicoNumpy (CPython C-API)  :  10.2 * norm
PicoNumpy (HPy CPy ABI)    :  11.6 * norm
PicoNumpy (HPy Universal)  :    12 * norm
Transonic-Pythran          : 0.874 * norm
Numpy                      :  36.6 * norm
PicoNumpy (purepy)         :  33.3 * norm
PicoNumpy (purepy_array)   :  49.8 * norm
PicoNumpy (Cython)         :  38.3 * norm
{'cache_tag': 'pypy311',
 'version': sys.pypy_version_info(major=7, minor=3, micro=19, releaselevel='final', serial=0)}
hostname: fv-az1112-292
Julia                      :     1 * norm = 0.015 s
PicoNumpy (CPython C-API)  :  36.9 * norm
PicoNumpy (HPy Universal)  :  41.6 * norm
Transonic-Pythran          :   1.6 * norm
Numpy                      :   179 * norm
PicoNumpy (purepy)         :  3.59 * norm
PicoNumpy (purepy_array)   :  10.1 * norm
PicoNumpy (Cython)         :   297 * norm

The main negative point is that the results with HPy Universal are bad on PyPy (and even worse on GraalPy).

To convince people that it is useful to invest on HPy, we'd need to improve this, and PyPy with HPy universal should be approximately as fast as CPython with its C API (a bit faster would of course be better but...).

Also, with CPython, PicoNumpy-HPy-CPy-ABI should be as fast as PicoNumpy-CPython-C-API, but we need to check if these two implementations of PicoNumpy as actually equivalent (PicoNumpy-CPython-C-API might be less safe).

I think I have few simple microbenchmarks showing some performance issues, in particular

I'm going to create separate issues on PyPy and GraalPy.

@paugier paugier force-pushed the microbench_loop_sum branch 2 times, most recently from 631d1d8 to 010d2ad Compare May 14, 2025 09:36
@paugier
Copy link
Author

paugier commented May 14, 2025

I added a description to this PR. Can anyone have a quick look? The changes are mostly about benchmarks and updates. The C code is not touched. I don't think a detailed review on the benchmark/profiling code is needed, since it is quite boring and harmless.

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

Successfully merging this pull request may close these issues.

1 participant