hardware read write lock elision
play

Hardware Read-Write Lock Elision Alexander Shady Issa Pascal - PowerPoint PPT Presentation

Hardware Read-Write Lock Elision Alexander Shady Issa Pascal Felber Matveev Paolo Romano Multicores are everywhere 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 2 Parallel programming Main memory Core 1 Core 2 Core 3 Core 4


  1. Hardware Read-Write Lock Elision Alexander Shady Issa Pascal Felber Matveev Paolo Romano

  2. Multicores are everywhere 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 2

  3. Parallel programming Main memory Core 1 Core 2 Core 3 Core 4 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 3

  4. Parallel programming Main memory Core 1 Core 2 Core 3 Core 4 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 4

  5. Parallel programming complexity - deadlocks Main memory - livelocks - priority inversions - convoy effects Core 1 Core 2 Core 3 Core 4 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 5

  6. Parallel programming Main memory Transactional memory atomic{ Core 1 Core 2 Core 3 Core 4 if(bal>amount) withdraw(amount) } 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 6

  7. Hardware Transactional Memory 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 7

  8. Hardware lock elision w(B) r(A) Thread 1 unlock lock w(X) w(Y) Thread 2 lock lock unlock 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 8

  9. Hardware lock elision w(B) r(A) Thread 1 unlock lock Begin Commit H/W Tx H/W Tx w(X) w(Y) Thread 2 lock unlock Begin Commit H/W Tx H/W Tx 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 9

  10. Hardware lock elision r(X) r(A) Thread 1 lock acquire Begin abort lock H/W Tx normally w(X) Thread 2 lock Begin H/W Tx 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 10

  11. Hardware lock elision r(X) r(A) Thread 1 lock acquire Begin abort lock H/W Tx normally w(X) Thread 2 lock capacity prohibited instructions Begin page faults H/W Tx TLB miss 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 11

  12. Read-write Locks read mode write mode concurrent sequential writers ✔ ✘ readers blocks readers ✘ read dominated workloads 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 12

  13. Hardware read-write lock elision readers run without instrumentation: writers run in H/W Txs: no H/W Txs no lock acquisition • • no S/W tracking of H/W tracking of • • read locations read/write locations no lock acquisition • 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 13

  14. Hardware read-write lock elision r(?) r(X) Reader r-unlock r-lock w(X) w(Y) Writer w-lock w-unlock Begin Commit HW Tx HW Tx 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 14

  15. Hardware read-write lock elision r(?) r(X) Reader r-unlock r-lock ? = Y w(X) w(Y) Writer w-lock w-unlock Begin Commit H/W Tx H/W Tx 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 15

  16. Hardware read-write lock elision r(?) r(X) Reader r-unlock r-lock ? = Y w(X) w(Y) Writer w-lock w-unlock w-unlock Begin Commit H/W Tx H/W Tx 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 16

  17. Hardware read-write lock elision r(Y) r(X) Reader r-unlock r-lock w(X) w(Y) abort Writer w-lock w-unlock Begin Commit H/W Tx H/W Tx 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 17

  18. Hardware read-write lock elision r(?) r(X) Reader r-unlock r-lock wait for concurrent readers active here w(X) w(Y) Writer w-lock w-unlock w-unlock Begin Commit H/W Tx H/W Tx 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 18

  19. Hardware read-write lock elision R1 r-unlock R2 r-unlock r-lock reader state reader state R1 inactive R1 inactive R2 active R2 inactive . . . . Writer abort w-unlock w-unlock 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 19

  20. Hardware read-write lock elision r(?) r(X) Reader r-unlock r-lock wait for concurrent readers active here w(X) w(Y) Writer w-lock w-unlock Suspend Resume Commit Begin HW Tx HW Tx HW Tx HW Tx 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 20

  21. Hardware read-write lock elision Writes use H/W Txs concurrency Txs may never commit ✔ ✘ among writers fallback lock is a must • Readers must synchronize • with lock holder 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 21

  22. Hardware read-write lock elision check old wait for lock lock X r(X) r(Y) Reader r-lock r-lock r-unlock wait for concurrent readers Writer w(X) w(Y) in lock w-lock w-unlock fallback Release Acquire lock lock 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 22

  23. Rollback Only Transactions r(X) r(X) r(X) Thread 1 lock unlock lock Begin Commit abort Begin H/W Tx ROT ROT w(X) w(X) Thread 2 lock lock unlock Begin Begin Commit H/W Tx ROT ROT 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 23

  24. Rollback Only Transactions new old X X r(X) r(X) r(X) Thread 1 lock unlock lock Begin Commit abort Begin H/W Tx ROT ROT w(X) w(X) Thread 2 lock lock unlock Begin Begin Commit H/W Tx ROT ROT 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 24

  25. Using Rollback Only Transactions (ROTs) atomic no tracking of reads ✔ ✘ allow larger Txs not serializable ✔ ✘ no need for Suspend/Resume single writer ✔ ✘ 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 25

  26. Experiments complex benchmarks synthetic and benchmarks applications 10 cores degree of STMBench7 contention 80 H/W threads TPC-C length of Transactions Kyoto Cabinet 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 26

  27. Optimistic Pessimestic RW-LE OPT RW-LE PES HTM ROT ROT GL GL 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 27

  28. Optimistic Pessimestic RW-LE OPT RW-LE PES HTM HLE ROT BRLock ROT RWL GL SGL GL 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 28

  29. Synthetic benchmarks RW-LE OPT RW-LE PES Size of Txs HLE BRLock RWL SGL Degree of contention 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 29

  30. Stress test – performance 10% writers RW-LE OPT 1 RW-LE PES HLE BRLock 1 RWL SGL Large Txs Time (s) Time (s) 0.1 RW-LE OPT 8X 7X RW-LE PES 0.01 0.1 HLE 16 32 64 80 16 32 64 80 Number of threads Number of threads BRLock 10 RWL 1 Small Txs SGL Time (s) Time (s) 1 10X 0.1 0.1 16 32 64 80 16 32 64 80 Number of threads Number of threads 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 30 Low contention High contention

  31. Stress test – abort rate 10% writers Large Txs Aborts (%) Aborts (%) ROT capacity ROT conflicts Lock aborts RW-LE RW-LE HLE RW-LE RW-LE HLE OPT PES OPT PES HTM capacity HTM non-tx Small Txs Aborts (%) Aborts (%) HTM tx RW-LE RW-LE HLE RW-LE RW-LE HLE OPT PES OPT PES 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 31 Low contention High contention

  32. Stress test 90% writers 1 RW-LE OPT RW-LE PES HLE BRLock 1 RWL SGL Large Txs Time (s) Time (s) 0.1 RW-LE OPT RW-LE PES 0.01 HLE 0.1 16 32 64 80 16 32 64 80 Number of threads Number of threads BRLock 100 10 RWL Small Txs 10 SGL Time (s) 1 Time (s) 1 -25% -10% 0.1 0.1 16 32 64 80 16 32 64 80 Number of threads Number of threads 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 32 Low contention High contention

  33. Synthetic benchmarks HTM ROT SGL Uninstrumented HTM ROT SGL Uninstrumented 1% write locks 10% write locks 90% write locks 1% write locks 10% write locks 90% write locks 100 100 High capacity Commits (%) Commits (%) 80 80 60 60 40 40 20 20 0 0 RW-LE RW-LE HLE RW-LE RW-LE HLE RW-LE RW-LE HLE RW-LE RW-LE HLE RW-LE RW-LE HLE RW-LE RW-LE HLE OPT PES OPT PES OPT PES OPT PES OPT PES OPT PES Number of threads (2,4,8,16,32,64,80) Number of threads (2,4,8,16,32,64,80) HTM ROT SGL Uninstrumented HTM ROT SGL Uninstrumented 1% write locks 10% write locks 90% write locks 1% write locks 10% write locks 90% write locks Low capacity 100 100 Commits (%) Commits (%) 80 80 60 60 40 40 20 20 0 0 RW-LE RW-LE HLE RW-LE RW-LE HLE RW-LE RW-LE HLE RW-LE RW-LE HLE RW-LE RW-LE HLE RW-LE RW-LE HLE OPT PES OPT PES OPT PES OPT PES OPT PES OPT PES Number of threads (2,4,8,16,32,64,80) Number of threads (2,4,8,16,32,64,80) 21/4/16 Hardware Read-Write Lock Elision - Eurosys 2016 33 Low contention High contention

Recommend


More recommend