SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
Reconsidering
Custom Memory Allocation

Emery Berger, Ben Zorn, Kathryn McKinley




     UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE
Custom Memory Allocation
    Programmers replace                              Very common practice
                                                
    new/delete, bypassing                                 Apache, gcc, lcc, STL,
                                                      

    system allocator                                      database servers…
                                                          Language-level
        Reduce runtime – often                        
    
                                                          support in C++
        Expand functionality – sometimes
    

                                                          Widely recommended
        Reduce space – rarely                         
    



                                                           “Use custom
                                                             allocators”

           UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE            2
Drawbacks of Custom Allocators
    Avoiding system allocator:


        More code to maintain & debug
    

        Can’t use memory debuggers
    

        Not modular or robust:
    

              Mix memory from custom
          

              and general-purpose allocators → crash!
    Increased burden on programmers



          Are custom allocators really a win?
        UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   3
Overview
    Introduction


    Perceived benefits and drawbacks


    Three main kinds of custom allocators


    Comparison with general-purpose allocators


    Advantages and drawbacks of regions


    Reaps – generalization of regions & heaps





     UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   4
(1) Per-Class Allocators
    Recycle freed objects from a free list


    a = new Class1;               Class1
                                                       Fast
                                  free list
    b = new Class1;                                +
    c = new Class1;                                         Linked list operations
                                                        +
                                     a
    delete a;                                          Simple
                                                   +
    delete b;
                                                            Identical semantics
                                    b                   +
    delete c;
                                                            C++ language support
                                                        +
    a = new Class1;
                                     c
                                                       Possibly space-inefficient
    b = new Class1;                                -
    c = new Class1;




           UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE              5
(II) Custom Patterns
             Tailor-made to fit allocation patterns
         

                 Example: 197.parser (natural language parser)
             


                              db
                         a             c
char[MEMORY_LIMIT]

                       end_of_array
                           end_of_array
                               end_of_array
                                  end_of_array
                                      end_of_array
       a = xalloc(8);                       Fast
                                       +
       b = xalloc(16);                           Pointer-bumping allocation
                                             +
       c = xalloc(8);
                                       - Brittle
       xfree(b);
                                             - Fixed memory size
       xfree(c);
                                             - Requires stack-like lifetimes
       d = xalloc(8);
                 UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   6
(III) Regions
    Separate areas, deletion only en masse


    regioncreate(r)               r
    regionmalloc(r, sz)
    regiondelete(r)
                                                     - Risky
    Fast
+

                                                          - Dangling
         Pointer-bumping allocation
     +

                                                            references
         Deletion of chunks
     +

                                                          - Too much space
    Convenient
+

         One call frees all memory
     +


             Increasingly popular custom allocator
         
              UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   7
Overview
    Introduction


    Perceived benefits and drawbacks


    Three main kinds of custom allocators


    Comparison with general-purpose allocators


    Advantages and drawbacks of regions


    Reaps – generalization of regions & heaps





     UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   8
Custom Allocators Are Faster…
                                Runtime - Custom Allocator Benchmarks

                                                           Custom             Win32

                         1.75
    Normalized Runtime




                                       non-regions                             regions
                          1.5
                         1.25
                            1
                         0.75
                          0.5
                         0.25
                           0
                                                              r




                                                                                    he
                                    er




                                                                                                  lle
                                                  ze
                                    m




                                                                          c




                                                                                            c
                                                            vp


                                                                       gc




                                                                                         lc
                                 rs



                                 si




                                                                                                ud
                                                                                  ac
                                                ee



                                                          5.


                                                                     6.
                               d-
                              pa




                                                                                                m
                                                       17




                                                                               ap
                                             br




                                                                  17
                            xe
                            7.




                                           c-
                         bo
                         19




                   As good as and sometimes much faster than Win32

                           UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE                 9
Not So Fast…
                                       Runtime - Custom Allocator Benchmarks
                                                               Custom    Win32     DLmalloc

                         1.75
                                            non-regions                           regions
    Normalized Runtime




                          1.5
                         1.25
                           1
                         0.75
                          0.5
                         0.25
                           0




                                                                                                      lle
                                                           e



                                                                     r




                                                                                       he



                                                                                                c
                                  r


                                                m




                                                                              c
                                                                   vp
                                   e




                                                                                              lc
                                                         z




                                                                            gc
                                              si




                                                                                                     ud
                                rs




                                                      ee




                                                                                    ac
                                                                 5.
                                            d-




                                                                          6.
                             pa




                                                                                                    m
                                                      br


                                                                17




                                                                                  ap
                                                                         17
                                        xe
                           7.




                                                    c-
                                       bo
                          19




                         DLmalloc: as fast or faster for most benchmarks

                           UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE                     10
The Lea Allocator (DLmalloc 2.7.0)
    Mature public-domain general-purpose

    allocator
    Optimized for common allocation patterns


        Per-size quicklists ≈ per-class allocation
    

    Deferred coalescing

    (combining adjacent free objects)
        Highly-optimized fastpath
    

    Space-efficient




        UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   11
