Code Monkey home page Code Monkey logo

mypyc-benchmarks's Introduction

mypyc benchmarks

This is a collection of mypyc benchmarks. They are intended to track performance of mypyc against interpreted CPython. They are also useful for validating that a mypyc enhancement results in a measurable performance improvement.

Some benchmarks are microbenchmarks that are only useful for finding big performance differences related to specific operations or language features. They don't reflect real-world performance.

Benchmark results

We have a service that automatically collects benchmark results for all mypyc and mypy commits:

Running benchmarks

Prerequisites:

  • Python 3.7 or later on Linux, macOS, or Windows
  • venv installed (python3-venv on Ubuntu)
  • mypyc in PATH
  • A working Python C development environment
  • A python environment with mypy test-requirements.txt installed

Display the names of available benchmarks using runbench.py --list:

$ python3 runbench.py --list
binary_trees
bytes_call (micro)
bytes_concat (micro)
bytes_format (micro)
bytes_indexing (micro)
...

Microbenchmarks are distinguished by (micro).

Run a benchmark using runbench.py --mypy-repo <dir> <name>:

$ python3 runbench.py --mypy-repo ~/src/mypy richards
...
running richards
......
interpreted: 0.190326s (avg of 6 iterations; stdev 1%)
compiled:    0.019284s (avg of 6 iterations; stdev 1.6%)

compiled is 9.870x faster

This runs the benchmark in both compiled and interpreted modes using the mypyc from the given mypy repository, and reports the relative performance.

Use runbench.py -c ... to only run the compiled benchmark.

Run a benchmark first using the mypy master branch and then your local branch to see how well your branch does relative to master.

Documentation

There is more information in the documentation.

mypyc-benchmarks's People

Contributors

a5rocks avatar chadrik avatar ichard26 avatar jukkal avatar pranavrajpal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mypyc-benchmarks's Issues

Benchmarking against other Python-related compilers

1st of all, congratulations for great design goals: compiling Python code as is much better than having non portable extensions.

The speedup in your benchmarks is really exciting. However, if you don't mind I think it would be nice to benchmark mypyc against other tools that intend to improve Python performance, like Pyrex, for instance.

Add mypy self check benchmark

Add benchmark that type checks mypy using mypy.

Try to make this work with earlier mypyc revisions so that we can generate some historical data as well.

Add easy to way to test differences between mypyc revisions

A common use is testing performance between two mypyc revisions (usually between master and a local branch). Add an easy, documented way to do this. Currently the workflow is optimized for testing between compiled and interpreted mode.

Migrate benchmark runner to a new machine

We run the benchmark suite once a day on a Linux desktop that I have running at home. It's pretty janky, since the CPU is from 2011 and it doesn't even have wired internet. I'm going to replace it with a new system with these features:

  • Intel NUC (small form-factor PC)
  • Core i5 laptop processor (11th gen)
  • 16 GB RAM (same amount as before)
  • Wired network (now possible since the small form factor makes placement flexible)

I expect that the relative performance of compiled code will be worse on the new system. The CPU is wider and has better branch prediction, among other things -- these should help interpreted code more. Still, I'd rather have "worse" results that better match current reality.

As a bonus it should consume much less power, which is nice since it's running 24/7.

Steps:

  • Stop daily benchmark cron job
  • Install latest updates to Ubuntu 20.04 (this may help with hardware compatibility)
  • Shut down old system
  • Install new system, move SSD to the new system
  • Do some manual testing to ensure that things basically work
  • Turn off turbo boost and hyperthreading (for more reliable timings)
  • Check that timings actually are reliable
  • Make sure auto updates are disabled
  • Implement scaling of old timings to avoid abrupt changes when we switch to the new system
  • Collect initial performance figures for the new system and make sure scaling works
  • Enable cron job
  • Monitor results for a while

Add scripts to automatically generate performance reports

For each new mypyc/mypy commit, run all benchmarks and collect the data in a repository. Generate reports based on the collected data that highlight changes in performance between mypyc versions.

Set up the scripts to be automatically run at least daily.

Add Enum benchmarks

We have some support for enums, and since they are a popular feature, we should have some (micro)benchmarks that use them.

Add microbenchmarks that call stdlib functions using keyword args

Currently non-native calls with keyword arguments are slow, but I don't think that we have many benchmarks that use these. Create a new benchmark focused on this use case, since it's a pretty important one and is probably a bottleneck. Call Python functions, C extension functions, Python classes, and extension type objects. It probably makes sense to split this into at least two separate benchmarks (for example, function vs type).

Add named tuple benchmarks

Named tuples are popular, at least in code that didn't initially target Python 3.7+ (dataclasses were added in 3.7), so we should have benchmarks that use them. Microbenchmarks are fine.

Perfomance with Numpy?

Does mypyc recognize numpy as a C-Compiled module or it falls back to regular python calls?

I know the docs say that Cython is better for numeric code, but I just wonder if mypyc can do this natively.

Add more realistic string benchmarks

String operations are common in Python code, but the current benchmarks don't use them much (other than some microbenchmarks). Add a string benchmark or two.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.