Author: Armin Rigo <[email protected]>
Branch: extradoc
Changeset: r5067:f7e98dc6084b
Date: 2013-10-04 11:01 +0200
http://bitbucket.org/pypy/extradoc/changeset/f7e98dc6084b/
Log: Tweak slides
diff --git a/talk/pyconza2013/Makefile b/talk/pyconza2013/Makefile
--- a/talk/pyconza2013/Makefile
+++ b/talk/pyconza2013/Makefile
@@ -1,13 +1,13 @@
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
diff --git a/talk/pyconza2013/stylesheet.latex
b/talk/pyconza2013/stylesheet.latex
new file mode 100644
--- /dev/null
+++ b/talk/pyconza2013/stylesheet.latex
@@ -0,0 +1,10 @@
+\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}
diff --git a/talk/pyconza2013/talk.pdf b/talk/pyconza2013/talk.pdf
index
6fed83a5c845e1d71cd4c32a98eb6a6b93d07bcf..80a179ffd04df370eb9f786822977148c46dc6be
GIT binary patch
[cut]
diff --git a/talk/pyconza2013/talk.rst b/talk/pyconza2013/talk.rst
--- a/talk/pyconza2013/talk.rst
+++ b/talk/pyconza2013/talk.rst
@@ -1,18 +1,14 @@
.. 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
@@ -20,6 +16,8 @@
* what is PyPy: an alternative implementation of Python
+* very compatible
+
* main focus is on speed
@@ -34,6 +32,14 @@
SQL by example
--------------
+.. raw:: latex
+
+ %empty
+
+
+SQL by example
+--------------
+
::
BEGIN TRANSACTION;
@@ -58,6 +64,27 @@
::
+ ...
+ 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
@@ -100,10 +127,10 @@
::
- 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
@@ -111,9 +138,9 @@
::
- 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
@@ -121,9 +148,9 @@
::
- 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
@@ -134,14 +161,46 @@
* 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
@@ -149,11 +208,13 @@
::
- 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
@@ -161,11 +222,26 @@
::
- 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()
@@ -178,6 +254,8 @@
* uses threads, but internally only
+* very simple, pure Python
+
Example 2
---------
@@ -187,7 +265,7 @@
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
@@ -215,37 +293,29 @@
* 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
@@ -258,9 +328,11 @@
::
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
@@ -273,11 +345,11 @@
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
@@ -287,11 +359,11 @@
* 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
+----------------------
::
@@ -318,6 +390,16 @@
* 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
---------------
@@ -329,8 +411,8 @@
* 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
@@ -345,4 +427,8 @@
* a small change for Python users
+* (and the GIL is gone)
+
+* this work is sponsored by crownfunding (thanks!)
+
* `Q & A`
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit