[pypy-commit] extradoc extradoc: Add my FOSDEM talk
rguillebert
noreply at buildbot.pypy.org
Sun Jan 26 01:00:40 CET 2014
Author: Romain Guillebert <romain.py at gmail.com>
Branch: extradoc
Changeset: r5141:1b90c0f4886c
Date: 2014-01-26 01:00 +0100
http://bitbucket.org/pypy/extradoc/changeset/1b90c0f4886c/
Log: Add my FOSDEM talk
diff --git a/talk/fosdem2014/pypy-jit/Makefile b/talk/fosdem2014/pypy-jit/Makefile
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2014/pypy-jit/Makefile
@@ -0,0 +1,16 @@
+# you can find rst2beamer.py and inkscapeslide.py here:
+# http://bitbucket.org/antocuni/env/src/619f486c4fad/bin/rst2beamer.py
+# http://bitbucket.org/antocuni/env/src/619f486c4fad/bin/inkscapeslide.py
+
+
+talk.pdf: talk.rst author.latex stylesheet.latex
+ rst2beamer.py --input-encoding=utf8 --output-encoding=utf8 --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 > /dev/null 2>&1 &
+
+xpdf: talk.pdf
+ xpdf talk.pdf &
diff --git a/talk/fosdem2014/pypy-jit/Speed.png b/talk/fosdem2014/pypy-jit/Speed.png
new file mode 100644
index 0000000000000000000000000000000000000000..796a1ed2ef8f48d701a54242e78694ac16a70762
GIT binary patch
[cut]
diff --git a/talk/fosdem2014/pypy-jit/author.latex b/talk/fosdem2014/pypy-jit/author.latex
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2014/pypy-jit/author.latex
@@ -0,0 +1,8 @@
+\definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0}
+
+\title[How PyPy makes your code run fast]{How PyPy makes your code run fast}
+\author[rguillebert]
+{Romain Guillebert}
+
+\institute{FOSDEM}
+\date{February 2nd, 2014}
diff --git a/talk/fosdem2014/pypy-jit/beamerdefs.txt b/talk/fosdem2014/pypy-jit/beamerdefs.txt
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2014/pypy-jit/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/fosdem2014/pypy-jit/rst2beamer.py b/talk/fosdem2014/pypy-jit/rst2beamer.py
new file mode 100755
--- /dev/null
+++ b/talk/fosdem2014/pypy-jit/rst2beamer.py
@@ -0,0 +1,267 @@
+#!/usr/bin/env python
+# encoding: utf-8
+"""
+A docutils script converting restructured text into Beamer-flavoured LaTeX.
+
+Beamer is a LaTeX document class for presentations. Via this script, ReST can
+be used to prepare slides. It can be called::
+
+ rst2beamer.py infile.txt > outfile.tex
+
+where ``infile.tex`` contains the produced Beamer LaTeX.
+
+See <http:www.agapow.net/programming/python/rst2beamer> for more details.
+
+"""
+# TODO: modifications for handout sections?
+# TOOD: sections and subsections?
+# TODO: enable beamer themes?
+# TODO: convert document metadata to front page fields?
+# TODO: toc-conversion?
+# TODO: fix descriptions
+
+# Unless otherwise stated, created by P-M Agapow on 2007-08-21
+# and open for academic & non-commercial use and modification .
+
+__docformat__ = 'restructuredtext en'
+__author__ = "Paul-Michael Agapow <agapow at bbsrc.ac.uk>"
+__version__ = "0.2"
+
+
+### IMPORTS ###
+
+import locale
+from docutils.core import publish_cmdline, default_description
+from docutils.writers.latex2e import Writer as Latex2eWriter
+from docutils.writers.latex2e import LaTeXTranslator, DocumentClass
+from docutils import nodes
+
+## Syntax highlighting:
+
+"""
+ .. sourcecode:: python
+
+ My code goes here.
+
+
+ :copyright: 2007 by Georg Brandl.
+ :license: BSD, see LICENSE for more details.
+"""
+
+from pygments.formatters import HtmlFormatter, LatexFormatter
+
+# The default formatter
+DEFAULT = LatexFormatter()
+
+
+from docutils.parsers.rst import directives
+
+from pygments import highlight
+from pygments.lexers import get_lexer_by_name, TextLexer
+
+VARIANTS = {
+ 'linenos': LatexFormatter(linenos=True),
+}
+
+def pygments_directive(name, arguments, options, content, lineno,
+ content_offset, block_text, state, state_machine):
+ try:
+ lexer = get_lexer_by_name(arguments[0])
+ except ValueError:
+ # no lexer found - use the text one instead of an exception
+ lexer = TextLexer()
+ formatter = DEFAULT
+ parsed = highlight(u'\n'.join(content), lexer, formatter)
+ return [nodes.raw('', parsed, format='latex')]
+
+pygments_directive.arguments = (1, 0, 1)
+pygments_directive.content = 1
+pygments_directive.options = dict([(key, directives.flag) for key in VARIANTS])
+
+directives.register_directive('sourcecode', pygments_directive)
+
+
+## multiple images as a single animation
+
+"""
+ .. animage:: foo-p*.pdf
+ :align: center
+ :scale: 50%
+"""
+
+from glob import glob
+import copy
+from docutils.parsers.rst import directives
+from docutils.parsers.rst.directives.images import Image
+import docutils
+
+class Animage(Image): # Animated Image :-)
+
+ def run(self):
+ def raw(text):
+ return docutils.nodes.raw('', text, format='latex')
+
+ nodes = Image.run(self)
+ img = nodes[0]
+ if not isinstance(img, docutils.nodes.image):
+ return nodes # not an image, WTF?
+ newnodes = []
+ pattern = img.attributes['uri']
+ filenames = sorted(glob(pattern))
+ for i, filename in enumerate(filenames):
+ newimg = copy.deepcopy(img)
+ newimg.attributes['uri'] = filename
+ newnodes += [raw(r'\only<%d>{' % (i+1)),
+ newimg,
+ raw('}')]
+ return newnodes
+
+directives.register_directive('animage', Animage)
+
+
+
+
+## CONSTANTS & DEFINES: ###
+
+BEAMER_SPEC = (
+ 'Beamer options',
+ 'These are derived almost entirely from the LaTeX2e options',
+ tuple (
+ [
+ (
+ 'Specify theme.',
+ ['--theme'],
+ {'default': '', }
+ ),
+ (
+ 'Specify document options. Multiple options can be given, '
+ 'separated by commas. Default is "10pt,a4paper".',
+ ['--documentoptions'],
+ {'default': '', }
+ ),
+ ] + list (Latex2eWriter.settings_spec[2][2:])
+ ),
+)
+
+BEAMER_DEFAULTS = {
+ 'output_encoding': 'latin-1',
+ 'documentclass': 'beamer',
+}
+
+
+### IMPLEMENTATION ###
+
+try:
+ locale.setlocale (locale.LC_ALL, '')
+except:
+ pass
+
+class BeamerTranslator (LaTeXTranslator):
+ """
+ A converter for docutils elements to beamer-flavoured latex.
+ """
+
+ def __init__ (self, document):
+ LaTeXTranslator.__init__ (self, document)
+ self.head_prefix = [x for x in self.head_prefix if ('{typearea}' not in x)]
+ hyperref_posn = [i for i in range (len (self.head_prefix)) if ('{hyperref}' in self.head_prefix[i])]
+ if not hyperref_posn:
+ self.head_prefix.append(None)
+ hyperref_posn = [-1] # XXX hack
+ self.head_prefix[hyperref_posn[0]] = ('\\usepackage{hyperref}\n' +
+ '\\usepackage{fancyvrb}\n' +
+ LatexFormatter(style="manni").get_style_defs() +
+ "\n")
+
+ self.head_prefix.extend ([
+ '\\definecolor{rrblitbackground}{rgb}{0.55, 0.3, 0.1}\n',
+ '\\newenvironment{rtbliteral}{\n',
+ '\\begin{ttfamily}\n',
+ '\\color{rrblitbackground}\n',
+ '}{\n',
+ '\\end{ttfamily}\n',
+ '}\n',
+ ])
+ # this fixes the hardcoded section titles in docutils 0.4
+ self.d_class = DocumentClass ('article')
+
+ def begin_frametag (self, node):
+ if "verbatim" in str(node).lower():
+ return '\\begin{frame}[containsverbatim,fragile]\n'
+ else:
+ return '\\begin{frame}\n'
+
+ def end_frametag (self):
+ return '\\end{frame}\n'
+
+ def visit_section (self, node):
+ if (self.section_level == 0):
+ self.body.append (self.begin_frametag(node))
+ LaTeXTranslator.visit_section (self, node)
+
+ def depart_section (self, node):
+ # Remove counter for potential subsections:
+ LaTeXTranslator.depart_section (self, node)
+ if (self.section_level == 0):
+ self.body.append (self.end_frametag())
+
+ def visit_title (self, node):
+ if (self.section_level == 1):
+ self.body.append ('\\frametitle{%s}\n\n' % self.encode(node.astext()))
+ raise nodes.SkipNode
+ else:
+ LaTeXTranslator.visit_title (self, node)
+
+ def depart_title (self, node):
+ if (self.section_level != 1):
+ LaTeXTranslator.depart_title (self, node)
+
+ def visit_literal_block(self, node):
+ if not self.active_table.is_open():
+ self.body.append('\n\n\\smallskip\n\\begin{rtbliteral}\n')
+ self.context.append('\\end{rtbliteral}\n\\smallskip\n\n')
+ else:
+ self.body.append('\n')
+ self.context.append('\n')
+ if (self.settings.use_verbatim_when_possible and (len(node) == 1)
+ # in case of a parsed-literal containing just a "**bold**" word:
+ and isinstance(node[0], nodes.Text)):
+ self.verbatim = 1
+ self.body.append('\\begin{verbatim}\n')
+ else:
+ self.literal_block = 1
+ self.insert_none_breaking_blanks = 1
+
+ def depart_literal_block(self, node):
+ if self.verbatim:
+ self.body.append('\n\\end{verbatim}\n')
+ self.verbatim = 0
+ else:
+ self.body.append('\n')
+ self.insert_none_breaking_blanks = 0
+ self.literal_block = 0
+ self.body.append(self.context.pop())
+
+
+class BeamerWriter (Latex2eWriter):
+ """
+ A docutils writer that modifies the translator and settings for beamer.
+ """
+ settings_spec = BEAMER_SPEC
+ settings_defaults = BEAMER_DEFAULTS
+
+ def __init__(self):
+ Latex2eWriter.__init__(self)
+ self.translator_class = BeamerTranslator
+
+
+
+
+if __name__ == '__main__':
+ description = (
+ "Generates Beamer-flavoured LaTeX for PDF-based presentations." + default_description)
+ publish_cmdline (writer=BeamerWriter(), description=description)
+
+
+### END ######################################################################
+
diff --git a/talk/fosdem2014/pypy-jit/stylesheet.latex b/talk/fosdem2014/pypy-jit/stylesheet.latex
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2014/pypy-jit/stylesheet.latex
@@ -0,0 +1,11 @@
+\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/fosdem2014/pypy-jit/talk.rst b/talk/fosdem2014/pypy-jit/talk.rst
new file mode 100644
--- /dev/null
+++ b/talk/fosdem2014/pypy-jit/talk.rst
@@ -0,0 +1,94 @@
+=================================
+How PyPy makes your code run fast
+=================================
+
+Introduction
+============
+
+* Romain Guillebert, @rguillebert
+
+* PyPy contributor for ~3 years
+
+* NumPyPy contributor
+
+* Please interrupt me
+
+* How the PyPy JIT works (kind of)
+
+* Warning : May contain traces of machine code
+
+speed.pypy.org
+==============
+
+.. image:: Speed.png
+ :scale: 40%
+ :align: center
+
+AOT
+===
+
+* Ahead of time compilation
+
+* GCC
+
+* You can optimize only on what you know before running the program
+
+Interpreter
+===========
+
+* CPython, PyPy
+
+* Do everything at runtime
+
+* Not very smart
+
+JIT
+===
+
+* PyPy
+
+* Gathers information at runtime
+
+* Produces optimized machine code
+
+Tracing JIT
+===========
+
+* Optimizes loops
+
+* Traces one iteration of a loop
+
+* Produces a linear trace of execution
+
+* The trace is then optimized and compiled
+
+Guard
+=====
+
+* The JIT produces a linear trace, but the code isn't
+
+* The JIT can make assumptions that are not always true
+
+* Guard : If this is true, continue, otherwise return to the interpreter
+
+* guard_true, guard_class, guard_no_exception, ...
+
+Bridge
+======
+
+* After a guard has failed X times, the other path is traced, compiled and attached to the trace
+
+Jitviewer
+=========
+
+* Jitviewer demo
+
+Demo
+====
+
+* Edge detection algorithm
+
+Questions
+=========
+
+* Questions ?
More information about the pypy-commit
mailing list