Space Consumption: Mixed Results
                                      Space - Custom Allocator Benchmarks

                                                         Custom        DLmalloc

                   1.75
                                  non-regions                                     regions
Normalized Space




                    1.5
                   1.25
                      1
                   0.75
                    0.5
                   0.25
                      0




                                                                                                   lle
                                                     e



                                                              r




                                                                                  he



                                                                                            c
                            r


                                        sim




                                                                       c
                                                            vp
                             e




                                                                                            lc
                                                   z




                                                                     gc




                                                                                                  ud
                          rs




                                                ee




                                                                              ac
                                                          5.
                                      d-




                                                                   6.
                      pa




                                                                                                 m
                                                br


                                                         17




                                                                            ap
                                                                  17
                                  xe
                    7.




                                              c-
                                 bo
                   19




                     UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE                        12
Overview
    Introduction


    Perceived benefits and drawbacks


    Three main kinds of custom allocators


    Comparison with general-purpose allocators


    Advantages and drawbacks of regions


    Reaps – generalization of regions & heaps





     UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   13
Regions – Pros and Cons
    Fast, convenient, etc.
+

    Avoid resource leaks (e.g., Apache)
+

         Tear down memory for terminated connections
     



    No individual object deletion
-
         Unbounded memory consumption
    
         (producer-consumer, long-running computations,
          off-the-shelf programs)
     Apache: vulnerable to DoS, memory leaks

         UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   14
Reap Hybrid Allocator
          Reap = region + heap
      

               Adds individual object deletion & heap
          

reapcreate(r)
                             r
reapmalloc(r, sz)
reapfree(r,p)
reapdelete(r)

          Can reduce memory consumption
      +

          Fast
      +

               Adapts to use (region or heap style)
          +

               Cheap deletion
          +

              UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   15
Reap Runtime
                             Runtime - Custom Allocation Benchmarks

                                                  Custom        Win32    DLmalloc       Reap

                     1.75
Normalized runtime




                                        non-regions                          regions
                      1.5
                     1.25
                        1
                     0.75
                      0.5
                     0.25
                        0




                                                                                                 lle
                                                       e


                                                                r




                                                                                   he



                                                                                         c
                              r


                                           im




                                                                         c
                                                              vp
                               e




                                                                                         lc
                                                     z




                                                                       gc




                                                                                                ud
                            rs




                                                  ee
                                        -s




                                                                               ac
                                                            5.


                                                                     6.
                        pa


                                       d




                                                                                               m
                                                  br


                                                           17




                                                                              ap
                                                                    17
                                    xe
                      7.




                                                c-
                                   bo
                     19




                       UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE                    16
Reap Space
                             Space - Custom Allocator Benchmarks
                                                         Custom    DLmalloc       Reap

                   1.75
                                      non-regions                                regions
Normalized Space




                    1.5
                   1.25
                      1
                   0.75
                    0.5
                   0.25
                      0




                                                                                                  lle
                                                     e


                                                               r




                                                                                 he



                                                                                           c
                            r


                                        sim




                                                                        c
                                                             vp
                             e




                                                                                           lc
                                                   z




                                                                      gc




                                                                                                 ud
                          rs




                                                ee




                                                                              ac
                                                           5.
                                      d-




                                                                    6.
                      pa




                                                                                                m
                                                br


                                                          17




                                                                            ap
                                                                   17
                                  xe
                    7.




                                              c-
                                 bo
                   19




                     UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE                       17
Reap: Best of Both Worlds
    Allows mixing of regions and new/delete


    Case study:


     New Apache module “mod_bc”

              bc: C-based arbitrary-precision calculator
          

              Changed 20 lines out of 8000
          


        Benchmark: compute 1000th prime
    

              With Reap: 240K
          

              Without Reap: 7.4MB
          



        UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   18
Conclusions and Future Work
    Empirical study of custom allocators


        Lea allocator often as fast or faster
    

        Non-region custom allocation ineffective
    

    Reap: region performance without drawbacks


    Future work:


        Reduce space with per-page bitmaps
    

        Combine with scalable general-purpose
    

        allocator (e.g., Hoard)

        UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   19
Software


http://www.cs.umass.edu/~emery
(Reap: part of Heap Layers distribution)

http://g.oswego.edu
(DLmalloc 2.7.0)


    UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   20
If You Can Read This,
I Went Too Far




   UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   21
Backup Slides




   UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   22
Experimental Methodology

    Comparing to general-purpose


    allocators
        Same semantics: no problem
    

              E.g., disable per-class allocators
          


        Different semantics: use emulator
    

            Uses general-purpose allocator
          

           Adds bookkeeping to support

            region semantics
        UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   23
Why Did They Do That?
    Recommended practice


    Premature optimization


        Microbenchmarks vs. actual performance
    

    Drift


        Not bottleneck anymore
    

    Improved competition


        Modern allocators are better
    




        UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   24
