[pypy-issue] [issue1329] stm-thread-2: Many small transactions issue

Remi tracker at bugs.pypy.org
Mon Nov 19 13:56:44 CET 2012

New submission from Remi <remi.meier at gmail.com>:

Here is an artificial example which shows the worst-case behaviour of the current 
STM implementation:

def may_turn_inevitable():
    f = float("0") # turn inevitable
    return f

def caller():
    for i in range(1000):

In may_turn_inevitable() we have an operation which (currently) causes the 
transaction to turn inevitable. This again causes a transaction break as soon as 
possible. Hence, we break out of the normal dispatch() loop and call 
stm_perform_transaction() (which commits the transaction, starts a new one and 
calls us again).
In a normal transaction, we now execute the "return f" which will raise ExitFrame 
and cause us to return from the callback, commit and end the current call to 
stm_perform_transaction() and therefore start a new inevitable transaction again. 
This one will also commit as soon as possible (before we call may_turn_inevitable
() again).

In the end we alternate between very short normal and inevitable transactions.

A real world example where this can be observed is in 
json.scanner.py_make_scanner._scan_once (parse_float).

messages: 5011
nosy: Remi, pypy-issue
priority: performance bug
status: unread
title: stm-thread-2: Many small transactions issue

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list