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

Allow for warmup in PEP659 #144

Open
tonybaloney opened this issue Nov 8, 2022 · 7 comments
Open

Allow for warmup in PEP659 #144

tonybaloney opened this issue Nov 8, 2022 · 7 comments

Comments

@tonybaloney
Copy link

PyPerf doesn't seem to account for PEP659's dynamic interpreter optimising the byte codes in the target function.

There is a condition for PyPy and GraalPython to run a warmup cycle, but not for Python 3.11+. I know PEP659 isn't a JIT, but functions which are heavily optimised will be unstable.

Can some flag be set to run a warmup cycle?

@vstinner
Copy link
Member

vstinner commented Nov 8, 2022

You can manually change the number of computed warmup values using --warmup command line option.

But yeah, it would be interesting to increase the number of warmups when running on CPython with specialized bytecode.

My latest attempt (which is now old) to automatically detect "changepoint" and decide when a benchmark "looks stable", to compute automatically the number of warmup values when running a benchmark with a JIT (PyPy): https://vstinner.readthedocs.io/pypy_warmups.html

@vstinner
Copy link
Member

vstinner commented Nov 8, 2022

I suggest you to always have a look at raw values: write results in a JSON file and then use "python -m pyperf dump" to see raw values. You can try to plot them.

Maybe a command can be added to "pyperf convert" to convert first values to warmup values. For example, replace 1 warmup 5 values to 3 warmups 3 values (ignore the first 3 values, instead of one).

@ericsnowcurrently
Copy link

You can try to plot them.

It would be awesome if pyperf basically did that for you, with a command that produced a plot that is easy to interpret. I know we want to keep pyperf as simple and straight-forward as possible, but it can be hard to set up this sort of graphing and to get the output right.

(This is just a thought. It isn't important enough to me to motivate me to do something about it. 😄)

@vstinner
Copy link
Member

vstinner commented Nov 8, 2022

For example, I wrote https://pyperf.readthedocs.io/en/latest/examples.html#hist-scipy-script example in the doc.

I don't want to add a dependency to matplotlib to pyperf.

@vstinner
Copy link
Member

vstinner commented Nov 8, 2022

And there is also https://pyperf.readthedocs.io/en/latest/examples.html#plot example in the doc.

Screenshot of this example on pyperf/tests/telco.json file:

Capture d’écran du 2022-11-08 16-43-36

@vstinner
Copy link
Member

vstinner commented Nov 8, 2022

plot.py usage:

$ python3 plot.py --help
usage: plot.py [-h] [-b BENCHMARK] [--split-runs] [--skip SKIP] [--warmups] [--run INDEX] filename

positional arguments:
  filename

options:
  -h, --help            show this help message and exit
  -b BENCHMARK, --benchmark BENCHMARK
  --split-runs
  --skip SKIP           skip first SKIP values
  --warmups
  --run INDEX           only render run number INDEX

You may want to play with the --skip option.

I wrote this example a long time ago, I'm not sure if it's still correct :-) Maybe it should be updated for the latest pyperf API.

@ericsnowcurrently
Copy link

Yeah, clear instructions (with example) in the docs is sufficient.

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

3 participants