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

atom automatic transaction oriented memoization
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

ATOM: Automatic Transaction-Oriented Memoization

Hugo Rito and Jo˜ ao Cachopo

INESC-ID Instituto Superior T´ ecnico

September 11, 2009

slide-2
SLIDE 2

Overview of Memoization

Functional Programming

Memoization

slide-3
SLIDE 3

Overview of Memoization

Functional Programming

Functional Programming

slide-4
SLIDE 4

Overview of Memoization

Functional Programming

Memoization

slide-5
SLIDE 5

Overview of Memoization

Fibonacci function

static int fib(int n) { if (n <= 1) return n; return fib(n-1) + fib(n-2); }

slide-6
SLIDE 6

Overview of Memoization

fib(4) 1 4 2 1 3 1 2

slide-7
SLIDE 7

Overview of Memoization

fib(4) 1 4 2 1 3 1 2

slide-8
SLIDE 8

Overview of Memoization

fib(5) 5 3 1 2 1 1 4 2 1 3 1 2

slide-9
SLIDE 9

Overview of Memoization

fib(5) 5 3 1 2 1 1 4 2 1 3 1 2

slide-10
SLIDE 10

Overview of Memoization

fib(5) 5 3 1 2 1 1 4 2 1 3 1 2

slide-11
SLIDE 11

Overview of Memoization

Memoization Memoization

Optimization technique Function cache Relevant state − → Result

slide-12
SLIDE 12

Overview of Memoization

Memo fib(5) 5 3 1 2 1 1 4 2 1 3 1 2

slide-13
SLIDE 13

Overview of Memoization

Memo fib(5) 5 1 4 2 3

slide-14
SLIDE 14

Limitations of Memoization

Non-Functional Programming

Object-Oriented Imperative Programming

slide-15
SLIDE 15

Limitations of Memoization

Non-Functional Programming

Memoization

slide-16
SLIDE 16

Limitations of Memoization

Banking Domain

Client

Account

getTotalBalance() : long 1 * balance : long

slide-17
SLIDE 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; } }

slide-18
SLIDE 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; } }

slide-19
SLIDE 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; } }

slide-20
SLIDE 20

Limitations of Memoization

Relevant State: Problem

No automatic solutions

slide-21
SLIDE 21

Limitations of Memoization

Relevant State: Problem

No automatic solutions Manually

Difficult Error-prone

slide-22
SLIDE 22

Limitations of Memoization

Side-effects

Share state reads difficult...

slide-23
SLIDE 23

Limitations of Memoization

Side-effects

Share state reads difficult... and side-effects make it worse!

slide-24
SLIDE 24

Proposed Solution

Proposed Solution

Memoization

slide-25
SLIDE 25

Proposed Solution

Proposed Solution

Memoization + Software Transactional Memory

slide-26
SLIDE 26

Proposed Solution

Proposed Solution

slide-27
SLIDE 27

Proposed Solution

Proposed Solution

Automatic Transaction-Oriented Memoization

slide-28
SLIDE 28

Proposed Solution

Proposed Solution

Object-Oriented Imperative Programming

slide-29
SLIDE 29

Proposed Solution

Proposed Solution

Automatic Transaction-Oriented Memoization

slide-30
SLIDE 30

Proposed Solution

Software Transactional Memory

Concurrent programming

slide-31
SLIDE 31

Proposed Solution

Software Transactional Memory

Concurrent programming Transaction

slide-32
SLIDE 32

Proposed Solution

Software Transactional Memory

Concurrent programming Transaction Intercept accesses

slide-33
SLIDE 33

Proposed Solution

Software Transactional Memory

Concurrent programming Transaction Intercept accesses Read-set / Write-set

slide-34
SLIDE 34

Proposed Solution

JVSTM Example

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

slide-35
SLIDE 35

Proposed Solution

JVSTM Example

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

slide-36
SLIDE 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; } }

slide-37
SLIDE 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; } }

slide-38
SLIDE 38

Proposed Solution

The ATOM

Java library

slide-39
SLIDE 39

Proposed Solution

The ATOM

Java library Uses an STM to..

Build the relevant state Detect side-effects Capture side-effects

slide-40
SLIDE 40

Proposed Solution

The ATOM

Java library Uses an STM to..

Build the relevant state Detect side-effects Capture side-effects

Simple interface

slide-41
SLIDE 41

Proposed Solution

Evolution

Cache Search Cache Hit? Execute Method Add New Cache Entry Get Result From Cache Yes No

Memoization

Return Result

slide-42
SLIDE 42

Proposed Solution

Evolution

Cache Search Cache Hit? Execute Method Add New Cache Entry Get Result From Cache Yes No

Extended Memoization

Return Result Begin Transaction Commit Transaction

Read-set: Relevant state Write-set: Side-effects

slide-43
SLIDE 43

Proposed Solution

Evolution

Cache Search Cache Hit? Commit Transaction Execute Method Add New Cache Entry Get Result From Cache Yes No

Extended Memoization

Begin Transaction Return Result Yes No Can Memoize? Collect Information

Two memoization strategies: Read-only Write-allowed “Collect Information” caches: Read-set Possibly the write-set

slide-44
SLIDE 44

Proposed Solution

Evolution

Cache Search Cache Hit? Commit Transaction Execute Method Add New Cache Entry Get Result From Cache Yes No

Extended Memoization

Begin Transaction Return Result Read Only? Yes No Can Memoize? Collect Information Yes No Apply Changes

Possibly apply the write-set

slide-45
SLIDE 45

Proposed Solution

Evolution

Cache Hit? Commit Transaction Execute Method Add New Cache Entry Get Result From Cache Yes No

Extended Memoization

Begin Transaction Return Result Read Only? Yes No Apply Changes Can Memoize? Collect Information Yes No Cache Search

Two caching policies: Version Value

slide-46
SLIDE 46

Proposed Solution

ATOM Example

@Atomic long getTotalBalance() { /* Body of getTotalBalance() */ }

slide-47
SLIDE 47

Proposed Solution

ATOM Example

@Memo long getTotalBalance() { /* Body of getTotalBalance() */ }

slide-48
SLIDE 48

Experimental Results

STMBench7 benchmark

Customizable Evaluate STM implementations CAD domain

slide-49
SLIDE 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

slide-50
SLIDE 50

Experimental Results

Results

1 2 4 8 16 1000 2000 3000 4000 5000 6000

No read-write traversals / No structural modifications

ATOM JVSTM

Number of Threads O p e r a t i

  • n

s / s e c

  • n

d

slide-51
SLIDE 51

Experimental Results

Results

1 2 4 8 16 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000

No traversals

ATOM JVSTM

Number of Threads O p e r a t i

  • n

s / s e c

  • n

d

slide-52
SLIDE 52

Experimental Results

Results

1 2 4 8 16 5000 10000 15000 20000 25000

No traversals / No structural modifications

ATOM JVSTM

Number of Threads O p e r a t i

  • n

s / s e c

  • n

d

slide-53
SLIDE 53

Conclusions

Summary

Memoize object-oriented imperative programs is hard

slide-54
SLIDE 54

Conclusions

Summary

Memoize object-oriented imperative programs is hard ATOM

Relevant state dynamically constructed Detects/Integrates side-effects Simple interface

slide-55
SLIDE 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

slide-56
SLIDE 56

Conclusions

Questions