[pypy-commit] extradoc extradoc: Blatantly copy EP handson

fijal noreply at buildbot.pypy.org
Thu Jun 30 11:05:25 CEST 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: extradoc
Changeset: r3811:38badf0312fd
Date: 2011-06-30 11:12 +0200
http://bitbucket.org/pypy/extradoc/changeset/38badf0312fd/

Log:	Blatantly copy EP handson

diff --git a/talk/ctpug2011/Makefile b/talk/ctpug2011/Makefile
new file mode 100644
--- /dev/null
+++ b/talk/ctpug2011/Makefile
@@ -0,0 +1,26 @@
+# 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 title.latex stylesheet.latex
+	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
+
+teaser.pdf: teaser.rst author.latex title.latex stylesheet.latex
+	rst2beamer.py --stylesheet=stylesheet.latex --documentoptions=14pt teaser.rst teaser.latex || exit
+	sed 's/\\date{}/\\input{author.latex}/' -i teaser.latex || exit
+	sed 's/\\maketitle/\\input{title.latex}/' -i teaser.latex || exit
+	pdflatex teaser.latex  || exit
+
+view: talk.pdf
+	evince talk.pdf &
+
+clean:
+	rm -f talk.pdf talk.pdf.info talk.aux talk.log talk.nav talk.out talk.snm talk.toc talk.vrb talk.latex
+
+xpdf: talk.pdf
+	xpdf talk.pdf &
diff --git a/talk/ctpug2011/author.latex b/talk/ctpug2011/author.latex
new file mode 100644
--- /dev/null
+++ b/talk/ctpug2011/author.latex
@@ -0,0 +1,8 @@
+\definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0}
+
+\title[PyPy training session]{PyPy training session}
+\author[antocuni, arigo]
+{Antonio Cuni \\ Armin Rigo}
+
+\institute{EuroPython 2011}
+\date{June 20 2011}
diff --git a/talk/ctpug2011/beamerdefs.txt b/talk/ctpug2011/beamerdefs.txt
new file mode 100644
--- /dev/null
+++ b/talk/ctpug2011/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/ctpug2011/stylesheet.latex b/talk/ctpug2011/stylesheet.latex
new file mode 100644
--- /dev/null
+++ b/talk/ctpug2011/stylesheet.latex
@@ -0,0 +1,12 @@
+\usepackage{ulem}
+\usetheme{Boadilla}
+\usecolortheme{whale}
+\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/ctpug2011/talk.rst b/talk/ctpug2011/talk.rst
new file mode 100644
--- /dev/null
+++ b/talk/ctpug2011/talk.rst
@@ -0,0 +1,216 @@
+.. include:: beamerdefs.txt
+
+================================
+PyPy training session
+================================
+
+PyPy training session
+---------------------
+
+- Part 1: Run your application under PyPy
+
+- Part 2: Write your own interpreter with PyPy
+
+
+Part 1
+------
+
+* Run your application under PyPy
+
+
+How to run PyPy
+----------------
+
+* ``pypy program.py``
+
+* That's it!
+
+  - (modulo details)
+
+Challenge
+---------
+
+* ``html_fibo.py``
+
+* HTML list of fibonacci numbers
+
+* (the most complicate ever)
+
+* run it on CPython
+
+* run it on PyPy
+
+* fix it!
+
+
+Refcounting vs generational GC (1)
+----------------------------------
+
+|scriptsize|
+|example<| |scriptsize| ``gc0.py`` |end_scriptsize| |>|
+
+.. sourcecode:: python
+
+   def foo():
+       f = file('/tmp/bar.txt', 'w')
+       f.write('hello world')
+
+   foo()
+   print file('/tmp/bar.txt').read()
+
+|end_example|
+
+|pause|
+|example<| |scriptsize| ``gc1.py`` |end_scriptsize| |>|
+
+.. sourcecode:: python
+
+   def foo():
+       f = file('/tmp/bar.txt', 'w')
+       f.write('hello world')
+       f.close() # <-------
+
+|end_example|
+
+|pause|
+|example<| |scriptsize| ``gc2.py`` |end_scriptsize| |>|
+
+.. sourcecode:: python
+
+   def foo():
+       with file('/tmp/bar.txt', 'w') as f:
+           f.write('hello world')
+
+|end_example|
+|end_scriptsize|
+
+
+Refcounting vs generational GC (2)
+----------------------------------
+
+* ``__del__``
+
+  - especially files or sockets
+
+  - don't leak file descriptors!
+
+* weakrefs
+
+* ``finally`` inside generators
+
+
+
+Just-in-Time Compilation
+------------------------
+
+* Tracing JIT, like TraceMonkey
+
+* Complete by construction
+
+* Supports Intel x86, amd64, and soon ARM
+
+
+Short introduction to JITting
+-----------------------------
+
+* run code with the interpreter
+
+* observe what it does
+
+* generate optimized machine code for commonly executed paths
+
+* using runtime knowledge (types, paths taken)
+
+Tracing JIT
+-----------
+
+* compiles one loop at a time
+
+* generates linear code paths, recording what the interpreter did
+
+* for each possible branch, generate a guard, that exits assembler on triggering
+
+* if guard fails often enough, start tracing from the failure
+
+Meta-Tracing in PyPy
+--------------------
+
+* The explanation above assumes a tracing JIT for the full Python
+  language
+
+* Would need to be maintained whenever we change the Python version we
+  support
+
+* Instead, we have a "meta-tracing JIT"
+
+* A very important point for us since we don't have a huge team
+  to implement all Python semantics for the JIT
+
+* We trace the python interpreter's main loop (running N times) interpreting
+  a python loop (running once)
+
+
+PYPYLOG
+--------
+
+|small|
+
+* ``PYPYLOG=categories:logfile pypy program.py``
+
+|end_small|
+
+* categories:
+
+  - gc-minor, gc-major
+
+  - jit-log-noopt, jit-log-opt
+
+  - jit-backend
+
+  - jit-backend-counts
+
+
+Inspecting the JIT log
+-----------------------
+
+|scriptsize|
+|example<| |scriptsize| ``count.py`` |end_scriptsize| |>|
+
+.. sourcecode:: python
+
+    def count_mult_of_5(N):
+        mult = 0
+        not_mult = 0
+        for i in range(N):
+            if i % 5 == 0:
+                mult += 1
+            else:
+                not_mult += 1
+        return mult, not_mult
+
+|end_example|
+|end_scriptsize|
+
+|small|
+
+* ``PYPYLOG=jit-log-opt:mylog pypy count.py 2000``
+
+* ``PYPYLOG=jit-log-opt:mylog pypy count.py 10000``
+
+|end_small|
+
+
+The jitviewer
+-------------
+
+|scriptsize|
+
+* ``PYPYLOG=jit-log-opt,jit-backend-counts:mylog pypy count.py 2000``
+
+* ``PYPYLOG=jit-log-opt,jit-backend-counts:mylog pypy count.py 10000``
+
+* ``jitviewer.py log.pypylog``
+
+* Look at the (missing) bridge!
+
+|end_scriptsize|
diff --git a/talk/ctpug2011/title.latex b/talk/ctpug2011/title.latex
new file mode 100644
--- /dev/null
+++ b/talk/ctpug2011/title.latex
@@ -0,0 +1,5 @@
+\begin{titlepage}
+\begin{figure}[h]
+\includegraphics[width=60px]{../img/py-web-new.png}
+\end{figure}
+\end{titlepage}


More information about the pypy-commit mailing list