430 likes | 526 Views
Interfacing Software Transactional Memory Simplicity vs. Flexibility. Vincent Gramoli. Multi-core Motivations. Transistor size allows multi-core. Multi-core Motivations. Transistor size allows multi-core Processor speed is power-consuming. Multi-core Motivations.
E N D
Interfacing Software Transactional Memory Simplicity vs. Flexibility Vincent Gramoli
Multi-core Motivations • Transistor size allows multi-core
Multi-core Motivations • Transistor size allows multi-core • Processor speed is power-consuming
Multi-core Motivations • Transistor size allows multi-core • Processor speed is power-consuming • Limiting computation speed
Software Transactional Memory Motivations • Simplicity while handling efficiently parallelism: • Avoiding inefficient coarse-grained locking • Avoiding tricky fine-grained locking • Allowing composition of transactions • Providing transparency to programmer • Here it is: Software Transactional Memory • Execute code optimistically • Detect conflict when it occurs • Roll-back in case it aborts
Goal Making STM simple and flexible! • Making STM simple: Any programmer should be able to use it • Making STM flexible: STM should be efficient in any situations
Overview • Preliminaries • Making STM easy-to-use • Making STM flexible • Reconciling simplicity and flexibility
What is an interface? “The interactions of an object with the outside world.” [java.sun.com]
Interfacing STM Application STM beginTransaction() endTransaction()
Interfacing STM Application STM beginTransaction() Abort handler onAbort() endTransaction() Commit handler onCommit()
Interfacing STM • Is the abort handler part of the STM? • Is the commit handler part of the Application? • What should be defined explicitly?
Overview • Preliminaries • Making STM easy-to-use • Making STM flexible • Reconciling simplicity and flexibility
Guards Explicit Semantic [Harris, Fraser in OOPSLA’03]: If* (B) Do (A) where A is the atomic block, B is a boolean (guard) * can also act as a “wait” (e.g. B=!full_stack) Implicit Requirement: Implicit maximum number of retries B = #retries < ? How many retries should be made?
Retries Explicit Semantic [Harris, Marlow, Peyton Jones, Herlihy, PPoPP’05]: Do (A) If (B) Retry Implicit Requirement: Implicit roll-back if B is true Which previous actions should be canceled?
Exceptions Explicit Semantic [Fetzer, Felber in J.UCS’07]: Do (A) If (B) Do (C) Implicit Requirement: Implicit identification of the cause of the exception How can we prevent this exception to raise again ?
Achieving simplicity • Every statement must be implicit: • Guard/retry/exception should be handled by the STM • But, for efficiency purpose we can not: • STM should be tuned so that commit throughput is increased How to make an STM flexible ?
Overview • Preliminaries • Making STM easy-to-use • Making STM flexible • Reconciling simplicity and flexibility
Multi-level Interface NooB Programmer needs Simplicity: Desire of easy-of-use Expert Programmer needs Flexbility: Ability to tune the STM
Dynamic STM 2 [Herlihy, Luchangco, Moir in OOPSLA 2006] How to use this framework? (NooB programmer) • Define your atomic object interface; • Pass it to your favorite factory constructor; • The factory provides object access; • Access the object create/setters/getters.
Dynamic STM 2 My Interface LinkedListNode My Atomic Code Factory Class LinkedListNode
What is tunable? What can be made tunable? • Contention Manager • Which transaction should abort the other? • Escape Mechanisms • Could we provide early-release action? …and so on
Dynamic STM 2 [Herlihy, Luchangco, Moir, OOPSLA 2006] How to extend this framework? (expert programmer) • Define your atomic object interface; • Write your own factory and/or contention manager; • Pass it to your factory constructor; • The factory provides object access; • Access the object create/setters/getters.
Dynamic STM 2 My Interface LinkedListNode My Atomic Code Factory My Factory Class LinkedListNode
Dynamic STM 2 My Interface LinkedListNode My Atomic Code Factory My Factory My Contention Manager Class LinkedListNode
Dynamic STM 2 My Interface LinkedListNode My Atomic Code Obstruction-free Factory Class LinkedListNode
Dynamic STM 2 My Interface LinkedListNode My Atomic Code Shadow Factory Class LinkedListNode
Dynamic STM 2 To conclude: • Especially-suited for object-based STMs; • Indirection is the general mechanism; • STM changes imply interface change. Can we make it more flexible?
What is tunable? What can be made tunable? • Contention Manager • Which transaction should abort the other? • Escape Mechanisms • Could we provide early-release action? • Data access granularity • Object-/Field-/Word-based …and so on DSTM2 DSTM2
Intel STM transactional C application transactional Java application StarJIT/ ORP JVM Proton compiler transactional memory runtime SMP system Simulator (HW support) This slide is taken from a talk of Adam Welc [youTube tYRIg4M5xNM]
Intel STM Write: • Acquire lock on tx-record • Logs old value for roll-back in tx-descriptor • Record value read in read-set of tx-descriptor Read: • Records value read in read-set of tx-descriptor Termination: • Validate read-set versions w.r.t. tx-descriptor • Empty read-set, write-set, undo-log
Intel STM To conclude: • Application language independent • Direct access • Eager update Can we make it more flexible?
Overview • Preliminaries • Making STM easy-to-use • Making STM flexible • Reconciling simplicity and flexibility
Simplicity, Basic Interface interface STMBasicallyUsable { void beginTransaction() void commitTransaction() }
Simplicity, Basic Interface Application STM beginTransaction() endTransaction()
Flexibility, Advanced Interface interface STMCarefullyUsable extends Tunable { void beginTransaction() void commitTransaction() }
Interfacing STM Application STM Contention manager beginTransaction() resolveConflict() abort() Abort handler Memory onAbort() store() load() endTransaction() commit() Commit handler onCommit()
Flexibility, Advanced Interface interface STMCarefullyUsable extends Tunable { void beginTransaction() void commitTransaction() }
What is tunable? What can be made tunable? • Contention Manager • Which transaction should abort the other? • Escape Mechanisms • Could we provide early-release action? • Data access granularity • Object-/Field-/Word-based • Eager/Lazy update • should write operations take effect before commit? • Direct vs. indirect access • E.g. compare-and-set “pointer to changes” or “lock of changes”? • Operation visibility • should read operations conflict with operations of other transactions? …and so on
What is tunable? What can be made tunable? • Contention Manager • Which transaction should abort the other? • Escape Mechanisms • Could we provide early-release action? • Data access granularity • Object-/Field-/Word-based • Eager/Lazy update • should write operations take effect before commit? • Direct vs. indirect access • E.g. compare-and-set “pointer to changes” or “lock of changes”? • Operation visibility • should read operations conflict with operations of other transactions? …and so on DSTM2 DSTM2
What is tunable? What can be made tunable? • Contention Manager • Which transaction should abort the other? • Escape Mechanisms • Could we provide early-release action? • Data access granularity • Object-/Field-/Word-based • Eager/Lazy update • should write operations take effect before commit? • Direct vs. indirect access • E.g. compare-and-set “pointer to changes” or “lock of changes”? • Operation visibility • should read operations conflict with operations of other transactions? …and so on DSTM2 DSTM2 Intel STM
Conclusion Interfaces define the role the STM must play • to maximize performance • to be easy-to-use Various STM techniques are efficient in different cases: • Direct/Indirect access, • Access granularity, • Contention manager, • Operation visibility, • Eager/Lazy update… Unifying those techniques in a generic STM: • Simplicity: allows the programmer to choose the one he understands • Flexibility: allows the programmer to choose the one he needs
Open questions Which techniques are not compatible? e.g. indirection and eager update How to refine interface to transactions? e.g. one transaction with eager update, another with lazy-update Could we find the interface to unify all STMs?