Reaps as Regions: Runtime
                                  Runtime - Region-Based Benchmarks

                                         Custom   Win32   DLmalloc   Reap

                     1.75

                      1.5
Normalized Runtime




                     1.25

                       1

                     0.75

                      0.5

                     0.25

                       0
                                        lcc                           mudlle


                      Reap performance nearly matches regions

                        UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   25
Using Reap as Regions
                                       Runtime - Region-Based Benchmarks

                                  Original   Win32    DLmalloc   WinHeap   Vmalloc   Reap
                                                   4.08
                      2.5


                       2
 Normalized Runtime




                      1.5


                       1


                      0.5


                       0
                                             lcc                           mudlle


Reap performance nearly matches regions
                            UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE    26
Drawbacks of Regions
    Can’t reclaim memory within regions


        Bad for long-running computations,
    

        producer-consumer patterns,
        “malloc/free” programs
        unbounded memory consumption
    




    Current situation for Apache:


        vulnerable to denial-of-service
    

        limits runtime of connections
    

        limits module programming
    


        UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   27
Use Custom Allocators?
    Strongly recommended by practitioners


    Little hard data on performance/space

    improvements
        Only one previous study [Zorn 1992]
    

        Focused on just one type of allocator
    

        Custom allocators: waste of time
    

              Small gains, bad allocators
          


    Different allocators better? Trade-offs?




        UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   28
Kinds of Custom Allocators
    Three basic types of custom allocators


        Per-class
    

              Fast
          

        Custom patterns
    

              Fast, but very special-purpose
          

        Regions
    

              Fast, possibly more space-efficient
          

              Convenient
          

              Variants: nested, obstacks
          




        UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE   29
Optimization Opportunity
                                  Time Spent in Memory Operations

                                             Memory Operations                Other

                100
% of runtime




                    80
                    60
                    40
                    20
                    0
                                 sim




                                                                                         ll e
                                                                                 lcc
                                             ze




                                                                 cc




                                                                                                  e
                                                                           e
                                                       pr
                           r
                         se




                                                                                                ag
                                                                          h




                                                                                       ud
                                                      v

                                                                g
                                           e




                                                                       ac
                                 d-




                                                   5.
                    ar




                                                             6.
                                        re




                                                                                              er
                                                                                       m
                                                                      ap
                                                  17
                               xe




                                                            17
                   p




                                         b




                                                                                            Av
                7.




                                      c-
                          bo
               19




                 UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE                         30

Contenu connexe

En vedette

Operating Systems 1 (9/12) - Memory Management Concepts
Operating Systems 1 (9/12) - Memory Management ConceptsOperating Systems 1 (9/12) - Memory Management Concepts
Operating Systems 1 (9/12) - Memory Management ConceptsPeter Tröger
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory ManagementNi Zo-Ma
 
chapter 2 memory and process management
chapter 2 memory and process managementchapter 2 memory and process management
chapter 2 memory and process managementAisyah Rafiuddin
 
Memory management in Linux
Memory management in LinuxMemory management in Linux
Memory management in LinuxRaghu Udiyar
 
Zettabyte File Storage System
Zettabyte File Storage SystemZettabyte File Storage System
Zettabyte File Storage SystemAmdocs
 

En vedette (6)

Operating Systems 1 (9/12) - Memory Management Concepts
Operating Systems 1 (9/12) - Memory Management ConceptsOperating Systems 1 (9/12) - Memory Management Concepts
Operating Systems 1 (9/12) - Memory Management Concepts
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
chapter 2 memory and process management
chapter 2 memory and process managementchapter 2 memory and process management
chapter 2 memory and process management
 
Memory management in Linux
Memory management in LinuxMemory management in Linux
Memory management in Linux
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
Zettabyte File Storage System
Zettabyte File Storage SystemZettabyte File Storage System
Zettabyte File Storage System
 

Similaire à Reconsidering Custom Memory Allocation Techniques

Operating Systems - Dynamic Memory Management
Operating Systems - Dynamic Memory ManagementOperating Systems - Dynamic Memory Management
Operating Systems - Dynamic Memory ManagementEmery Berger
 
Operating Systems - Intro to C++
Operating Systems - Intro to C++Operating Systems - Intro to C++
Operating Systems - Intro to C++Emery Berger
 
Practical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in GroovyPractical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in GroovyGuillaume Laforge
 
Operating Systems - Architecture
Operating Systems - ArchitectureOperating Systems - Architecture
Operating Systems - ArchitectureEmery Berger
 
Kamaelia - Networking Using Generators
Kamaelia - Networking Using GeneratorsKamaelia - Networking Using Generators
Kamaelia - Networking Using Generatorskamaelian
 
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...InfinIT - Innovationsnetværket for it
 
2010 06-24 karlsruher entwicklertag
2010 06-24 karlsruher entwicklertag2010 06-24 karlsruher entwicklertag
2010 06-24 karlsruher entwicklertagMarcel Bruch
 
