Replies: 11 comments 27 replies
-
Going back to the "Producing wrong data without doing anything obviously wrong!" paper, do you think this paper did a good job in measuring their TBAA optimization? How did the authors select which benchmarks to run the optimizer on? Is this a fair choice, and if not, how should they choose the benchmarks? |
Beta Was this translation helpful? Give feedback.
-
How else can we leverage type systems for compiler optimizations? |
Beta Was this translation helpful? Give feedback.
-
When can we leverage upper bound analysis for compiler optimizations? When should we leverage them? |
Beta Was this translation helpful? Give feedback.
-
One thing I was kind of impressed with was being 2.5% within an optimal alias analysis, at least for RLE and the given benchmarks. It seems like there are a lot of more sophisticated things that could be added to improve precision (for example, using a flow-sensitive analysis) yet, at least in the observed executions of the benchmarks with RLE, there isn't much more room to improve. Another thing I discovered during the LLVM assignment that struck me as odd is that (recent versions of) LLVM only have a single opaque pointer type. Initially, I thought that could be because LLVM was originally designed for C and C++ and pointer types might be less useful for those languages. But I discovered that it used to have typed pointers, and only recently have they been fully removed. Although they mentioned pointee types were causing issues, this decision would definitely hamper the usage of a technique like TBAA. On the surface it seems like more information would be better, but clearly whatever problems it was causing outweighed any benefits. |
Beta Was this translation helpful? Give feedback.
-
It's interesting seeing alias analyses which take a different approach than the dataflow analysis we saw in class. I also liked that at each step, the authors tied their implementation to real-world languages, explaining how they would modify it for Java/C/C++. |
Beta Was this translation helpful? Give feedback.
-
I quite enjoyed this paper. At a first read, it makes total sense - pointers that have different types obviously can't alias. If they did, it must mean something really strange is going on with the program. In fact, the results alone to me indicate that we should actively pursue developing programming languages where this cannot happen. Or at the very least, if a programmer is going to force this behavior, they should be very explicit about what they are doing and ensure that they understand what is going on. Rust programmers probably like this idea :) In C, this is not necessarily a given. There's all sorts of dark magic we can do with pointers of different types. Here's a small example in C:
While this example is probably fine, you can imagine a lot more troublesome examples in other programs. I guess the question this poses, then, is to what extent do papers like these reflect the need to build programming languages that enforce these guarantees? If type-based alias analysis truly does just as well as any other kind of alias analysis, why should we ever build a language that doesn't make TBAA easy? |
Beta Was this translation helpful? Give feedback.
-
Type information provides a contractual guarantee about how variables and data structures will be used. The central thesis of type-based alias analysis is simple but interesting: pointers of different types, in many cases, don't alias. This seemingly basic observation has many implications for optimization. The authors, through empirical studies on real-world programs, found that different typed pointers often don't alias in practice. This finding makes type-based alias analysis an attractive alternative to more traditional, often computationally expensive methods. When implemented in an optimizing compiler, the type-based approach was shown to be competitive, and in some instances superior, to these traditional methods. This outcome was achieved with reduced computational overhead, making it an efficient and scalable solution. I’m curious, then, how we can use type systems to motivate other kinds of optimizations. For example, decisions about function inlining strongly depend on types, and you can also perform automatic parallelization. If the type system can prove that two data structures are distinct and will not alias, then operations on them can potentially be parallelized since there's a guarantee of no side effects between them. I’d love to keep exploring more of these optimizations that leverage strong types. |
Beta Was this translation helpful? Give feedback.
-
There was a super brief section on how some researchers used TBAA for execution-time improvements, and it got me thinking!! It was super interesting to me on how this alias analysis could happen for execution-time improvement. I was wondering if it would be possible at all to apply this to a language similar to Python? Don't really understand too much about underlying memory model of Python, but my understanding of Python is that its type system is duck-typing, which is more about what attributes the object has rather than the name of its type. One thought that came to mind was maybe that would look like classifying types by their attributes -- and then in order to remove copying of objects, we would compare values of attributes? Is that even feasible? And would the tradeoff of making the comparison be better than doing the actual copy? |
Beta Was this translation helpful? Give feedback.
-
I thought this paper offered an interesting look into the optimization of programs, particularly through RLE. What I found particularly intriguing was the paper's focus on not just the effectiveness but also the complexity of the TBAA algorithms. It's fascinating to see how the paper balances the trade-off between precision and computational efficiency, seemingly bringing us closer to the ideal of a "perfect" alias analysis. Given that the TBAA methods were nearly as effective as a perfect alias analysis in the context of RLE, could these methods be generalized to other types of program optimizations? |
Beta Was this translation helpful? Give feedback.
-
I am always amazed to see how far one can go by "just" including types in a program. This paper shows that by including types, and then increasing the granularity to consider the fields within an object, one can achieve a considerably high accuracy in pinpointing potential aliasing pairs. Interestingly, considering explicit assignments does not add a significant benefit in terms of the accuracy of the algorithm, which is evidence in support of how using types - and in this case, fields - orients the developer to write non-aliasing code. This reminds me of separation logic, and I know that it is being used for memory aliasing. It was helpful to see different metrics, and to realize that sometimes high or optimal analysis accuracy does not lead to a significant performance upgrade. However, perhaps there are use cases in which (bulk) performance is not the only issue of interest, and there are other things to look out for. For instance, perhaps a thorough algorithmic analysis of aliasing would be super helpful for a program including cryptography and secure data. Aliasing might lead to side channels in this case. As another example, perhaps there are paths in the program that are less frequently executed (depending on the nondeterminism of the program), and are therefore less reflected in the performance analysis. However, a developer might be concerned about the aliasing behavior of these paths for some reasons exogenous to performance, and therefore might be interested in a fine-grained aliasing information. |
Beta Was this translation helpful? Give feedback.
-
Considering the history of languages evolving to utilize type safety for reference correctness checks and compiler optimization alias information, it is interesting to compare to a more recent alias model for Rust called Stacked Borrows https://dl.acm.org/doi/10.1145/3371109 which defined a set of rules to extend reasoning into unsafe code to make useful analyses for a broader set of performant code useful to application developers. |
Beta Was this translation helpful? Give feedback.
-
Here's the discussion thread for 10/17's paper discussion on Alias-Based Optimization. The paper is here!
Edit: better paper URL
Beta Was this translation helpful? Give feedback.
All reactions