1 / 47

Scheduling Memory Transactions

Scheduling Memory Transactions. Synchronization alternatives: Transactional Memory. A (memory) transaction is a sequence of memory reads and writes executed by a single thread that either commits or aborts

bgamble
Download Presentation

Scheduling Memory Transactions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Scheduling Memory Transactions

  2. Synchronization alternatives: Transactional Memory • A (memory) transaction is a sequence of memory reads and writes executed by a single thread that either commits or aborts • If a transaction commits, all the reads and writes appear to have executed atomically • If a transaction aborts, none of its operations take effect • Transaction operations aren't visible until they commit (if they do)

  3. Transactional Memory Implementations Hardware Transactional Memory • Transactional Memory [Herlihy & Moss, '93] • Transactional Memory Coherence and Consistency [Hammond et al., '04] • Unbounded transactional memory [Ananian, Asanovic, Kuszmaul, Leiserson, Lie, '05]… Software Transactional Memory • Software Transactional Memory [Shavit &Touitou, '97] • DSTM [Herlihy, Luchangco, Moir, Scherer, '03] • RSTM [Marathe et al., '06] • WSTM [Harris & Fraser, '03], OSTM [Fraser, '04], ASTM [Marathe, Scherer, Scott, '05], SXM [Herlihy]…

  4. “Conventional” STM system high-level structure OS-scheduler-controlledthreads TM system ContentionManager ContentionDetection Passive Aggressive Polite Karma greedy arbitrate Abort/retry, wait Polka proceed

  5. Talk outline • Preliminaries • Memory Transactions Scheduling: Rationale • CAR-STM • Adaptive TM Schedulers • TM-scheduling OS support

  6. Conventional conflict resolution policies are often insufficient • Loser resumes execution after pre-determined waiting period • May resume execution too early • May resume execution too late • Repeated collisions occur under high contention • Livelocks • Performance may become worse than single lock Scheduling-based CM to the rescue.

  7. TM schedulers: rationale • Transactional threads controlled by TM-aware scheduler • Kernel-level, user-level • Richer “tool-box“ for reducing and/or preventing transaction conflicts Improve performance under high-contention

  8. The first TM schedulers • “Adaptive Transaction Scheduling for transactional memory systems”, Yoo & Lee, SPAA'08 • “CAR-STM: Scheduling-based collision avoidance and resolution for software transactional memory”, Dolev, Hendler & Suissa, PODC '08 • “Steal-on-abort: dynamic transaction reordering to reduce conflicts in transactional memory”, Ansari , Jarvis, Kirkham, Kotsedilis, Lujan and Watson, HiPEAC'09

  9. Our work • “CAR-STM: Scheduling-based collision avoidance and resolution for software transactional memory” [Dolev, Hendler & Suissa, PODC '08] • “On the impact of Serializing Contention Management on STM performance” [Heber, Hendler & Suissa, OPODIS '09] • “Scheduling support for transactional memory contention management” [Fedorova, Felber, Hendler, Lawall, Maldonado, Marlier Muller & Suissa, PPoPP'10]

  10. CAR-STM (Collision Avoidance and Reduction for STM) Design Goals • Limit Parallelism to a single transaction per core (or hardware thread) • Serialize conflicting transactions • Contention avoidance

  11. CAR-STM high-level architecture Transaction thread T-Info Dispatcher CollisionAvoider TQ thread TQ thread Serializing contention mgr. Transaction queue #k Transaction queue #1 Core #1 Core #k

  12. TQ-Entry Structure Transaction thread T-Info Dispatcher CollisionAvoider wrapper method Transaction data TQ thread TQ thread T-Info Serializing contention mgr. Trans. thread Lock, condition var Transaction queue #k Transaction queue #1 Core #1 Core #k

  13. Transaction dispatching process Enque transaction in most-conflicting queue. Put thread to sleep, notify TQ thread. 1 Call app-specific conflict probability method Dispatcher calls Collision Avoider 4 2 Call Dispatcher with a T-Info pointer argument 3 4

  14. Transaction execution 2 TQ thread executes transaction TQ thread wakes-up transaction thread 1 3 wrapper method TQ thread Transaction data T-Info Trans. thread Lock, condition var TQ thread dequeues entry Transaction queue #i Core #i

  15. Serializing Contention Managers • When two transactions collide, fail the newer transaction and move it to the TQ of the older transaction • Fast elimination of live-lock scenarios • Two SCMs implemented • Basic (BSCM) – move failed transaction to end of the other transactions' TQ • Permanent (PSCM) – Make the failed transaction a subordinate-transaction of the other transaction

  16. PSCM Transactions a and b collide, b is older TQ thread TQ thread Td Te Ta Tb Tc PSCM Transaction queue #1 Transaction queue #k Core #1 Core #k

  17. PSCM TQ thread TQ thread Td Te Tb Ta Tc PSCM Ta Transaction queue #1 Transaction queue #k Tc Losing transaction and its subordinates are made subordinates of winning transaction Core #1 Core #k

  18. Execution time: STMBench7R/W dominated workloads

  19. Throughput: STMBench7R/W dominated workloads

  20. CAR-STM Shortcomings • May restrict parallelism too much • At most a single transactional thread per core/hardware-thread • Transitive serialization • High overhead • Non-adaptive

  21. Talk outline • Preliminaries • Memory Transactions Scheduling: Rationale • CAR-STM • Adaptive TM Scheduling • TM-scheduling OS support

  22. “On the impact of Serializing Contention Management on STM performance” • CBench – synthetic benchmark generating workloads with pre-determined length and abort probability. • A low-overhead serialization mechanism • Better understanding of adaptive serialization algorithms

  23. A Low Overhead Serialization Mechanism(LO-SER) Transactional threads Conditionvariables

  24. A Low Overhead Serialization Mechanism (cont'd) 1) t Identifies a collision 3) t change status of t' to ABORT(writes that t is winner) t' t 2) t calls contention manager: ABORT_OTHER 4) t' identifies it was aborted

  25. A Low Overhead Serialization Mechanism (cont'd) t 6) Eventually t commits and broadcasts on its condition variable… 5) t' rolls back transaction and goes to sleep on the condition variable of t t'

  26. A Low Overhead Serialization Mechanism (cont'd) t' t

  27. Requirements for serialization mechanism • Commit broadcasts only if transaction won a collision since last broadcast (or start of execution) • No waiting cycles (deadlock-freedom) • Avoid race conditions

  28. LO-SER algorithm: data structures

  29. LO-SER algorithm: pseudo-code

  30. LO-SER algorithm: pseudo-code (cont'd)

  31. LO-SER algorithm: pseudo-code (cont'd)

  32. Adaptive algorithms • Collect (local or global) statistics on contention level. • Apply serialization only when contention is high. Otherwise, apply a “conventional” contention-management algorithm. • We find that Stabilized adaptive algorithms perform better. First adaptive TM scheduler: “Adaptive transaction scheduling for transactional memory systems” [Yoo & Lee, SPAA'08]

  33. CBench Evaluation Always serializing incurs no overhead in the lack of contention Always serializing is bad in medium contention CAR-STM incurs high overhead as compared with other algorithms Always serializing is best in high contention

  34. CBench Evaluation Adaptive serialization fares well for all contention levels

  35. CBench Evaluation Conventional CM performance degrades for high contention

  36. CBench Evaluation (cont'd) CAR-STM has best efficiency but worst throughput

  37. RandomGraph Evaluation Throughput and efficiency of conventional algorithms are bad Stabilized algorithm improves throughput by up to 30%

  38. Talk outline • Preliminaries • Memory Transactions Scheduling: Rationale • CAR-STM • Adaptive TM Schedulers • TM-scheduling OS support

  39. “Scheduling Support for Transactional Memory Contention Management” • Implement CM scheduling support in the kernel scheduler (Linux & OpenSolaris) • (Strict) serialization • Soft serialization • Time-slice extension • Different mechanisms for communication between user-level STM library and kernel scheduler

  40. TM Library / Kernel Communication via Shared Memory Segment (Ser-k) • User code notifies kernel on events such as: transaction start, commit and abort (in which case thread yields) • Kernel code handles moving thread between ready and blocked queues

  41. Soft Serialization • Instead of blocking, reduce loser thread priority and yield • Efficient in scenarios where loser transactions may take a different execution path when retrying (non-determinism) • Priority should be restored upon commit or when conflicting transactions terminate

  42. Time-slice extention • Preemption in the midst of a transaction increases conflict “window of vulnerability” • Defer preemption of transactional threads • avoid CPU monopolization by bounding number of extensions and yielding after commit • May be combined with serialization/soft serialization

  43. Evaluation (STMBench7, 16 core machine) Serializing by local spinning is efficient as long as threads ≤ cores Conventional CM deteriorates when threads>cores

  44. Evaluation - STMBench7 throughput Serializing by sleeping on condition var is best when threads>cores, since system call overhead is negligible (long transactions)

  45. Evaluation - STMBench7 aborts data

  46. Conclusions • Scheduling-based CM results in • Improved throughput in high contention • Improved efficiency in all contention levels • LO-SER-based serialization incurs no visible overhead • Lightweight kernel support can improve performance and efficiency • Dynamically selecting best CM algorithm for workload at hand is a challenging research direction

  47. Thank you. Any questions?

More Related