XS Boston 2008 Paravirt Ops in Linux IA64
XS Boston 2008 Paravirt Ops in Linux IA64XS Boston 2008 Paravirt Ops in Linux IA64
XS Boston 2008 Paravirt Ops in Linux IA64The Linux Foundation
 
GR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
GR8Conf 2009: Practical Groovy DSL by Guillaume LaforgeGR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
GR8Conf 2009: Practical Groovy DSL by Guillaume LaforgeGR8Conf
 
Ph d colloquium 2
Ph d colloquium 2Ph d colloquium 2
Ph d colloquium 2Rishi Roy
 
Kamaelia-ACCU-20050422
Kamaelia-ACCU-20050422Kamaelia-ACCU-20050422
Kamaelia-ACCU-20050422journeyer
 
32 dynamic linking nd overlays
32 dynamic linking nd overlays32 dynamic linking nd overlays
32 dynamic linking nd overlaysmyrajendra
 
Rubinius - Improving the Rails ecosystem
Rubinius - Improving the Rails ecosystemRubinius - Improving the Rails ecosystem
Rubinius - Improving the Rails ecosystemevanphx
 
Close encounters in MDD: when Models meet Code
Close encounters in MDD: when Models meet CodeClose encounters in MDD: when Models meet Code
Close encounters in MDD: when Models meet Codelbergmans
 
Close Encounters in MDD: when models meet code
Close Encounters in MDD: when models meet codeClose Encounters in MDD: when models meet code
Close Encounters in MDD: when models meet codelbergmans
 
C++ in kernel mode
C++ in kernel modeC++ in kernel mode
C++ in kernel modecorehard_by
 
Scalable Elastic Systems Architecture (SESA)
Scalable Elastic Systems Architecture (SESA)Scalable Elastic Systems Architecture (SESA)
Scalable Elastic Systems Architecture (SESA)Eric Van Hensbergen
 

Similaire à Reconsidering Custom Memory Allocation Techniques (20)

Operating Systems - Dynamic Memory Management
Operating Systems - Dynamic Memory ManagementOperating Systems - Dynamic Memory Management
Operating Systems - Dynamic Memory Management
 
Operating Systems - Intro to C++
Operating Systems - Intro to C++Operating Systems - Intro to C++
Operating Systems - Intro to C++
 
Practical Groovy DSL
Practical Groovy DSLPractical Groovy DSL
Practical Groovy DSL
 
Practical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in GroovyPractical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in Groovy
 
Operating Systems - Architecture
Operating Systems - ArchitectureOperating Systems - Architecture
Operating Systems - Architecture
 
Kamaelia - Networking Using Generators
Kamaelia - Networking Using GeneratorsKamaelia - Networking Using Generators
Kamaelia - Networking Using Generators
 
IN4308 1
IN4308 1IN4308 1
IN4308 1
 
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
 
2010 06-24 karlsruher entwicklertag
2010 06-24 karlsruher entwicklertag2010 06-24 karlsruher entwicklertag
2010 06-24 karlsruher entwicklertag
 
XS Boston 2008 Paravirt Ops in Linux IA64
XS Boston 2008 Paravirt Ops in Linux IA64XS Boston 2008 Paravirt Ops in Linux IA64
XS Boston 2008 Paravirt Ops in Linux IA64
 
GR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
GR8Conf 2009: Practical Groovy DSL by Guillaume LaforgeGR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
GR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
 
Ph d colloquium 2
Ph d colloquium 2Ph d colloquium 2
Ph d colloquium 2
 
Kamaelia-ACCU-20050422
Kamaelia-ACCU-20050422Kamaelia-ACCU-20050422
Kamaelia-ACCU-20050422
 
Understanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual MachineUnderstanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual Machine
 
32 dynamic linking nd overlays
32 dynamic linking nd overlays32 dynamic linking nd overlays
32 dynamic linking nd overlays
 
Rubinius - Improving the Rails ecosystem
Rubinius - Improving the Rails ecosystemRubinius - Improving the Rails ecosystem
Rubinius - Improving the Rails ecosystem
 
Close encounters in MDD: when Models meet Code
Close encounters in MDD: when Models meet CodeClose encounters in MDD: when Models meet Code
Close encounters in MDD: when Models meet Code
 
Close Encounters in MDD: when models meet code
Close Encounters in MDD: when models meet codeClose Encounters in MDD: when models meet code
Close Encounters in MDD: when models meet code
 
C++ in kernel mode
C++ in kernel modeC++ in kernel mode
C++ in kernel mode
 
Scalable Elastic Systems Architecture (SESA)
Scalable Elastic Systems Architecture (SESA)Scalable Elastic Systems Architecture (SESA)
Scalable Elastic Systems Architecture (SESA)
 

Plus de Emery Berger

Doppio: Breaking the Browser Language Barrier
Doppio: Breaking the Browser Language BarrierDoppio: Breaking the Browser Language Barrier
Doppio: Breaking the Browser Language BarrierEmery Berger
 
