Scalable Context-Sensitive Points-to Analysis Using Multi-dimensional Bloom Filters
Summary (3 min read)
1 Introduction
- Pointer analysis enables many compiler optimization opportunities and remains as one of the most important compiler analyses.
- The objective of a context-sensitive points-to analysis is to construct, for each pointer and context, a set containing all the memory locations that the pointer can point to in that context.
- The third dimension (hash functions) is essential to control loss in precision.
- In effect, multibloom significantly reduces the memory requirement with a very low probabilistically bound loss in precision.
- The major contributions of this paper are: – We propose a multi-dimensional bloom filter that can compactly represent the points-to information with almost no loss in precision.the authors.the authors.
2 Background
- General purpose languages like C pose many challenges to the compiler community.
- Use of pointers hinders many compiler optimizations.
- Pointers with multiple indirections, pointers to functions, etc. only add to these challenges.
- The authors analysis handles all aspects of C (including recursion), except variable number of arguments.
2.1 Context-Sensitive Points-to Analysis
- A context-sensitive points-to analysis distinguishes between various calling contexts of a program and thus, is able to more accurately determine the points-to information compared to the context-insensitive version [5].
- The number of distinct paths from main to the leaf nodes in the graph is equal to the number of different contexts the program has.
- Therefore, for a context-sensitive points-to analysis, the number of points-to tuples can be exponential (in the number of functions in the program).
- Reducing the storage requirements of a context-sensitive points-to analysis has attracted much research in pointer analysis.
- Absolute values of memory and time required are substantially high.
2.2 Bloom Filter
- Note that element 3 also hashes to the same location as 13.
- This introduces false positives, as the membership query would return true for element 3 even if it is not inserted.
- The false positive rate can be reduced drastically by using multiple hash functions.
- P = (1/2)d (1 − nd N ) (1) This is under the assumption that the individual hash functions are random and different hash functions are independent.
- Unlike traditional data structures used in points-to analysis[5][8], time to insert elements in a bloom filter and to check for their membership is independent of the number of elements in the filter.
3 Points-to Analysis using Bloom Filters
- A naive implementation stores context-sensitive points-to tuples in a bloom filter by hashing the tuple 〈p, c, x〉 and setting that bit in the bloom filter.
- One way to solve this problem is to keep track of the set of all pointees .
- This way, the query FindPointsTo(p, c) to find the points-to set for a pointer p under context c is answered by checking the bits that are set for each of the pointees.
- It requires storing all possible pointees, making it storage inefficient.
3.1 Multi-Dimensional Bloom Filter
- The proposed multi-dimensional bloom filter is a generalization of the basic bloom filter introduced in Section 2.2.
- To obtain a good balance of storage requirement, analysis time and precision, the authors employ a combination of the above two techniques.
- The conservative strategy results in little precision loss considering that less than 1% of all dynamic pointer statements contain more than two levels of pointer indirections (obtained empirically).
- Extending multibloom for two-level pointers makes it look like mb[P ][S][C][D][B] where S is the number of entries for pointers that are pointees of a two-level pointer.
- Therefore the number of entries per bloom filter would be twice the average number of pointees per context-wise pointer.
4.1 Implementation Details and Experimental Setup
- All their implementation is done in the LLVM compiler infrastructure[13] and the analysis is run as a post linking phase.
- Neither version implements optimizations like offline variable substitution[16].
- Their characteristics are given in Table 1.
- The authors empirically found that the number of entries S for pointers pointed to by two-level pointers gives a good trade off between memory and precision for S = 5.
- From now on, when the authors report the results, they refer to the multibloom configuration by the tuple (C−D−B).
4.2 Tradeoff between Precision, Memory and Analysis Time
- In Tables 3-4 the authors report the precision, time and memory requirements for various benchmarks.
- At the other end, medium and large config- urations achieve full precision for all the benchmarks with significant savings in memory requirement for those requiring at least 15MB memory.
- For larger benchmarks the authors see significant improvements in analysis time using bloom filter.
- One unique advantage of using multibloom is the user-control over various parameters to trade off precision for memory or vice versa.
- The authors observe that with at most 1% reduction in average precision, they can obtain around 18% reduction in average memory requirement.
4.3 Mod/Ref Analysis as a Client to Points-to Analysis
- Next the authors analyze how the loss in precision in the points-to analysis due to false positives affect the client analyses.
- The authors use the Mod/Ref analysis as the client of their multibloom based points-to analysis.
- For a query GetModRef(callsite, pointer), the Mod/Ref analysis checks whether callsite reads or modifies the memory pointed to by pointer.
- From the figure, it can be seen that the NoModRef percentage with multibloom is 96.9% of the exact analysis even with a tiny configuration.
- For scalable analyses, one can reduce these values trading off some precision.
6 Conclusions
- In this paper the authors propose the use of multi-dimensional bloom filter for storing points-to information.
- The proposed representation, though, may introduce false positives, significantly reduces the memory requirement and provides a probabilistic lower bound on loss of precision.
- With average 4MB memory, multibloom achieves almost the same (98.6%) precision as the exact analysis taking about average 4 minutes per benchmark.
- Using Mod/Ref analysis as the client, the authors find that the client analysis is not affected that often even with some loss of precision in points-to representation.
- The authors approach, for the first time, provides user a control on the memory requirement, yet giving a probabilistic lower bound on the loss in precision.
Did you find this useful? Give us your feedback
Citations
21 citations
17 citations
Cites background from "Scalable Context-Sensitive Points-t..."
...[23,21] hashed contexts to alleviate the need to store complete context information....
[...]
13 citations
Cites background or methods from "Scalable Context-Sensitive Points-t..."
...[11] hashed contexts to alleviate the need to store the complete context information....
[...]
...For our experiments, we use the medium configuration [11] which results in less than 2% precision loss for the chosen benchmarks....
[...]
...analysis [1], BDD-based Lazy Cycle Detection [10], Deep Propagation [7] and Bloom Filters [11]) for SPEC 2000 benchmarks and five large open source programs (httpd, sendmail, gdb, wine-server and ghostscript) (Section V)....
[...]
...· We show the effectiveness of our approach by applying it on top of the state-of-the-art algorithms (Andersen s analysis [1], BDD-based Lazy Cycle Detection [10], Deep Propagation [7] and Bloom Filters [11]) for SPEC 2000 benchmarks and .ve large open source programs (httpd, sendmail, gdb, wine-server and ghostscript) (Sec tion V)....
[...]
12 citations
12 citations
Cites background from "Scalable Context-Sensitive Points-t..."
...The idea of context-sensitive approach [20,33] is to produce a points-to relation for the context of each call site of each procedure....
[...]
References
7,390 citations
"Scalable Context-Sensitive Points-t..." refers background or methods in this paper
...However, using the bloom filter as originally proposed in [10] is not efficient for a context sensitive analysis....
[...]
...A bloom filter is a probabilistic data structure used to store a set of elements and test the membership of a given element[10]....
[...]
...The false positive rate P for a bloom filter of size N bits after n elements are added to the filter with d hash functions is given by Equation 1 (from [10])....
[...]
...This paper proposes a new way of representing points-to information using a special kind of bloom filter[10] that we call a multi-dimensional bloom filter....
[...]
2,174 citations
1,127 citations
"Scalable Context-Sensitive Points-t..." refers background or methods in this paper
...Many scalable pointer analysis algorithms are context- and flow-insensitive [1]....
[...]
...To handle store statement ∗q = p where p is a single-level pointer and q is a two-level pointer, the cube mb[P ][1] of p is bitwise-ORed with each cube mb[Q][i] of q, ∀i = 1....
[...]
...Several context-insensitive algorithms have been shown to scale well for large programs [1][2][3][4]....
[...]
...Since inclusion-based analyses are costly, several unificationbased algorithms were introduced, trading off precision for speed [1], [18]....
[...]
1,009 citations
"Scalable Context-Sensitive Points-t..." refers methods in this paper
...Both versions are implemented by extending Andersen’s algorithm [15] for contextsensitivity....
[...]
618 citations
"Scalable Context-Sensitive Points-t..." refers background or methods in this paper
...Recent research (see Related Work in Section 5) has focused on the scalability aspect of context-sensitive points-to analysis and achieves moderate success in that direction[9][4]....
[...]
...Several novel data structures have been used in the last decade to scale points-to analysis, like ROBDD[2][23][9], ZBDD[24]....
[...]
...For instance, in [9], most of the larger benchmarks require over 100 MB for points-to analysis....
[...]
...For instance, the number of methods in the open source program pmd is 1971, but it has 10(23) contextsensitive paths[9]....
[...]
...For instance, in [9], all the benchmarks having more than 10K methods (columba, gantt, jxplorer, jedit, gruntspud) require over 100MB of memory....
[...]
Related Papers (5)
Frequently Asked Questions (18)
Q2. What have the authors stated for future works in "Scalable context-sensitive points-to analysis using multi-dimensional bloom filters" ?
As a future work, it would be interesting to see the effect of approximation introduced using bloom filters with the approximations introduced in control-flow analyses such as kCFA or in unification of contexts.
Q3. What is the important aspect of pointer analysis?
context-sensitive pointer analysis improves precision at the cost of high — often unacceptable — storage requirement and analysis time.
Q4. What is the common query that is used for a point-to analysis?
For a query GetModRef(callsite, pointer), the Mod/Ref analysis checks whether callsite reads or modifies the memory pointed to by pointer.
Q5. What is the way to handle load statement?
To handle load statement p = ∗q where p is a single-level pointer and q is a two-level pointer, all the cubes mb[Q][i] (i.e., C × D × B bits) corresponding to pointer q, ∀i = 1..S are bitwise-ORed to get a resultant cube.
Q6. What is the meaning of a point-to-tuple?
A points-to tuple 〈p, c, x〉 represents a pointer p pointing to variable x in calling context c. A context is defined by a sequence of functions and their call-sites.
Q7. How does a naive implementation store tuples in a bloom filter?
A naive implementation stores context-sensitive points-to tuples in a bloom filter by hashing the tuple 〈p, c, x〉 and setting that bit in the bloom filter.
Q8. How many benchmarks run out of memory when the authors run an exact analysis?
Three out of the 18 benchmarks run out of memory when the authors run an exact analysis, highlighting the need for a scalable context-sensitive points-to analysis.
Q9. What enhancements have been made to the original Andersen’s inclusionbased algorithm?
Various enhancements have also been made to the original Andersen’s inclusionbased algorithm: online cycle elimination[20] to break dependence cycles on the fly, offline variable substitution[16] to reduce the number of pointers tracked during the analysis, location equivalence[21] and semi-sparse flow-sensitivity[22].
Q10. How many times does a multibloom fail to map the values?
To measure the false positive rate the authors will now try to map the values back from a 4-dimensional multibloom to a 2-dimensional bloom filter so that the authors can apply Equation 1.
Q11. How is the scalability of multibloom improved?
As scalability became an important factor with increasing code size, interesting mechanisms were introduced to approximate the precision of a full blowncontext-sensitive and flow-sensitive analysis. [17] proposed one level flow to improve precision of context-insensitive, flow-insensitive analyses, still maintaining the scalability.
Q12. What is the mapping function for hs?
4. The mapping function hs is defined as hs(p1) = 1 and hs(p2) = 2. Initially, all bits in the buckets for each pointer are set to 0.
Q13. What is the number of lines of code in a spec 2000 benchmark?
KLOC is the number of Kilo lines of code, Total Inst is the total number of static LLVM instructions, Pointer Inst is the number of static pointer-type LLVM instructions and No. of Fns is the number of functions in the benchmark.
Q14. What is the simplest way to handle a load statement?
It makes each pointer pointed to by q point to the pointees pointed to by p.Handling context-sensitive load/store statements requires a modification to address-of assignment p = &q.
Q15. How much memory is required for all benchmarks?
The memory requirement is three orders less, while the access time is reduced to about one-fourth for all benchmarks which take at least 20 seconds.
Q16. How many bits does the algorithm need to map to a given context?
For each hash function the algorithm needs to determine if the corresponding bit vectors have at least one common bit with the value 1.
Q17. How much precision can a client analysis enjoy?
This shows that a client analysis is hardly affected due to loss in precision by using an approximate representation, while still enjoying the benefits of reduced memory and time requirements.
Q18. What is the false positive rate for a bloom filter?
The false positive rate P for a bloom filter of size N bits after n elements are added to the filter with d hash functions is given by Equation 1 (from [10]).