identifying logically related regions of the heap
DESCRIPTION
Identifying Logically Related Regions of the Heap. Mark Marron 1 , Deepak Kapur 2 , Manuel Hermenegildo 1 1 Imdea-Software (Spain) 2 University of New Mexico . Overview. Want to identify regions (sets of objects) that are conceptually related Conceptually related - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/1.jpg)
1
Identifying Logically Related Regions of the Heap
Mark Marron1, Deepak Kapur2,Manuel Hermenegildo1
1Imdea-Software (Spain) 2University of New Mexico
![Page 2: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/2.jpg)
2
Want to identify regions (sets of objects) that are conceptually related
Conceptually related• Same recursive data structure• Stored in equivalent locations (e.g., same array)
Extract information via static analysis Apply memory optimizations on regions
instead of over entire heap• Region Allocation/Collection• Region/Parallel GC• Optimized Layout
Overview
![Page 3: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/3.jpg)
3
Must be Dynamic• Variable based partitions too coarse, do not
represent composition well.• Allocation site based too imprecise, can cause
spurious grouping of objects. Must be Repartitionable• Want to track program splitting and merging
regions: list append, subset operations.
Region Representation
![Page 4: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/4.jpg)
4
Base on storage shape graph• Nodes represent sets of objects (or recursive data
structures), edges represent sets of pointers• Has natural representation heap regions and
relations between them• Efficient
Annotate nodes and edges with additional instrumentation properties• For region identification only need type
information
Explicit Representation Model
![Page 5: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/5.jpg)
5
Recursive Structures• Group objects representing same recursive
structure, keep distinct from other recursive structures
References• Group objects stored in similar sets of locations
together (objects in A, in B, both A and B) Composite Structures• Group objects in each subcomponent, group
similar components hierarchically
Region Concepts
![Page 6: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/6.jpg)
6
The general approach taken to Identifying Recursive Data Structures is well known• Look at type information to determine which
objects may be part of a recursive structure• Based on connectivity group these recursive
objects together Two subtle distinctions made in this work• Only group objects in complete recursive
structure• Ignore back pointers in computing complete
recursive structures
Recursive Structures
![Page 7: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/7.jpg)
7
Em3d: Back Edges
class Enode{ Enode[] fromN; …}
![Page 8: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/8.jpg)
8
The grouping of objects that are in the same container or related composite structures is more difficult
Given regions R, R’ when do they represent conceptually equivalent sets of objects• Stored in the same types of locations (variables,
collections, referred to by same object fields)• Have same type of recursive signature (can split
leaf contents of recursive structures from internal recursive component)
Composite Struct./Containers
![Page 9: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/9.jpg)
9
Storage Location Similarity
![Page 10: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/10.jpg)
10
Case Study BH (Barnes-Hut) N-Body Simulation in 3-dimensions Uses Fast Multi-Pole method with space
decomposition tree• For nearby bodies use naive n2 algorithm• For distant bodies compute center of mass of
many bodies and treat as single point mass
![Page 11: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/11.jpg)
11
![Page 12: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/12.jpg)
12
Main Execution Loopfor(…) { root = null; makeTree();
Iterator<Body> bm = this.bodyTabRev.iterator(); while(bm.hasNext()) bm.next().hackGravity(root);
Iterator<Body> bp = this.bodyTabRev.iterator(); while(bm.hasNext()) bm.next().propUpdatedAccel();}
![Page 13: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/13.jpg)
Statically collect, space decomposition tree and all MathVector/double[] objects (11% of GC work).
Static Collection: root = null
13
![Page 14: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/14.jpg)
GC objects reachable from the acc/vel fields in parallel with the hackGravity method (no overhead).
Parallel Collection: hackGravity
14
![Page 15: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/15.jpg)
Inline Double[] into MathVector objects, 23% serial speedup 37% memory use reduction.
Object Inline
15
![Page 16: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/16.jpg)
16
Benchmark
LOC Analysis Time
Analysis Memory
Region Ok
tsp 910 0.03s <30 MB Yem3d 1103 0.09s <30 MB Yvoronoi 1324 0.50s <30 MB Ybh 2304 0.72s <30 MB Ydb 1985 0.68s <30 MB Yraytrace 5809 15.5s 38 MB Yexp 3567 152.3s 48 MB Ydebug 15293 114.8s 122 MB Y
Benchmark Analysis Statistics
![Page 17: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/17.jpg)
17
Simple interpreter and debug environment for large subset of Java language
14,000+ Loc (in normalized form), 90 Classes• Additional 1500 Loc for specialized standard
library handling stubs. Large recursive call structures, large
inheritance trees with numerous virtual method implementations
Wide range of data structure types, extensive use of java.util collections, heap contains both shared and unshared structures.
Debug Benchmark
![Page 18: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/18.jpg)
18
Region Information provides excellent basis for driving many memory optimizations and supporting other analysis work
A simple set of heuristics (when taking into account a few subtleties) is sufficient for grouping memory objects
Recent work shows excellent scalability on non-trivial programs
Further work on developing robust infrastructure for further evaluation and applications
Conclusion and Future Work
![Page 19: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/19.jpg)
19
![Page 20: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/20.jpg)
20
Many programs (particularly OO programs) use back pointers to parent objects• Makes type recursive even though structure is
finite• Can lead to grouping many structures that are
conceptually distinct in the program• Simply ignore them based on depth from roots
Similarly want to wait until structures are finished before merging them• Preserves analysis precision during construction
of recursive structures• Prevents grouping of objects that have recursive
types but are used in finite heap structures
Back Pointers + Partial Strucures
![Page 21: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/21.jpg)
21
Using heuristics based on declared type information and connectivity group• Objects that make up recursive data structures• Objects that are stored in the same sets of
containers (arrays, java.util collections)• Objects that are in the same kind of composite
structure Use incremental approach to identify these
structures (for efficiency in dataflow analysis)
General Approach
![Page 22: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/22.jpg)
22
Example: Arithmatic Exp.exp
vars
Heap
![Page 23: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/23.jpg)
23
Example: Arithmatic Exp.exp
vars
{+, -, *, /}
{Const}
{Var}
{Var[]}
![Page 24: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/24.jpg)
24
Example: Exp
![Page 25: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/25.jpg)
25
Merge nodes 2 and 5
![Page 26: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/26.jpg)
26
Finish Recursive Merge
![Page 27: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/27.jpg)
27
Merge Edges 9 and 6
![Page 28: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/28.jpg)
28
Merge Nodes 7 and 8
![Page 29: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/29.jpg)
29
We have the core of a practical heap analysis technique• Performance:
Analyze moderate size non-trivial Java programs Runtime on the order of 10s of seconds Recent work should improve scalability
• Accuracy: Precisely represent connectivity, sharing, shape
properties + region and dependence information• Qualitatively Useful
Used results in multiple optimization domains Want to apply tool to other problems, work on
improvements in frontend, IR and exporting results
Wrap-Up and Future Work
![Page 30: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/30.jpg)
Demo of the shape analysis and benchmark code available at:
www.cs.unm.edu/~marron/software.html
![Page 31: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/31.jpg)
31
Example: Arithmatic Exp.exp
vars
Heap
{+, -, *, /}
![Page 32: Identifying Logically Related Regions of the Heap](https://reader036.vdocuments.us/reader036/viewer/2022062520/568164c8550346895dd6e015/html5/thumbnails/32.jpg)
32
Example: Arithmatic Exp.exp
varsHeap
{+, -, *, /}
{Const}
{Var}