Dthreads: Efficient Deterministic Multithreading
Dthreads: Efficient Deterministic MultithreadingDthreads: Efficient Deterministic Multithreading
Dthreads: Efficient Deterministic MultithreadingEmery Berger
 
Programming with People
Programming with PeopleProgramming with People
Programming with PeopleEmery Berger
 
Stabilizer: Statistically Sound Performance Evaluation
Stabilizer: Statistically Sound Performance EvaluationStabilizer: Statistically Sound Performance Evaluation
Stabilizer: Statistically Sound Performance EvaluationEmery Berger
 
DieHarder (CCS 2010, WOOT 2011)
DieHarder (CCS 2010, WOOT 2011)DieHarder (CCS 2010, WOOT 2011)
DieHarder (CCS 2010, WOOT 2011)Emery Berger
 
Operating Systems - Advanced File Systems
Operating Systems - Advanced File SystemsOperating Systems - Advanced File Systems
Operating Systems - Advanced File SystemsEmery Berger
 
Operating Systems - File Systems
Operating Systems - File SystemsOperating Systems - File Systems
Operating Systems - File SystemsEmery Berger
 
Operating Systems - Networks
Operating Systems - NetworksOperating Systems - Networks
Operating Systems - NetworksEmery Berger
 
Operating Systems - Queuing Systems
Operating Systems - Queuing SystemsOperating Systems - Queuing Systems
Operating Systems - Queuing SystemsEmery Berger
 
Operating Systems - Distributed Parallel Computing
Operating Systems - Distributed Parallel ComputingOperating Systems - Distributed Parallel Computing
Operating Systems - Distributed Parallel ComputingEmery Berger
 
Operating Systems - Concurrency
Operating Systems - ConcurrencyOperating Systems - Concurrency
Operating Systems - ConcurrencyEmery Berger
 
Operating Systems - Advanced Synchronization
Operating Systems - Advanced SynchronizationOperating Systems - Advanced Synchronization
Operating Systems - Advanced SynchronizationEmery Berger
 
Operating Systems - Synchronization
Operating Systems - SynchronizationOperating Systems - Synchronization
Operating Systems - SynchronizationEmery Berger
 
Processes and Threads
Processes and ThreadsProcesses and Threads
Processes and ThreadsEmery Berger
 
Virtual Memory and Paging
Virtual Memory and PagingVirtual Memory and Paging
Virtual Memory and PagingEmery Berger
 
Operating Systems - Virtual Memory
Operating Systems - Virtual MemoryOperating Systems - Virtual Memory
Operating Systems - Virtual MemoryEmery Berger
 
MC2: High-Performance Garbage Collection for Memory-Constrained Environments
MC2: High-Performance Garbage Collection for Memory-Constrained EnvironmentsMC2: High-Performance Garbage Collection for Memory-Constrained Environments
MC2: High-Performance Garbage Collection for Memory-Constrained EnvironmentsEmery Berger
 
Vam: A Locality-Improving Dynamic Memory Allocator
Vam: A Locality-Improving Dynamic Memory AllocatorVam: A Locality-Improving Dynamic Memory Allocator
Vam: A Locality-Improving Dynamic Memory AllocatorEmery Berger
 
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory ManagementQuantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory ManagementEmery Berger
 
Garbage Collection without Paging
Garbage Collection without PagingGarbage Collection without Paging
Garbage Collection without PagingEmery Berger
 

Plus de Emery Berger (20)

Doppio: Breaking the Browser Language Barrier
Doppio: Breaking the Browser Language BarrierDoppio: Breaking the Browser Language Barrier
Doppio: Breaking the Browser Language Barrier
 
Dthreads: Efficient Deterministic Multithreading
Dthreads: Efficient Deterministic MultithreadingDthreads: Efficient Deterministic Multithreading
Dthreads: Efficient Deterministic Multithreading
 
Programming with People
Programming with PeopleProgramming with People
Programming with People
 
Stabilizer: Statistically Sound Performance Evaluation
Stabilizer: Statistically Sound Performance EvaluationStabilizer: Statistically Sound Performance Evaluation
Stabilizer: Statistically Sound Performance Evaluation
 
DieHarder (CCS 2010, WOOT 2011)
DieHarder (CCS 2010, WOOT 2011)DieHarder (CCS 2010, WOOT 2011)
DieHarder (CCS 2010, WOOT 2011)
 
Operating Systems - Advanced File Systems
Operating Systems - Advanced File SystemsOperating Systems - Advanced File Systems
Operating Systems - Advanced File Systems
 
Operating Systems - File Systems
Operating Systems - File SystemsOperating Systems - File Systems
Operating Systems - File Systems
 
Operating Systems - Networks
Operating Systems - NetworksOperating Systems - Networks
Operating Systems - Networks
 
Operating Systems - Queuing Systems
Operating Systems - Queuing SystemsOperating Systems - Queuing Systems
Operating Systems - Queuing Systems
 
Operating Systems - Distributed Parallel Computing
Operating Systems - Distributed Parallel ComputingOperating Systems - Distributed Parallel Computing
Operating Systems - Distributed Parallel Computing
 
Operating Systems - Concurrency
Operating Systems - ConcurrencyOperating Systems - Concurrency
Operating Systems - Concurrency
 
Operating Systems - Advanced Synchronization
Operating Systems - Advanced SynchronizationOperating Systems - Advanced Synchronization
Operating Systems - Advanced Synchronization
 
Operating Systems - Synchronization
Operating Systems - SynchronizationOperating Systems - Synchronization
Operating Systems - Synchronization
 
Processes and Threads
Processes and ThreadsProcesses and Threads
Processes and Threads
 
Virtual Memory and Paging
Virtual Memory and PagingVirtual Memory and Paging
Virtual Memory and Paging
 
Operating Systems - Virtual Memory
Operating Systems - Virtual MemoryOperating Systems - Virtual Memory
Operating Systems - Virtual Memory
 
MC2: High-Performance Garbage Collection for Memory-Constrained Environments
MC2: High-Performance Garbage Collection for Memory-Constrained EnvironmentsMC2: High-Performance Garbage Collection for Memory-Constrained Environments
MC2: High-Performance Garbage Collection for Memory-Constrained Environments
 
Vam: A Locality-Improving Dynamic Memory Allocator
Vam: A Locality-Improving Dynamic Memory AllocatorVam: A Locality-Improving Dynamic Memory Allocator
Vam: A Locality-Improving Dynamic Memory Allocator
 
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory ManagementQuantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
 
Garbage Collection without Paging
Garbage Collection without PagingGarbage Collection without Paging
Garbage Collection without Paging
 

Dernier

APRIL2024_UKRAINE_xml_0000000000000 .pdf
APRIL2024_UKRAINE_xml_0000000000000 .pdfAPRIL2024_UKRAINE_xml_0000000000000 .pdf
APRIL2024_UKRAINE_xml_0000000000000 .pdfRbc Rbcua
 
Unveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic ExperiencesUnveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic ExperiencesDoe Paoro
 
Guide Complete Set of Residential Architectural Drawings PDF
Guide Complete Set of Residential Architectural Drawings PDFGuide Complete Set of Residential Architectural Drawings PDF
Guide Complete Set of Residential Architectural Drawings PDFChandresh Chudasama
 
Darshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfDarshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfShashank Mehta
 
Healthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare NewsletterHealthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare NewsletterJamesConcepcion7
 
20200128 Ethical by Design - Whitepaper.pdf
20200128 Ethical by Design - Whitepaper.pdf20200128 Ethical by Design - Whitepaper.pdf
20200128 Ethical by Design - Whitepaper.pdfChris Skinner
 
Entrepreneurship lessons in Philippines
Entrepreneurship lessons in  PhilippinesEntrepreneurship lessons in  Philippines
Entrepreneurship lessons in PhilippinesDavidSamuel525586
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfJamesConcepcion7
 
Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...Peter Ward
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdfShaun Heinrichs
 
EUDR Info Meeting Ethiopian coffee exporters
EUDR Info Meeting Ethiopian coffee exportersEUDR Info Meeting Ethiopian coffee exporters
EUDR Info Meeting Ethiopian coffee exportersPeter Horsten
 
WSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfWSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfJamesConcepcion7
 
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...Operational Excellence Consulting
 
Excvation Safety for safety officers reference
Excvation Safety for safety officers referenceExcvation Safety for safety officers reference
Excvation Safety for safety officers referencessuser2c065e
 
BAILMENT & PLEDGE business law notes.pptx
BAILMENT & PLEDGE business law notes.pptxBAILMENT & PLEDGE business law notes.pptx
BAILMENT & PLEDGE business law notes.pptxran17april2001
 
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...SOFTTECHHUB
 
digital marketing , introduction of digital marketing
digital marketing , introduction of digital marketingdigital marketing , introduction of digital marketing
digital marketing , introduction of digital marketingrajputmeenakshi733
 
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...Associazione Digital Days
 

Dernier (20)

APRIL2024_UKRAINE_xml_0000000000000 .pdf
APRIL2024_UKRAINE_xml_0000000000000 .pdfAPRIL2024_UKRAINE_xml_0000000000000 .pdf
APRIL2024_UKRAINE_xml_0000000000000 .pdf
 
Unveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic ExperiencesUnveiling the Soundscape Music for Psychedelic Experiences
Unveiling the Soundscape Music for Psychedelic Experiences
 
Guide Complete Set of Residential Architectural Drawings PDF
Guide Complete Set of Residential Architectural Drawings PDFGuide Complete Set of Residential Architectural Drawings PDF
Guide Complete Set of Residential Architectural Drawings PDF
 
Darshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfDarshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdf
 
Healthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare NewsletterHealthcare Feb. & Mar. Healthcare Newsletter
Healthcare Feb. & Mar. Healthcare Newsletter
 
20200128 Ethical by Design - Whitepaper.pdf
20200128 Ethical by Design - Whitepaper.pdf20200128 Ethical by Design - Whitepaper.pdf
20200128 Ethical by Design - Whitepaper.pdf
 
Entrepreneurship lessons in Philippines
Entrepreneurship lessons in  PhilippinesEntrepreneurship lessons in  Philippines
Entrepreneurship lessons in Philippines
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdf
 
Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...
 
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptxThe Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf
 
EUDR Info Meeting Ethiopian coffee exporters
EUDR Info Meeting Ethiopian coffee exportersEUDR Info Meeting Ethiopian coffee exporters
EUDR Info Meeting Ethiopian coffee exporters
 
WSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfWSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdf
 
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
 
Excvation Safety for safety officers reference
Excvation Safety for safety officers referenceExcvation Safety for safety officers reference
Excvation Safety for safety officers reference
 
BAILMENT & PLEDGE business law notes.pptx
BAILMENT & PLEDGE business law notes.pptxBAILMENT & PLEDGE business law notes.pptx
BAILMENT & PLEDGE business law notes.pptx
 
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
 
digital marketing , introduction of digital marketing
digital marketing , introduction of digital marketingdigital marketing , introduction of digital marketing
digital marketing , introduction of digital marketing
 
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
Lucia Ferretti, Lead Business Designer; Matteo Meschini, Business Designer @T...
 
WAM Corporate Presentation April 12 2024.pdf
WAM Corporate Presentation April 12 2024.pdfWAM Corporate Presentation April 12 2024.pdf
WAM Corporate Presentation April 12 2024.pdf
 

Reconsidering Custom Memory Allocation Techniques

  • 1. Reconsidering Custom Memory Allocation Emery Berger, Ben Zorn, Kathryn McKinley UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE
  • 2. Custom Memory Allocation Programmers replace Very common practice   new/delete, bypassing Apache, gcc, lcc, STL,  system allocator database servers… Language-level Reduce runtime – often   support in C++ Expand functionality – sometimes  Widely recommended Reduce space – rarely   “Use custom allocators” UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 2
  • 3. Drawbacks of Custom Allocators Avoiding system allocator:  More code to maintain & debug  Can’t use memory debuggers  Not modular or robust:  Mix memory from custom  and general-purpose allocators → crash! Increased burden on programmers  Are custom allocators really a win? UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 3
  • 4. Overview Introduction  Perceived benefits and drawbacks  Three main kinds of custom allocators  Comparison with general-purpose allocators  Advantages and drawbacks of regions  Reaps – generalization of regions & heaps  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 4
  • 5. (1) Per-Class Allocators Recycle freed objects from a free list  a = new Class1; Class1 Fast free list b = new Class1; + c = new Class1; Linked list operations + a delete a; Simple + delete b; Identical semantics b + delete c; C++ language support + a = new Class1; c Possibly space-inefficient b = new Class1; - c = new Class1; UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 5
  • 6. (II) Custom Patterns Tailor-made to fit allocation patterns  Example: 197.parser (natural language parser)  db a c char[MEMORY_LIMIT] end_of_array end_of_array end_of_array end_of_array end_of_array a = xalloc(8); Fast + b = xalloc(16); Pointer-bumping allocation + c = xalloc(8); - Brittle xfree(b); - Fixed memory size xfree(c); - Requires stack-like lifetimes d = xalloc(8); UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 6
  • 7. (III) Regions Separate areas, deletion only en masse  regioncreate(r) r regionmalloc(r, sz) regiondelete(r) - Risky Fast + - Dangling Pointer-bumping allocation + references Deletion of chunks + - Too much space Convenient + One call frees all memory + Increasingly popular custom allocator  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 7
  • 8. Overview Introduction  Perceived benefits and drawbacks  Three main kinds of custom allocators  Comparison with general-purpose allocators  Advantages and drawbacks of regions  Reaps – generalization of regions & heaps  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 8
  • 9. Custom Allocators Are Faster… Runtime - Custom Allocator Benchmarks Custom Win32 1.75 Normalized Runtime non-regions regions 1.5 1.25 1 0.75 0.5 0.25 0 r he er lle ze m c c vp gc lc rs si ud ac ee 5. 6. d- pa m 17 ap br 17 xe 7. c- bo 19 As good as and sometimes much faster than Win32  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 9
  • 10. Not So Fast… Runtime - Custom Allocator Benchmarks Custom Win32 DLmalloc 1.75 non-regions regions Normalized Runtime 1.5 1.25 1 0.75 0.5 0.25 0 lle e r he c r m c vp e lc z gc si ud rs ee ac 5. d- 6. pa m br 17 ap 17 xe 7. c- bo 19 DLmalloc: as fast or faster for most benchmarks  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 10
  • 11. The Lea Allocator (DLmalloc 2.7.0) Mature public-domain general-purpose  allocator Optimized for common allocation patterns  Per-size quicklists ≈ per-class allocation  Deferred coalescing  (combining adjacent free objects) Highly-optimized fastpath  Space-efficient  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 11
  • 12. Space Consumption: Mixed Results Space - Custom Allocator Benchmarks Custom DLmalloc 1.75 non-regions regions Normalized Space 1.5 1.25 1 0.75 0.5 0.25 0 lle e r he c r sim c vp e lc z gc ud rs ee ac 5. d- 6. pa m br 17 ap 17 xe 7. c- bo 19 UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 12
  • 13. Overview Introduction  Perceived benefits and drawbacks  Three main kinds of custom allocators  Comparison with general-purpose allocators  Advantages and drawbacks of regions  Reaps – generalization of regions & heaps  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 13
  • 14. Regions – Pros and Cons Fast, convenient, etc. + Avoid resource leaks (e.g., Apache) + Tear down memory for terminated connections  No individual object deletion - Unbounded memory consumption  (producer-consumer, long-running computations, off-the-shelf programs)  Apache: vulnerable to DoS, memory leaks UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 14
  • 15. Reap Hybrid Allocator Reap = region + heap  Adds individual object deletion & heap  reapcreate(r) r reapmalloc(r, sz) reapfree(r,p) reapdelete(r) Can reduce memory consumption + Fast + Adapts to use (region or heap style) + Cheap deletion + UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 15
  • 16. Reap Runtime Runtime - Custom Allocation Benchmarks Custom Win32 DLmalloc Reap 1.75 Normalized runtime non-regions regions 1.5 1.25 1 0.75 0.5 0.25 0 lle e r he c r im c vp e lc z gc ud rs ee -s ac 5. 6. pa d m br 17 ap 17 xe 7. c- bo 19 UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 16
  • 17. Reap Space Space - Custom Allocator Benchmarks Custom DLmalloc Reap 1.75 non-regions regions Normalized Space 1.5 1.25 1 0.75 0.5 0.25 0 lle e r he c r sim c vp e lc z gc ud rs ee ac 5. d- 6. pa m br 17 ap 17 xe 7. c- bo 19 UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 17
  • 18. Reap: Best of Both Worlds Allows mixing of regions and new/delete  Case study:   New Apache module “mod_bc” bc: C-based arbitrary-precision calculator  Changed 20 lines out of 8000  Benchmark: compute 1000th prime  With Reap: 240K  Without Reap: 7.4MB  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 18
  • 19. Conclusions and Future Work Empirical study of custom allocators  Lea allocator often as fast or faster  Non-region custom allocation ineffective  Reap: region performance without drawbacks  Future work:  Reduce space with per-page bitmaps  Combine with scalable general-purpose  allocator (e.g., Hoard) UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 19
  • 20. Software http://www.cs.umass.edu/~emery (Reap: part of Heap Layers distribution) http://g.oswego.edu (DLmalloc 2.7.0) UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 20
  • 21. If You Can Read This, I Went Too Far UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 21
  • 22. Backup Slides UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 22
  • 23. Experimental Methodology Comparing to general-purpose  allocators Same semantics: no problem  E.g., disable per-class allocators  Different semantics: use emulator  Uses general-purpose allocator   Adds bookkeeping to support region semantics UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 23
  • 24. Why Did They Do That? Recommended practice  Premature optimization  Microbenchmarks vs. actual performance  Drift  Not bottleneck anymore  Improved competition  Modern allocators are better  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 24
  • 25. Reaps as Regions: Runtime Runtime - Region-Based Benchmarks Custom Win32 DLmalloc Reap 1.75 1.5 Normalized Runtime 1.25 1 0.75 0.5 0.25 0 lcc mudlle Reap performance nearly matches regions  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 25
  • 26. Using Reap as Regions Runtime - Region-Based Benchmarks Original Win32 DLmalloc WinHeap Vmalloc Reap 4.08 2.5 2 Normalized Runtime 1.5 1 0.5 0 lcc mudlle Reap performance nearly matches regions UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 26
  • 27. Drawbacks of Regions Can’t reclaim memory within regions  Bad for long-running computations,  producer-consumer patterns, “malloc/free” programs unbounded memory consumption  Current situation for Apache:  vulnerable to denial-of-service  limits runtime of connections  limits module programming  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 27
  • 28. Use Custom Allocators? Strongly recommended by practitioners  Little hard data on performance/space  improvements Only one previous study [Zorn 1992]  Focused on just one type of allocator  Custom allocators: waste of time  Small gains, bad allocators  Different allocators better? Trade-offs?  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 28
  • 29. Kinds of Custom Allocators Three basic types of custom allocators  Per-class  Fast  Custom patterns  Fast, but very special-purpose  Regions  Fast, possibly more space-efficient  Convenient  Variants: nested, obstacks  UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 29
  • 30. Optimization Opportunity Time Spent in Memory Operations Memory Operations Other 100 % of runtime 80 60 40 20 0 sim ll e lcc ze cc e e pr r se ag h ud v g e ac d- 5. ar 6. re er m ap 17 xe 17 p b Av 7. c- bo 19 UNIVERSITY OF MASSACHUSETTS • DEPARTMENT OF COMPUTER SCIENCE 30