Immutability, or Putting the Dream Machine to Work The trie memory - - PowerPoint PPT Presentation

immutability
SMART_READER_LITE
LIVE PREVIEW

Immutability, or Putting the Dream Machine to Work The trie memory - - PowerPoint PPT Presentation

Immutability, or Putting the Dream Machine to Work The trie memory scheme is ine ffi cient for small memories, but it be- comes increasingly e ffi cient in using available storage space as memory size increases. The attractive features of the


slide-1
SLIDE 1

Immutability,

  • r Putting the Dream Machine to Work
slide-2
SLIDE 2
slide-3
SLIDE 3
slide-4
SLIDE 4
slide-5
SLIDE 5

The trie memory scheme is inefficient for small memories, but it be- comes increasingly efficient in using available storage space as memory size increases. The attractive features of the scheme are these: 1) The retrieval process is extremely simple. Given the argument, enter the standard ini- tial register with the first character, and pick up the address of the second. Then go to the second register, and pick up the address of the third, etc. 2) If two arguments have initial characters in common, they use the same storage space for those characters.

  • J.C.R. Licklider, "Man-Computer Symbiosis" 1960
slide-6
SLIDE 6
slide-7
SLIDE 7
slide-8
SLIDE 8
slide-9
SLIDE 9
slide-10
SLIDE 10
slide-11
SLIDE 11

Model-View-Controller

slide-12
SLIDE 12

๏ first formulated by Trygve Reenskaug

Adele Goldberg and others at Xerox PARC in 1979

๏ long shadow, the basic concepts still

prevalent today.

slide-13
SLIDE 13

๏ At a very abstract level MVC is a sound

separation of concerns

๏ Implementations leave much to be

desired

๏ Stateful objects everywhere

slide-14
SLIDE 14
slide-15
SLIDE 15
slide-16
SLIDE 16

Functional Programming and Data

  • immutable values, not mutable objects
  • “change” returns a new value, leaving the old one unmodified
  • they’re persistent
  • they’re fast
slide-17
SLIDE 17

Simple example: Linked List

X

slide-18
SLIDE 18

X Y

Simple example: Linked List

slide-19
SLIDE 19

X Z Y

Simple example: Linked List

slide-20
SLIDE 20

X Z Y

structural sharing

Simple example: Linked List

slide-21
SLIDE 21

Sharing structure

  • space effjciency
  • computational effjciency – avoids copying
slide-22
SLIDE 22

Phil Bagwell

  • Array Mapped Trie
  • Hash Array Mapped Trie
slide-23
SLIDE 23

Bitmapped Vector Trie

  • data lives in the leaves
  • e.g. prefix tree used for string lookup
  • bitwise trie
slide-24
SLIDE 24

Persistent Vector

slide-25
SLIDE 25

Persistent Vector

slide-26
SLIDE 26

Persistent Vector

slide-27
SLIDE 27

Persistent Vector

slide-28
SLIDE 28

Persistent Vector

108 109 110 111 104 105 106 107 100 101 102 103 96 97 98 99

slide-29
SLIDE 29

Persistent Vector

getindex

slide-30
SLIDE 30

Persistent Vector

108 109 110 111 104 105 106 107 100 101 102 103 96 97 98 99

slide-31
SLIDE 31

Persistent Vector

108 109 110 111 104 105 106 107 100 101 102 103 96 97 98 99

0b01101010

slide-32
SLIDE 32

Persistent Vector

108 109 110 111 104 105 106 107 100 101 102 103 96 97 98 99

0b01101010

slide-33
SLIDE 33

Persistent Vector

108 109 110 111 104 105 106 107 100 101 102 103 96 97 98 99

0b01101010

slide-34
SLIDE 34

Persistent Vector

108 109 110 111 104 105 106 107 100 101 102 103 96 97 98 99

0b01101010

slide-35
SLIDE 35

Persistent Vector

108 109 110 111 104 105 106 107 100 101 102 103 96 97 98 99

0b01101010

slide-36
SLIDE 36

Persistent Vector

assoc

slide-37
SLIDE 37

Persistent Vector

108 109 110 111 104 105 106 107 100 101 102 103 96 97 98 99

slide-38
SLIDE 38

Persistent Vector

108 109 110 111 104 105 106 107 100 101 102 103 96 97 98 99

slide-39
SLIDE 39

Persistent Vector

108 109 110 111 104 105 106 107 100 101 102 103 96 97 98 99

slide-40
SLIDE 40

Persistent Vector

108 109 110 111 104 105 106 107 100 101 102 103 96 97 98 99

slide-41
SLIDE 41

Persistent Vector

108 109 110 111 104 105 106 107 100 101 102 103 96 97 98 99 104 105 foo 107

slide-42
SLIDE 42

Persistent Vector

Length 4 internal vectors?

slide-43
SLIDE 43

Persistent Vector

32

From Bagwell, Rompf 2011

slide-44
SLIDE 44

327

slide-45
SLIDE 45

34,359,738,368 elements

slide-46
SLIDE 46

demo

slide-47
SLIDE 47
slide-48
SLIDE 48
slide-49
SLIDE 49
slide-50
SLIDE 50

Om

slide-51
SLIDE 51
slide-52
SLIDE 52

f(D0) = V0

slide-53
SLIDE 53

f(D1) = V1

slide-54
SLIDE 54

diff(V0,V1) = CHANGES

slide-55
SLIDE 55
slide-56
SLIDE 56

demo

slide-57
SLIDE 57
slide-58
SLIDE 58

Persistent Data Structures … ROCK

slide-59
SLIDE 59
slide-60
SLIDE 60

Questions?