memory management for self adjusting computation
play

Memory Management for Self-Adjusting Computation Matthew Hammer - PowerPoint PPT Presentation

Memory Management for Self-Adjusting Computation Matthew Hammer Umut Acar Toyota Technological Institute at Chicago International Symposium on Memory Management, 2008 Overview of Talk Previous frameworks written in SML We implement a


  1. Memory Management for Self-Adjusting Computation Matthew Hammer Umut Acar Toyota Technological Institute at Chicago International Symposium on Memory Management, 2008

  2. Overview of Talk • Previous frameworks written in SML • We implement a framework for C In this talk, we • Briefly review self-adjusting computation • Discuss memory management issues • Introduce and evaluate our approach • Compare to previous SML framework Matthew Hammer Memory Management for Self-Adjusting Computation 2 / 42

  3. Self-Adjusting Computation Motivation : Incremental change is pervasive. Many applications encounter data that changes slowly or incrementally over time. • Applications that interact with a physical environment. E.g., Robots. • Applications that interact with a user. E.g., Games, Editors, Compilers, etc. • Application that rely on modeling or simulation. E.g., Scientific Computing, Computational Biology, Motion Simulation. Matthew Hammer Memory Management for Self-Adjusting Computation 3 / 42

  4. Self-Adjusting Computation Ordinary Program Runs Input 1 Program Output 1 • Ordinary programs often run repeatedly on Input 2 Program Output 2 changing input. • What if input and output change by only small increments? Input N Program Output N Matthew Hammer Memory Management for Self-Adjusting Computation 4 / 42

  5. Self-Adjusting Computation Ordinary Program Runs Input 1 Program Output 1 small small change • Ordinary programs often change run repeatedly on Input 2 Program Output 2 changing input. • What if input and output change by only small increments? Input N Program Output N Matthew Hammer Memory Management for Self-Adjusting Computation 4 / 42

  6. Self-Adjusting Computation Ordinary Program Runs Self-Adjusting Program Runs Self-Adj. Input 1 Program Output 1 Input 1 Output 1 Program small small small small Trace 1 change change change change Self-Adj. Input 2 Program Output 2 Input 2 Output 2 Program Trace 2 Trace N-1 Self-Adj. Input N Program Output N Input N Output N Program Matthew Hammer Memory Management for Self-Adjusting Computation 4 / 42

  7. Self-Adjusting Computation Self-Adjusting Program Runs • Record execution in a Self-Adj. Input 1 Output 1 Program program trace small small • When input changes, a Trace 1 change change change propagation Self-Adj. algorithm updates the Input 2 Output 2 Program output and trace as if the program was run Trace 2 “from-scratch”. • Tries to reuse past computation when Trace N-1 possible Self-Adj. Input N Output N Program Matthew Hammer Memory Management for Self-Adjusting Computation 4 / 42

  8. Self-Adjusting Computation Previous work has shown effectiveness for many applications: O ( 1 ) List primitives (map, reverse, . . . ) Sorting: mergesort, quicksort O ( log n ) 2D Convex hulls O ( log n ) [ESA ’06] Tree contraction [Miller, Reif ’85] O ( log n ) [SODA ’04]. 3D Convex Hulls O ( log n ) [SCG ’07] Meshing in 2D and 3D O ( log n ) [FWCG ’07] Bayesian Inference on Trees O ( log n ) [NIPS ’07] O ( s d log n ) Bayesian Inference on Graphs [UAI ’08] All bounds are randomized (expected time) and are within an expected constant factor of optimal or best known-bounds. Matthew Hammer Memory Management for Self-Adjusting Computation 5 / 42

  9. Writing Self-Adjusting Programs Program Transformation Trace In Self-Adj. Input Program Output Input Output Program Trace Out Ordinary programs may be transformed into self-adjusting ones • Special operations added to create/update program trace • Done either by hand, or via compiler support Previous work focused on supporting SML programs Matthew Hammer Memory Management for Self-Adjusting Computation 6 / 42

  10. Motivation for this Work Want to write self-adjusting computations in C. Benefits • Performance (both time and space). • Large user base • Broad hardware support (e.g., robots) • Interoperability with other libraries/software Challenges • Memory management • Ensuring Safety & Correct-usage Matthew Hammer Memory Management for Self-Adjusting Computation 7 / 42

  11. Motivation for this Work Want to write self-adjusting computations in C. Benefits • Performance (both time and space). • Large user base • Broad hardware support (e.g., robots) • Interoperability with other libraries/software Challenges • Memory management • Ensuring Safety & Correct-usage This talk will focus on memory management. Matthew Hammer Memory Management for Self-Adjusting Computation 7 / 42

  12. Motivation for this Work Want to write self-adjusting computations in C. Some Memory Management Options • Leave it to the programmer? — breaks abstractions of framework • Use an existing collector? — previous work suggests performance problems Our Approach Couples memory management with the existing change propagation algorithm. • Memory allocation recorded in program trace • Dead objects are identified during change propagation • Dead objects are reclaimed automatically Matthew Hammer Memory Management for Self-Adjusting Computation 7 / 42

  13. Motivation for this Work Want to write self-adjusting computations in C. Some Memory Management Options • Leave it to the programmer? — breaks abstractions of framework • Use an existing collector? — previous work suggests performance problems Our Approach Couples memory management with the existing change propagation algorithm. • Memory allocation recorded in program trace • Dead objects are identified during change propagation • Dead objects are reclaimed automatically Matthew Hammer Memory Management for Self-Adjusting Computation 7 / 42

  14. Examples Matthew Hammer Memory Management for Self-Adjusting Computation 8 / 42

  15. Self-Adjusting Primitives modref • A modifiable reference ( modref ) is a (input) memory cell that stores changeable f 3 data . read • The input, output and intermediate data call of the program is instrumented with g modrefs. • To access its contents, a modref is read write during a function invocation. • To set its contents, a modref is written 9 • The program trace stores the program’s modref (output) callgraph and modref dependencies. Matthew Hammer Memory Management for Self-Adjusting Computation 9 / 42

  16. Example: Mapping a List Input List ? Let’s map a list in a self-adjusting way. • The input is stored in a modref • We have to read it to see a list cell • We are given an empty modref to write the output E Output Dest Matthew Hammer Memory Management for Self-Adjusting Computation 10 / 42

  17. Example: Mapping a List Input List ? Let’s map a list in a self-adjusting way. read • The input is stored in a modref • We have to read it to map see a list cell • We are given an empty modref to write the output E Output Dest Matthew Hammer Memory Management for Self-Adjusting Computation 10 / 42

  18. Example: Mapping a List Input List a ? Cons Case read read • Read input cell value • Map a �→ a’ map • Allocate output cell • Write output cell • Recurse on tails E Output Dest Matthew Hammer Memory Management for Self-Adjusting Computation 10 / 42

  19. Example: Mapping a List Input List a ? Cons Case read read • Read input cell value • Map a �→ a’ map • Allocate output cell • Write output cell • Recurse on tails E Output Dest Matthew Hammer Memory Management for Self-Adjusting Computation 10 / 42

  20. Example: Mapping a List Input List a ? Cons Case read read • Read input cell value • Map a �→ a’ map • Allocate output cell • Write output cell allocate • Recurse on tails a' E E Output Dest Matthew Hammer Memory Management for Self-Adjusting Computation 10 / 42

  21. Example: Mapping a List Input List a ? Cons Case read read • Read input cell value • Map a �→ a’ map • Allocate output cell • Write output cell allocate • Recurse on tails write a' E Output Dest Matthew Hammer Memory Management for Self-Adjusting Computation 10 / 42

  22. Example: Mapping a List Input Input List List a ? Cons Case read read • Read input cell value • Map a �→ a’ map call map • Allocate output cell • Write output cell allocate • Recurse on tails write a' E Output Output Dest Dest Matthew Hammer Memory Management for Self-Adjusting Computation 10 / 42

  23. Example: Mapping a List Input List ? Nil Case • Read nil input • Write nil output E Output Dest Matthew Hammer Memory Management for Self-Adjusting Computation 10 / 42

  24. Example: Mapping a List Input List ? read Nil Case • Read nil input map • Write nil output E Output Dest Matthew Hammer Memory Management for Self-Adjusting Computation 10 / 42

  25. Example: Mapping a List Input List nil nil read read value Nil Case • Read nil input map • Write nil output E Output Dest Matthew Hammer Memory Management for Self-Adjusting Computation 10 / 42

  26. Example: Mapping a List Input List nil nil read read value Nil Case • Read nil input map • Write nil output write nil Output Dest Matthew Hammer Memory Management for Self-Adjusting Computation 10 / 42

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