stm on pypy

19
STM Francisco Fernandez Castano @fcofdezc [email protected] Upclose.me

Upload: fcofdezc

Post on 18-Jul-2015

98 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: STM on PyPy

STM

Francisco Fernandez Castano@fcofdezc

[email protected]

Page 2: STM on PyPy
Page 3: STM on PyPy
Page 4: STM on PyPy

The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software

Herb Sutterhttp://www.gotw.ca/publications/concurrency-ddj.htm

Page 5: STM on PyPy
Page 6: STM on PyPy

Inside the Python GIL

David Beazleyhttps://www.youtube.com/watch?v=ph374fJqFPE

Page 7: STM on PyPy
Page 8: STM on PyPy

Removing the GIL

● Fine-grained locking● Shared-nothing● STM

Page 9: STM on PyPy

BEGIN;

UPDATE accounts SET balance = balance - 100.00

WHERE name = 'Alice';

UPDATE accounts SET balance = balance + 100.00

WHERE name = 'Bob';

COMMIT;

Page 10: STM on PyPy

def update_account(src_account_id, dst_account_id, amount):

with atomic:src_account = accounts[src_account_id]dst_account = acconts[dst_account_id]dst_account.deposit(account.withdraw(amount))

Page 11: STM on PyPy

● Hardware and Software support● Some modern processors (Haswell) support it

– https://software.intel.com/en-us/blogs/2012/02/07/transactional-synchronization-in-haswell

Page 12: STM on PyPy

● Transaction is started● Memory read are logged into read set● Memory writes are logged into write set● Commit is attempted

Page 13: STM on PyPy
Page 14: STM on PyPy

PyPy approach

Page 15: STM on PyPy

Illustration taken from Armin Rigo

Page 16: STM on PyPy

Problems

● Too experimental● Only runs in 64 bit Linux and patched version of

Clang (just for translation)● Limited to 1.5 GB of Ram (Configurable)● JIT warm up still pretty bad● Different GC from regular PyPy (Less efficient)● Long running processes crash

Page 17: STM on PyPy

Demo

Page 18: STM on PyPy

References

● Rajwar, Herlihy and Lai: Virtualizing Transactional Memory

● Herlihy and Moss: Transactional Memory: Architectural Support for Lock-Free Data Structures

● Dice, Shalev, Shavit: Transactional Locking II

Page 19: STM on PyPy

Donations

● http://pypy.org/tmdonate2.html