fast multi level locks for java
play

Fast Multi-Level Locks for Java Khilan Gudka Imperial College - PowerPoint PPT Presentation

Fast Multi-Level Locks for Java Khilan Gudka Imperial College London Supervised by Susan Eisenbach Sophia Drossopoulou Tuesday, 20 July 2010 Hierarchical Data Structures Databases - tables, rows, cells Trees - subtree, leaf Hashtables -


  1. Fast Multi-Level Locks for Java Khilan Gudka Imperial College London Supervised by Susan Eisenbach Sophia Drossopoulou Tuesday, 20 July 2010

  2. Hierarchical Data Structures Databases - tables, rows, cells Trees - subtree, leaf Hashtables - table, chain, entries Tuesday, 20 July 2010

  3. Accesses Operations may access differing amounts of data c “lots of data” “little data” e.g. Tree - access individual leaf nodes vs. all nodes in subtree Tuesday, 20 July 2010

  4. Accesses Operations may access differing amounts of data c coarse fine “lots of data” “little data” e.g. Tree - access individual leaf nodes vs. all nodes in subtree Tuesday, 20 July 2010

  5. Concurrent Accesses => Concurrency Control Lock data before accessing Lock granularity - how much data a lock protects Trade off between concurrency and overhead fine-grained - more concurrency, higher overhead for coarse accesses coarse-grained - lower overhead, less concurrency for fine accesses Tuesday, 20 July 2010

  6. Hierarchical Bank Account Example Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Tuesday, 20 July 2010

  7. Hierarchical Bank Account Example Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Tuesday, 20 July 2010

  8. Fine-Grained Accesses Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Tuesday, 20 July 2010

  9. Fine-Grained Accesses Fine-grained locking => more concurrency Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Tuesday, 20 July 2010

  10. Fine-Grained Accesses Fine-grained locking => more concurrency Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Tuesday, 20 July 2010

  11. Fine-Grained Accesses Coarse-grained locking => less concurrency Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Tuesday, 20 July 2010

  12. Fine-Grained Accesses Coarse-grained locking => less concurrency Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Tuesday, 20 July 2010

  13. Coarse-Grained Accesses Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Tuesday, 20 July 2010

  14. Coarse-Grained Accesses Fine-grained locking => more overhead Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 4 locks Tuesday, 20 July 2010

  15. Coarse-Grained Accesses Coarse-grained locking => less overhead Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 1 lock Tuesday, 20 July 2010

  16. Best of Both Worlds Workloads access varying amounts of data throughout program’ s lifetime Fine-grained locking when accessing small amounts of data => More concurrency Coarse-grained locking when accessing large amounts of data => Low overhead Tuesday, 20 July 2010

  17. Multi-Granularity Locks Gray et al - “Granularity of Locks in a Shared Data Base” Simultaneous locking at differing granularities Both coarse-grained and fine-grained locks can be used Multi-granularity protocol takes care of their interaction Tuesday, 20 July 2010

  18. Multi-Granularity Locks Individual account accesses => fine-grained locks Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Tuesday, 20 July 2010

  19. Multi-Granularity Locks Individual account accesses => fine-grained locks Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Tuesday, 20 July 2010

  20. Multi-Granularity Locks Entire branch access => coarse-grained locks Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Tuesday, 20 July 2010

  21. Multi-Granularity Locks Interaction between coarse- and fine-grained locks Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Thread wishes to access a5 => has to wait for b2 Tuesday, 20 July 2010

  22. Multi-Granularity Locks Interaction between coarse- and fine-grained locks Operations on: H Account b1 b2 Branch Whole bank a1 a2 a3 a4 a5 a6 Tuesday, 20 July 2010

  23. Multi-Granularity Locks Account can be locked if branch is not already locked and vice-versa Interaction is achieved using “intentional mode” locking Tuesday, 20 July 2010

  24. Intentional Mode Locking Before locking a node, lock all ancestors in intentional mode “Locking is being performed lower down, is it ok to proceed?” Tuesday, 20 July 2010

  25. Intentional Mode Locking H b1 b2 a1 a2 a3 a4 a5 a6 To lock a5, first intentionally acquire H and b2 Tuesday, 20 July 2010

  26. Intentional Mode Locking H b1 b2 a1 a2 a3 a4 a5 a6 To lock a5, first intentionally acquire H and b2 Tuesday, 20 July 2010

  27. Intentional Mode Locking H b1 b2 a1 a2 a3 a4 a5 a6 To lock a5, first intentionally acquire H and b2 Tuesday, 20 July 2010

  28. Intentional Mode Locking H b1 b2 a1 a2 a3 a4 a5 a6 To lock a5, first intentionally acquire H and b2 Tuesday, 20 July 2010

  29. Intentional Mode Locking H b1 b2 a1 a2 a3 a4 a5 a6 To lock a5, first intentionally acquire H and b2 Tuesday, 20 July 2010

  30. Implementation Used Doug Lea’ s Synchronizer framework in Java 6 - highly performant Lock state represented using 64-bit long All state updates performed using CAS Queues are non-blocking Tuesday, 20 July 2010

  31. Performance Evaluation Does multi-granularity locking actually give a performance benefit? For which workloads does multi-granularity locking perform well? Tuesday, 20 July 2010

  32. Micro-benchmark Hierarchical bank account model with 10 branches each with 10 accounts 1 to 16 threads each perform 1,000,000 operations that could be any of the following: 1. Withdraw from random account 2. Deposit into random account 3. Sum balances across random branch 4. Sum balances across whole bank Tuesday, 20 July 2010

  33. Micro-benchmark 3 experiments - vary % of each op and measure overall number of ops per sec Compare against ReentrantReadWriteLock and Deuce STM (LSA and TL2 algorithms) Tuesday, 20 July 2010

  34. Experiment 1: Fine-Grained 50% withdrawals and 50% deposits 9000 Multi-Level Locks Read/Write Locks 8000 STM-TL2 STM-LSA 7000 Throughput (Kops/sec) 6000 5000 4000 3000 2000 1000 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Number of threads Tuesday, 20 July 2010

  35. Experiment 2: Medium-Grained 40% with., 40% dep., 10% branch, 10% bank 3500 Multi-Level Locks Read/Write Locks 3000 STM-TL2 STM-LSA Throughput (Kops/sec) 2500 2000 1500 1000 500 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Number of threads Tuesday, 20 July 2010

  36. Experiment 3: Coarse-Grained 20% with., 20% dep., 30% branch, 30% bank 4000 Multi-Level Locks Read/Write Locks 3500 STM-TL2 STM-LSA Throughput (Kops/sec) 3000 2500 2000 1500 1000 500 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Number of threads Tuesday, 20 July 2010

  37. Conclusion Fine-grained locking good for small accesses, coarse-grained locking good for large accesses Multi-granularity allows different granularities of locks simultaneously Results show that multi-level locks can yield better performance for workloads with a mix of coarse- and fine-grained operations Tuesday, 20 July 2010

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend