Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Improving Performance and Maintainability of Ob...

Improving Performance and Maintainability of Object Cloning with Lazy Clones: An Empirical Evaluation

Bruno Cartaxo

October 23, 2015
Tweet

More Decks by Bruno Cartaxo

Other Decks in Research

Transcript

  1. CONTEXT • Domain-specific static analysis tool which deals with complex

    data structures that are cloned frequently. • Cloning objects is not only an error-prone and hard to maintain activity, but also can hinder system performance and has some well known inherent flaws [1]. • We conducted an investigation about object cloning to make an evidence-based design decision. • Key drivers • High performance; • Low memory usage; • High code maintainability. 2 1 - Joshua Bloch. Effective Java. 2nd Edition, 2008.
  2. CLONING APPROACHES • Shallow • Pros: simple implementation • Cons:

    undesirable side effects • Deep • Pros: avoid undesirable side effects • Cons: performance penalties and high memory usage • LAZY – novel approach • Pros: consumes only the necessary memory and improves performance avoiding unnecessary clone operations • Cons: undesirable behavior for non-previsible mutable objects 4 original clone DEEP original clone SHALLOW
  3. CLONING IMPLEMENTATIONS • Deep • Dynamic Allocation (DA) • Reflection

    (R) • Serialization (S) • LAZY – proposed implementations • Dynamic Proxies (DP) • Aspect-Oriented Programming (AOP) 5
  4. EXPERIMENTAL SET UP • Real and synthetic workloads to evaluate

    each cloning implementation • Synthetic workloads were useful to simulate each implementation on hypothetic scenarios • Measurement Tools • Execution time: JMH¹ • Memory usage: Memory Analyzer² • To evaluate the impact on source code we counted the number of modified LOC to introduce each implementation 7 1 - http://openjdk.java.net/projects/code-tools/jmh/ 2 - http://www.eclipse.org/mat/
  5. • Best case: none of clone’s field is accessed. •

    Medium case: heaviest fields accesses pattern from the real workload. • Worst case: entire clone’s graph of fields is accessed. SYNTHETIC WORKLOAD RESULTS Memory Usage (bytes) Execution time (µs) 19 45 44 112 159 248 244 259 248 23 119 364 6 39 261 0 50 100 150 200 250 300 350 400 Best Case Medium Case Worst Case AOP DP S R DA DA R S DP AOP 51 0 2 8 2 Modified LOC 4560 4560 4560 4560 4560 4560 5032 5032 5032 104 984 6184 80 560 4560 0 1000 2000 3000 4000 5000 6000 7000 Best Case Medium Case Worst Case AOP DP S R DA
  6. 10 plot based on the medium case of the synthetic

    workload SYNTHETIC WORKLOAD RESULTS
  7. CONCLUDING REMARKS • Contributions • Two new implementations (AOP and

    DP) of object cloning based on the lazy approach. • The results can help developers to make evidence-based design decisions when faced with problems that require object cloning. • AOP implementation can be an alternative when high performance and low memory usage are demanded without compromise code maintainability. • For non-previsible mutable objects lazy approach is not recommended. 11