1 / 14

Persistent Data Structures

Persistent Data Structures. What is “persistent”?. A data structure capable of preserving the current version when modified A collection of immutable states. Why “persistent”?. The immutable states provide the basis for coordination around state in a distributed system.

akando
Download Presentation

Persistent Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Persistent Data Structures

  2. What is “persistent”? • A data structure capable of preserving the current version when modified • A collection of immutable states

  3. Why “persistent”? • The immutable states provide the basis for coordination around state in a distributed system

  4. References Comparison • Clojure: 4 types of mutable references • Refs: shared/synchronous/coordinated • Agents: shared/asynchronous/autonomous • Atoms: shared/synchronous/autonomous • Vars: isolated changes within threads • ION R1: references • CASRefs shared/synchronous/coordinated • IDRefs shared/asynchronous/autonomous (writes), coordinated (reads) • Using git semantics: Push, Pull

  5. Clojure-ION R1 • Clojure • Object structure is a hash map • Share strcutres in a single JVM (locks, shared resource) • Synchronous transactions, may fail if state has diverged • Mechanisms: Identity establishment, de-referencing (??) • ION R1 • Object structure is a graph data structure defined in proto meta object specifications • Distributed processes communicate by messages, • Eventually consistent backend (no locks, no sharing) • Asynchronous transactions, never fail (but may require merge on reads) • Working model for Commit and Checkouts

  6. Achieving persistence • Simple copying • Inefficient in time and space • Reusing similar structures • Share structure between new and old versions • Using same subtree in a number of tree structures

  7. Examples of persistent data structures (linked lists) zs = xs ++ ys • Copied: Nodes in list xs have been copied • Shared: Nodes in list ys are shared

  8. Examples of persistent data structures (Trees) ys = insert ("e", xs) • Original tree (xs) persists • Many common nodes are shared

  9. ION R1 Object Model

  10. ION Persistence Performance • Metrics • Creating new version from previous version • Fetch, de-serialize, change, serialize, commit • Retrieving a previous version of data structures

  11. Other References and Diagrams • http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey • https://docs.google.com/drawings/d/100bu4uC-TEH78dyBVmoIgT9DOpaAKEQLc8RqPt4nIjA/edit?hl=en_US&authkey=CO2M5dQD • https://docs2.google.com/drawings/d/1IPkIqsf5IWHHf9dRl9cEEOA45atjA5WCDoBnjXHtKCc/edit?hl=en_US • https://docs6.google.com/drawings/d/1Dgw2TF8ypRXmlCE5MdsjnkVISt4Cmx7rMvtJ7U5craM/edit?hl=en_US • https://docs3.google.com/drawings/d/1KtHHV5AgHppWfnBkyZGeORikjDT49OIbGiQa3c_6T3Q/edit?hl=en_US (Somewhat out of date)

  12. Thanks

  13. Persistent data structures in Clojure • Composite values – immutable • ‘Change’ is merely a function, takes one value and returns another, ‘changed’ value • New versions are not full copies • Old version of the collection is still available after 'changes', with same performance • Structural sharing • Indirect references to immutable objects

  14. Partially/Fully/Confluentlypersistent • Partially persistent • All versions can be accessed but only the newest version can be modified • Fully persistent • Every version can be both accessed and modified • Confluently persistent • A new version can be created from two previous versions (meld/merge operations)

More Related