atom automatic transaction oriented memoization
play

ATOM: Automatic Transaction-Oriented Memoization Hugo Rito and Jo - PowerPoint PPT Presentation

ATOM: Automatic Transaction-Oriented Memoization Hugo Rito and Jo ao Cachopo INESC-ID Instituto Superior T ecnico September 11, 2009 Overview of Memoization Functional Programming Memoization Overview of Memoization Functional


  1. ATOM: Automatic Transaction-Oriented Memoization Hugo Rito and Jo˜ ao Cachopo INESC-ID Instituto Superior T´ ecnico September 11, 2009

  2. Overview of Memoization Functional Programming Memoization

  3. Overview of Memoization Functional Programming Functional Programming

  4. Overview of Memoization Functional Programming Memoization

  5. Overview of Memoization Fibonacci function static int fib(int n) { if (n <= 1) return n; return fib(n-1) + fib(n-2); }

  6. Overview of Memoization fib(4) 4 3 2 2 1 1 0 1 0

  7. Overview of Memoization fib(4) 4 3 2 2 1 1 0 1 0

  8. Overview of Memoization fib(5) 5 3 4 3 2 2 1 2 1 1 0 1 0 1 0

  9. Overview of Memoization fib(5) 5 3 4 3 2 2 1 2 1 1 0 1 0 1 0

  10. Overview of Memoization fib(5) 5 3 4 3 2 2 1 2 1 1 0 1 0 1 0

  11. Overview of Memoization Memoization Optimization technique Memoization Function cache Relevant state �− → Result

  12. Overview of Memoization Memo fib(5) 5 3 4 3 2 2 1 2 1 1 0 1 0 1 0

  13. Overview of Memoization Memo fib(5) 5 4 3 2 1 0

  14. Limitations of Memoization Non-Functional Programming Object-Oriented Imperative Programming

  15. Limitations of Memoization Non-Functional Programming Memoization

  16. Limitations of Memoization Banking Domain Account Client 1 * balance : long getTotalBalance() : long

  17. Limitations of Memoization Banking Domain class Client { Set<Account> accounts; long getTotalBalance() { long total = 0; for (Account account : accounts) { total += accounts.getBalance(); } return total; } }

  18. Limitations of Memoization Banking Domain: Relevant State class Client { Set<Account> accounts ; long getTotalBalance() { long total = 0; for (Account account : accounts) { total += accounts.getBalance(); } return total; } }

  19. Limitations of Memoization Banking Domain: Relevant State class Client { Set<Account> accounts ; long getTotalBalance() { long total = 0; for (Account account : accounts) { total += accounts.getBalance() ; } return total; } }

  20. Limitations of Memoization Relevant State: Problem No automatic solutions

  21. Limitations of Memoization Relevant State: Problem No automatic solutions Manually Difficult Error-prone

  22. Limitations of Memoization Side-effects Share state reads difficult...

  23. Limitations of Memoization Side-effects Share state reads difficult... and side-effects make it worse!

  24. Proposed Solution Proposed Solution Memoization

  25. Proposed Solution Proposed Solution Memoization + Software Transactional Memory

  26. Proposed Solution Proposed Solution

  27. Proposed Solution Proposed Solution Automatic Transaction-Oriented Memoization

  28. Proposed Solution Proposed Solution Object-Oriented Imperative Programming

  29. Proposed Solution Proposed Solution Automatic Transaction-Oriented Memoization

  30. Proposed Solution Software Transactional Memory Concurrent programming

  31. Proposed Solution Software Transactional Memory Concurrent programming Transaction

  32. Proposed Solution Software Transactional Memory Concurrent programming Transaction Intercept accesses

  33. Proposed Solution Software Transactional Memory Concurrent programming Transaction Intercept accesses Read-set / Write-set

  34. Proposed Solution JVSTM Example class Client { Set<Account> accounts; long getTotalBalance() { long total = 0; for (Account account : accounts) { total += accounts.getBalance(); } return total; } }

  35. Proposed Solution JVSTM Example class Client { VSet<Account> accounts; long getTotalBalance() { long total = 0; for (Account account : accounts) { total += accounts.getBalance(); } return total; } }

  36. Proposed Solution JVSTM Example class Client { VSet<Account> accounts; long getTotalBalance() { long total = 0; for (Account account : accounts.get() ) { total += accounts.getBalance(); } return total; } }

  37. Proposed Solution JVSTM Example class Client { VSet<Account> accounts; @Atomic long getTotalBalance() { long total = 0; for (Account account : accounts.get()) { total += accounts.getBalance(); } return total; } }

  38. Proposed Solution The ATOM Java library

  39. Proposed Solution The ATOM Java library Uses an STM to.. Build the relevant state Detect side-effects Capture side-effects

  40. Proposed Solution The ATOM Java library Uses an STM to.. Build the relevant state Detect side-effects Capture side-effects Simple interface

  41. Proposed Solution Evolution Memoization Cache Search Cache No Execute Hit? Method Yes Get Result From Cache Add New Cache Entry Return Result

  42. Proposed Solution Evolution Extended Begin Memoization Transaction Cache Search Cache No Execute Hit? Method Yes Read-set: Relevant state Write-set: Side-effects Get Result From Cache Add New Cache Entry Commit Transaction Return Result

  43. Proposed Solution Evolution Extended Begin Memoization Transaction Cache Search Two memoization strategies: Read-only Cache No Execute Hit? Method Write-allowed Yes Can No Memoize? Yes Collect Get Result Information From Cache “Collect Information” caches: Add New Read-set Cache Entry Possibly the write-set Commit Transaction Return Result

  44. Proposed Solution Evolution Extended Begin Memoization Transaction Cache Search Cache No Execute Hit? Method Yes Can No Read Memoize? No Apply Only? Changes Possibly apply the write-set Yes Yes Collect Get Result Information From Cache Add New Cache Entry Commit Transaction Return Result

  45. Proposed Solution Evolution Extended Begin Memoization Transaction Cache Search Cache No Execute Hit? Method Yes Two caching policies: Can No Read Memoize? No Apply Only? Version Changes Yes Yes Value Collect Get Result Information From Cache Add New Cache Entry Commit Transaction Return Result

  46. Proposed Solution ATOM Example @Atomic long getTotalBalance() { /* Body of getTotalBalance() */ }

  47. Proposed Solution ATOM Example @Memo long getTotalBalance() { /* Body of getTotalBalance() */ }

  48. Experimental Results STMBench7 benchmark Customizable Evaluate STM implementations CAD domain

  49. Experimental Results Experimental Setting Dual-Quadcore Nehalem Xeon, 12Gb of RAM 1, 2, 4, 8, and 16 threads Read-dominated workload Three mixes of operations

  50. Experimental Results Results No read-write traversals / No structural modifications 6000 5000 d n 4000 o c e s 3000 ATOM / s JVSTM n o i 2000 t a r e p O 1000 0 1 2 4 8 16 Number of Threads

  51. Experimental Results Results No traversals 10000 9000 8000 d 7000 n o c 6000 e s 5000 ATOM / s JVSTM n 4000 o i t a 3000 r e p 2000 O 1000 0 1 2 4 8 16 Number of Threads

  52. Experimental Results Results No traversals / No structural modifications 25000 20000 d n o c 15000 e s ATOM / s JVSTM n 10000 o i t a r e p 5000 O 0 1 2 4 8 16 Number of Threads

  53. Conclusions Summary Memoize object-oriented imperative programs is hard

  54. Conclusions Summary Memoize object-oriented imperative programs is hard ATOM Relevant state dynamically constructed Detects/Integrates side-effects Simple interface

  55. Conclusions Summary Memoize object-oriented imperative programs is hard ATOM Relevant state dynamically constructed Detects/Integrates side-effects Simple interface Memoization improves STMs’ performance

  56. Conclusions Questions

Recommend


More recommend