Author: Antonio Cuni <[email protected]> Branch: extradoc Changeset: r5542:0e6f6ebd4d39 Date: 2015-07-17 15:46 +0200 http://bitbucket.org/pypy/extradoc/changeset/0e6f6ebd4d39/
Log: copy all the stuff needed to produce the pdf, expand the slides diff --git a/talk/ep2015/performance/Makefile b/talk/ep2015/performance/Makefile new file mode 100644 --- /dev/null +++ b/talk/ep2015/performance/Makefile @@ -0,0 +1,18 @@ +# you can find rst2beamer.py here: +# http://codespeak.net/svn/user/antocuni/bin/rst2beamer.py + +# WARNING: to work, it needs this patch for docutils +# https://sourceforge.net/tracker/?func=detail&atid=422032&aid=1459707&group_id=38414 + +talk.pdf: talk.rst author.latex stylesheet.latex + python `which rst2beamer.py` --stylesheet=stylesheet.latex --documentoptions=14pt talk.rst talk.latex || exit + #/home/antocuni/.virtualenvs/rst2beamer/bin/python `which rst2beamer.py` --stylesheet=stylesheet.latex --documentoptions=14pt talk.rst talk.latex || exit + sed 's/\\date{}/\\input{author.latex}/' -i talk.latex || exit + #sed 's/\\maketitle/\\input{title.latex}/' -i talk.latex || exit + pdflatex talk.latex || exit + +view: talk.pdf + evince talk.pdf & + +xpdf: talk.pdf + xpdf talk.pdf & diff --git a/talk/ep2015/performance/author.latex b/talk/ep2015/performance/author.latex new file mode 100644 --- /dev/null +++ b/talk/ep2015/performance/author.latex @@ -0,0 +1,8 @@ +\definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0} + +\title[Python and PyPy performance]{Python and PyPy performance\\(not) for dummies} +\author[antocuni,fijal] +{Antonio Cuni and Maciej Fijalkowski} + +\institute{EuroPython 2015} +\date{July 21, 2015} diff --git a/talk/ep2015/performance/beamerdefs.txt b/talk/ep2015/performance/beamerdefs.txt new file mode 100644 --- /dev/null +++ b/talk/ep2015/performance/beamerdefs.txt @@ -0,0 +1,108 @@ +.. colors +.. =========================== + +.. role:: green +.. role:: red + + +.. general useful commands +.. =========================== + +.. |pause| raw:: latex + + \pause + +.. |small| raw:: latex + + {\small + +.. |end_small| raw:: latex + + } + +.. |scriptsize| raw:: latex + + {\scriptsize + +.. |end_scriptsize| raw:: latex + + } + +.. |strike<| raw:: latex + + \sout{ + +.. closed bracket +.. =========================== + +.. |>| raw:: latex + + } + + +.. example block +.. =========================== + +.. |example<| raw:: latex + + \begin{exampleblock}{ + + +.. |end_example| raw:: latex + + \end{exampleblock} + + + +.. alert block +.. =========================== + +.. |alert<| raw:: latex + + \begin{alertblock}{ + + +.. |end_alert| raw:: latex + + \end{alertblock} + + + +.. columns +.. =========================== + +.. |column1| raw:: latex + + \begin{columns} + \begin{column}{0.45\textwidth} + +.. |column2| raw:: latex + + \end{column} + \begin{column}{0.45\textwidth} + + +.. |end_columns| raw:: latex + + \end{column} + \end{columns} + + + +.. |snake| image:: ../../img/py-web-new.png + :scale: 15% + + + +.. nested blocks +.. =========================== + +.. |nested| raw:: latex + + \begin{columns} + \begin{column}{0.85\textwidth} + +.. |end_nested| raw:: latex + + \end{column} + \end{columns} diff --git a/talk/ep2015/performance/jit-overview1.pdf b/talk/ep2015/performance/jit-overview1.pdf new file mode 100644 index 0000000000000000000000000000000000000000..6b511590edd06e9deb157eb02cecb7cf64c61926 GIT binary patch [cut] diff --git a/talk/ep2015/performance/jit-overview2.pdf b/talk/ep2015/performance/jit-overview2.pdf new file mode 100644 index 0000000000000000000000000000000000000000..c07d0e3948403a7c42951a65ba023311d4739ac8 GIT binary patch [cut] diff --git a/talk/ep2015/performance/jit-overview3.pdf b/talk/ep2015/performance/jit-overview3.pdf new file mode 100644 index 0000000000000000000000000000000000000000..277b2067bc2daf79f7696edaabd22614182e6bfa GIT binary patch [cut] diff --git a/talk/ep2015/performance/speed.png b/talk/ep2015/performance/speed.png new file mode 100644 index 0000000000000000000000000000000000000000..e980452b50ec2cd6bcc1787cb5596bf106ddcd99 GIT binary patch [cut] diff --git a/talk/ep2015/performance/stylesheet.latex b/talk/ep2015/performance/stylesheet.latex new file mode 100644 --- /dev/null +++ b/talk/ep2015/performance/stylesheet.latex @@ -0,0 +1,10 @@ +\usetheme{Boadilla} +\setbeamercovered{transparent} +\setbeamertemplate{navigation symbols}{} + +\definecolor{darkgreen}{rgb}{0, 0.5, 0.0} +\newcommand{\docutilsrolegreen}[1]{\color{darkgreen}#1\normalcolor} +\newcommand{\docutilsrolered}[1]{\color{red}#1\normalcolor} + +\newcommand{\green}[1]{\color{darkgreen}#1\normalcolor} +\newcommand{\red}[1]{\color{red}#1\normalcolor} diff --git a/talk/ep2015/performance/talk.rst b/talk/ep2015/performance/talk.rst --- a/talk/ep2015/performance/talk.rst +++ b/talk/ep2015/performance/talk.rst @@ -1,7 +1,237 @@ +.. include:: beamerdefs.txt +========================== Python & PyPy performance +========================== + +About us +--------- + +- PyPy core devs + +- ``pdb++``, ``fancycompleter``, ... + +- Consultant + +- http://baroquesoftware.com/ + + +About you +------------- + +- Target audience + +- Your Python program is slow + +- You want to make it fast(er) + + +Optimization for dummies ------------------------- +* Obligatory citation + + - *premature optimization is the root of all evil* (D. Knuth) + +* Pareto principle, or 80-20 rule + + - 80% of the time will be spent in 20% of the program + +* Two golden rules: + + 1. Identify the slow spots + + 2. Optimize them + + +This talk +---------------------------- + +* Two parts + + 1. PyPy as a tool to make Python faster + + 2. How to identify the slow spots + + + +Tools +------ + +- Endless list of tools/techniques to increment speed + +- C extension + +- Cython + +- numba + +- "performance tricks" + +- **PyPy** + + * We'll concentrate on it + + * WARNING: we wrote it, we are biased :) + + + +What is PyPy +--------------- + +- Alternative, fast Python implementation + +- Performance: JIT compiler, advanced GC + +- PyPy 2.6.0 (Python version 2.7.9) + +- Py3k as usual in progress (3.2.5 out, 3.3 in development) + +- http://pypy.org + +- EP Talks: + + * The GIL is dead: PyPy-STM + + (July 23, 16:45 by Armin Rigo) + + * PyPy ecosystem: CFFI, numpy, scipy, etc + + (July 24, 15:15 by Romain Guillebert) + + +Speed: 7x faster than CPython +------------------------------- + +.. image:: speed.png + :scale: 47% + + +The JIT +-------- + +.. image:: jit-overview1.pdf + :scale: 50% + + +The JIT +-------- + +.. image:: jit-overview2.pdf + :scale: 50% + + +The JIT +-------- + +.. image:: jit-overview3.pdf + :scale: 50% + + +JIT overview +------------- + +- Tracing JIT + + * detect and compile "hot" loops + + * (although not only loops) + +- **Specialization** + +- Precompute as much as possible + +- Constant propagation + +- Aggressive inlining + + +Specialization (1) +------------------- + +- ``obj.foo()`` + +- which code is executed? (SIMPLIFIED) + + * lookup ``foo`` in obj.__dict__ + + * lookup ``foo`` in obj.__class__ + + * lookup ``foo`` in obj.__bases__[0], etc. + + * finally, execute ``foo`` + +- without JIT, you need to do these steps again and again + +- Precompute the lookup? + + +Specialization (2) +-------------------- + +- pretend and assume that ``obj.__class__`` IS constant + + * "promotion" + +- guard + + * check our assumption: if it's false, bail out + +- now we can directly jump to ``foo`` code + + * ...unless ``foo`` is in ``obj.__dict__``: GUARD! + + * ...unless ``foo.__class__.__dict__`` changed: GUARD! + +- Too many guard failures? + + * Compile some more assembler! + +- guards are cheap + + * out-of-line guards even more + + +Specialization (3) +--------------------- + +- who decides what to promote/specialize for? + + * we, the PyPy devs :) + + * heuristics + +- instance attributes are never promoted + +- class attributes are promoted by default (with some exceptions) + +- module attributes (i.e., globals) as well + +- bytecode constants + + +Specialization trade-offs +-------------------------- + +- Too much specialization + + * guards fails often + + * explosion of assembler + +- Not enough specialization + + * inefficient code + + +Part 2 +------- + +* Measure performance + +* Identify problems + + What is performance? -------------------- _______________________________________________ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
