1. Pypy
  2. Untitled project
  3. extradoc

Commits

Armin Rigo  committed f7e98dc

Tweak slides

  • Participants
  • Parent commits 3a007c1
  • Branches extradoc

Comments (0)

Files changed (4)

File talk/pyconza2013/Makefile

View file
  • Ignore whitespace
 
 
 view: talk.pdf
-	xpdf talk.pdf
+	evince talk.pdf
 
 talk.pdf: talk.tex
 	64bit pdflatex talk.tex
 
-talk.tex: talk1.tex fix.py
-	python fix.py < talk1.tex > talk.tex
+talk.tex: talk.rst
+	rst2beamer --stylesheet=stylesheet.latex --documentoptions=14pt --input-encoding=utf8 --output-encoding=utf8 --overlaybullets=false $< > talk.tex
 
-talk1.tex: talk.rst
-	rst2beamer $< > talk1.tex
+clean:
+	rm -f talk.tex talk.pdf

File talk/pyconza2013/stylesheet.latex

View file
  • Ignore whitespace
+\usetheme{Warsaw}
+\usecolortheme{whale}
+\setbeamercovered{transparent}
+\definecolor{darkgreen}{rgb}{0, 0.5, 0.0}
+\newcommand{\docutilsrolegreen}[1]{\color{darkgreen}#1\normalcolor}
+\newcommand{\docutilsrolered}[1]{\color{red}#1\normalcolor}
+\addtobeamertemplate{block begin}{}{\setlength{\parskip}{35pt plus 1pt minus 1pt}}
+
+\newcommand{\green}[1]{\color{darkgreen}#1\normalcolor}
+\newcommand{\red}[1]{\color{red}#1\normalcolor}

File talk/pyconza2013/talk.pdf

  • Ignore whitespace
Binary file modified.

File talk/pyconza2013/talk.rst

View file
  • Ignore whitespace
 .. include:: beamerdefs.txt
 
-=======================================
-Software Transactional Memory with PyPy
-=======================================
+.. raw:: latex
 
+   \title{Software Transactional Memory with PyPy}
+   \author[arigo]{Armin Rigo}
 
-Software Transactional Memory with PyPy
----------------------------------------
+   \institute{PyCon ZA 2013}
+   \date{4th October 2013}
 
-* PyCon ZA 2013
-
-* talk by Armin Rigo
-
-* sponsored by crowdfunding (thanks!)
+   \maketitle
 
 
 Introduction
 
 * what is PyPy: an alternative implementation of Python
 
+* very compatible
+
 * main focus is on speed
 
 
 SQL by example
 --------------
 
+.. raw:: latex
+
+   %empty
+
+
+SQL by example
+--------------
+
 ::
 
     BEGIN TRANSACTION;
 
 ::
 
+    ...
+    obj.value += 1
+    ...
+
+
+Python by example
+-----------------
+
+::
+
+    ...
+    x = obj.value
+    obj.value = x + 1
+    ...
+
+
+Python by example
+-----------------
+
+::
+
     begin_transaction()
     x = obj.value
     obj.value = x + 1
 
 ::
 
-    BEGIN TRANSACTION;    BEGIN TRANSACTION;    BEGIN..
-    SELECT * FROM ...;    SELECT * FROM ...;    SELEC..
-    UPDATE ...;           UPDATE ...;           UPDAT..
-    COMMIT;               COMMIT;               COMMI..
+    BEGIN TRANSACTION;  BEGIN TRANSACTION;    BEGIN..
+    SELECT * FROM ...;  SELECT * FROM ...;    SELEC..
+    UPDATE ...;         UPDATE ...;           UPDAT..
+    COMMIT;             COMMIT;               COMMI..
 
 
 Locks != Transactions
 
 ::
 
-    with the_lock:        with the_lock:        with ..
-      x = obj.val           x = obj.val           x =..
-      obj.val = x + 1       obj.val = x + 1       obj..
+    with the_lock:      with the_lock:        with ..
+      x = obj.val         x = obj.val           x =..
+      obj.val = x + 1     obj.val = x + 1       obj..
 
 
 Locks != Transactions
 
 ::
 
-    with atomic:          with atomic:          with ..
-      x = obj.val           x = obj.val           x =..
-      obj.val = x + 1       obj.val = x + 1       obj..
+    with atomic:        with atomic:          with ..
+      x = obj.val         x = obj.val           x =..
+      obj.val = x + 1     obj.val = x + 1       obj..
 
 
 STM
 * advanced but not magic (same as databases)
 
 
-STM versus HTM
---------------
+By the way
+----------
 
-* Software versus Hardware
+* STM replaces the GIL (Global Interpreter Lock)
 
-* CPU hardware specially to avoid the high overhead
+* any existing multithreaded program runs on multiple cores
 
-* too limited for now
+
+By the way
+----------
+
+* the GIL is necessary and very hard to avoid,
+  but if you look at it like a lock around every single
+  subexpression, then it can be replaced with `with atomic` too
+
+
+So...
+-----
+
+* yes, any existing multithreaded program runs on multiple cores
+
+* yes, we solved the GIL
+
+* great
+
+
+So...
+-----
+
+* no, it would be quite hard to implement it in standard CPython
+
+* but not completely impossible
+
+* too bad for now, only in PyPy
+
+
+But...
+------
+
+* but only half of the story in my opinion `:-)`
 
 
 Example 1
 
 ::
 
-  def apply_interest_rate(self):
+  def apply_interest(self):
      self.balance *= 1.05
 
+
   for account in all_accounts:
-     account.apply_interest_rate()
+     account.apply_interest()
+                                                 .
 
 
 Example 1
 
 ::
 
-  def apply_interest_rate(self):
+  def apply_interest(self):
      self.balance *= 1.05
 
+
   for account in all_accounts:
-     add_task(account.apply_interest_rate)
+     account.apply_interest()
+     ^^^ run this loop multithreaded
+
+
+Example 1
+---------
+
+::
+
+  def apply_interest(self):
+     #with atomic: --- automatic
+        self.balance *= 1.05
+
+  for account in all_accounts:
+     add_task(account.apply_interest)
   run_tasks()
 
 
 
 * uses threads, but internally only
 
+* very simple, pure Python
+
 
 Example 2
 ---------
   def next_iteration(all_trains):
      for train in all_trains:
         start_time = ...
-        for othertrain in train.dependencies:
+        for othertrain in train.deps:
            if ...:
               start_time = ...
         train.start_time = start_time
 
 * but with `objects` instead of `records`
 
-* the transaction aborts and automatically retries
+* the transaction aborts and retries automatically
 
 
 Inevitable
 ----------
 
-* means "unavoidable"
+* "inevitable" (means "unavoidable")
 
 * handles I/O in a `with atomic`
 
 * cannot abort the transaction any more
 
 
-By the way
-----------
-
-* STM replaces the GIL
-
-* any existing multithreaded program runs on multiple cores
-
-
 Current status
 --------------
 
 * basics work, JIT compiler integration almost done
 
-* different executable called `pypy-stm`
+* different executable (`pypy-stm` instead of `pypy`)
 
 * slow-down: around 3x (in bad cases up to 10x)
 
-* speed-ups measured with 4 cores
+* real time speed-ups measured with 4 or 8 cores
 
 * Linux 64-bit only
 
 ::
 
     Detected conflict:
+      File "foo.py", line 58, in wtree
+        walk(root)
       File "foo.py", line 17, in walk
         if node.left not in seen:
-    Transaction aborted, 0.000047 seconds lost
+    Transaction aborted, 0.047 sec lost
 
 
 User feedback
     Forced inevitable:
       File "foo.py", line 19, in walk
         print >> log, logentry
-    Transaction blocked others for 0.xx seconds
+    Transaction blocked others for XX s
 
 
-Async libraries
----------------
+Asynchronous libraries
+----------------------
 
 * future work
 
 * existing Twisted apps still work, but we need to
   look at conflicts/inevitables
 
-* similar with Tornado, gevent, and so on
+* similar with Tornado, eventlib, and so on
 
 
-Async libraries
----------------
+Asynchronous libraries
+----------------------
 
 ::
 
 * reduce slow-down, port to other OS'es
 
 
+STM versus HTM
+--------------
+
+* Software versus Hardware
+
+* CPU hardware specially to avoid the high overhead (Intel Haswell processor)
+
+* too limited for now
+
+
 Under the cover
 ---------------
 
 
 * the most recent version can belong to one thread
 
-* synchronization only when a thread "steals" another thread's most
-  recent version, to make it shared
+* synchronization only at the point where one thread "steals"
+  another thread's most recent version, to make it shared
 
 * integrated with a generational garbage collector, with one
   nursery per thread
 
 * a small change for Python users
 
+* (and the GIL is gone)
+
+* this work is sponsored by crownfunding (thanks!)
+
 * `Q & A`