390 likes | 617 Views
Software Transactional Memory for Dynamic-Sized Data Structures. Maurice Herlihy, Victor Luchangco, Mark Moir, William Scherer Presented by: Gokul Soundararajan. Outline. Background Software Transactional Memory (STM) Implementation Long Example Experimental Results Conclusion.
E N D
Software Transactional Memory for Dynamic-Sized Data Structures Maurice Herlihy, Victor Luchangco, Mark Moir, William Scherer Presented by: Gokul Soundararajan
Outline • Background • Software Transactional Memory (STM) • Implementation • Long Example • Experimental Results • Conclusion
Transaction • A sequence of operations on components of a data structure executed by a single thread • Atomic: either • Commits: takes effect • Aborts: its effects are discarded • Linearizable: preserves program order
Transactional Memory • Any system that supports concurrent execution of transactions performed by threads • Originally, a hardware idea • Now, implemented in software
Transactional Objects • Is a container for a regular object • A transaction accesses it • Open • Read/modify • Changes are not seen until the transaction commits • Creation and initialization of a transactional object is not a part of any transaction
Class: TMObject Locator {Transaction, oldObject, newObject} Locator * start open( ) release( ) DSTM Implementation • Is a container for a regular object • TMObject class • Implements a transactional object
The transaction that most recently opened the object in WRITE mode start Locator transaction TMObject A new object version newObject oldObject An old object version DSTM Implementation
Current Version • Current version of a transactional object • Determined by the status of the transaction (T) that most recently opened the object in WRITE mode
transaction newObject oldObject Open(WRITE): T is COMMITTED T: COMMITTED myObj start newVersion oldVersion
transaction newObject oldObject transaction newObject oldObject Open(WRITE): T is COMMITTED T: COMMITTED myObj start newVersion oldVersion A: ACTIVE A opens myObj in WRITE mode
transaction newObject oldObject transaction newObject oldObject Open(WRITE): T is COMMITTED T: COMMITTED myObj start newVersion oldVersion A: ACTIVE copy Copy of newVersion A opens myObj in WRITE mode
transaction newObject oldObject transaction newObject oldObject Open(WRITE): T is COMMITTED T: COMMITTED myObj start newVersion oldVersion A: ACTIVE copy Copy of newVersion A opens myObj in WRITE mode
transaction newObject oldObject transaction newObject oldObject Open(WRITE): T is COMMITTED T: COMMITTED myObj start newVersion oldVersion CAS A: ACTIVE copy Copy of newVersion A opens myObj in WRITE mode
transaction newObject oldObject transaction newObject oldObject Open(WRITE): T is ABORTED T: ABORTED myObj start newVersion oldVersion A: ACTIVE A opens myObj in WRITE mode
transaction newObject oldObject transaction newObject oldObject Open(WRITE): T is ABORTED T: ABORTED myObj start newVersion oldVersion A: ACTIVE copy Copy of oldVersion A opens myObj in WRITE mode
transaction newObject oldObject transaction newObject oldObject Open(WRITE): T is ABORTED T: ABORTED myObj start newVersion oldVersion A: ACTIVE copy Copy of oldVersion A opens myObj in WRITE mode
transaction newObject oldObject transaction newObject oldObject Open(WRITE): T is ABORTED T: ABORTED myObj start newVersion oldVersion A: ACTIVE copy Copy of oldVersion A opens myObj in WRITE mode
transaction newObject oldObject transaction newObject oldObject Open(WRITE): T is ACTIVE T: ACTIVE myObj start newVersion oldVersion A: ACTIVE A opens myObj in WRITE mode ? A tries to abort T
Example: Integer Set • Specifications: • Object: Integer Set • Supports: • insert(v) • delete(v) • member(v) • Implementation: • Linked list of a set of elements • Sorted in ascending order
MIN MAX next next Integer Set Example:Constructor start start
thread MIN MAX -20 30 40 next next next next next Integer Set Example: insert(40) newElm newNode T ACTIVE T COMMITED start first start start start start
thread T N O 40 MIN MAX -20 30 MIN next next next next next next Integer Set Example: insert(40) newElm newNode T COMMITED T ACTIVE start first start start start start
thread T T N N O O MIN MAX -20 MIN 40 -20 30 next next next next next next next Integer Set Example: insert(40) newElm newNode T ACTIVE T COMMITED start first start start start start
thread T T T N N N O O O 40 MAX -20 MIN 30 30 -20 MIN next next next next next next next next Integer Set Example: insert(40) newElm newNode T ACTIVE T COMMITED start first start start start start
thread T T T N N N O O O 40 MAX -20 MIN 30 30 -20 MIN next next next next next next next next Integer Set Example: insert(40) newElm newNode T ACTIVE T COMMITED start first start start start start
thread T T T T N N N N O O O O -20 MAX MAX 30 MIN -20 40 30 MIN next next next next next next next next next Integer Set Example: insert(40) newElm newNode T ACTIVE T COMMITED start first start start start start
thread T T T T N N N N O O O O -20 MAX MAX 30 MIN -20 40 30 MIN next next next next next next next next next Integer Set Example: insert(40) newElm newNode T ACTIVE T COMMITED start first start start start start
DSTM and Sequential Code Differences: • Need to catch Denied exception • Retry transaction that fails to commit • Distinguish between transactional objects and non-transactional objects
Obstruction Freedom • Guarantees progress for any thread that eventually executes without interference for a sufficient number of steps • Strong enough to avoid problems associated with locks • Ensures that no thread can be blocked by delays or failures of other threads • Live-lock • Livelock Freedom - If some process wants to enter the critical section, then some process will eventually enter the critical section.
Obstruction Freedom • Weaker progress guarantee than wait-freedom • All processes are guaranteed to complete the access in finite time, regardless of the actions of the other processes. • BUT: Efficient Contention Manager In Practice Wait Freedom Obstruction Freedom +
Contention Management • Methods: • Aggressive • Abort the conflicting transaction • Interrupting a partially executed operation will not jeopardise correctness • Polite • Operations “back off” when they encounter interference • Wait for some time before retrying
Contention Management • Contention manager is invoked only in case of contention • In most lock-free and wait-free implementations, mechanisms used to ensure progress impose significant overhead even in the absence of contention
Experiments • Benchmarks • IntSet • IntSet with Early Release • RBTree • Contention Management • Aggressive– abort the conflicting transaction • Polite – have a back-off algorithm
Conclusion • Presented • Transactional Memory in Java/C++ • Probably easier in Java (because of the Object data type) • Good performance over simple locking