4 ms·
For some interesting backlog here: As Rust moves from lexical to non-lexical lifetimes, there's been a few different ways of actually implementing it. The initi
by steveklabnik 9y ago
For some interesting backlog here: As Rust moves from lexical to non-lexical lifetimes, there's been a few different ways of actually implementing it. The initial implementation had some bugs and was fairly slow; but Niko had some other ideas: http://smallcultfollowing.com/babysteps/blog/2018/04/27/an-alias-based-formulation-of-the-borrow-checker/ http://smallcultfollowing.com/babysteps/blog/2018/04/27/an-a...
The initial implementation used differential dataflow, but this was just merged in: https://github.com/rust-lang-nursery/polonius/pull/36#issuecomment-390393717 https://github.com/rust-lang-nursery/polonius/pull/36#issuec...
Very cool stuff!
- DannyBee 9y agoYes, this is a very traditional alias formulation of these sets of problems, and there is a lot of work in the past 10 years on expressing and computing aliasing like systems in datalog. I don't know about rust, but the cost of that abstraction elsewhere is pretty good. Datalog will beat basic implementations, and those that most researchers have time to implement handily. However, very well engineered purpose built solvers still beat datalog engines by a large factor (again, no theoretical reason this should be true, but it is), so production compilers still currently eat the complexity of building alias solvers. It would be nice if one day that was not true.
- tom_mellior 9y ago> However, very well engineered purpose built solvers still beat datalog engines by a large factor (again, no theoretical reason this should be true, but it is) Sure there is a reason: Many applications, alias analysis in particular, only use a subset of Datalog. Subsetting languages very often makes for easier and more efficient implementation. If you know that there is no negation in your alias problems, your special purpose solver can be much more efficient than a Datalog solver that must be prepared to deal with negation. Of course you might wish for a generic Datalog solver that you could run in a special mode where you promise that it will not encounter negation in the problem you give it. But that is then no longer a Datalog solver but a "well engineered purpose built solver". As for the "built in" part, anything that is not built in must cross an API boundary and usually translate between different data representations. That is a theoretical reason for being slower.
- Jweb_Guru 9y ago> But that is then no longer a Datalog solver but a "well engineered purpose built solver". I don't really agree. Specialized implementations for instances of a problem that can solved more efficiently than the general case are a pretty fundamental part of any mature solver (GMP is probably the most well-known example). This includes even cases where the user says to try the specialized algorithm and the solver checks that you indeed have an instance of it, rather than the specialized subproblem being automatically detected by the solver (there are many examples, but I always think of optimizations for read only transactions in databases--generally you have to declare the transaction read-only up front). > As for the "built in" part, anything that is not built in must cross an API boundary and usually translate between different data representations. That is a theoretical reason for being slower. The abstractions required for getting solvers to perform well on problems like this are usually sufficiently far removed from the representation you'd have had if you didn't have to solve the problem that (1) transforming it is only a small part of the overall time to solve, and (2) it is often a cost you already have to pay to some extent.
- DannyBee 9y agoFWIW: None of this is a theoretical reason. This is no different than the problems any other compiler/JIT faces. What you've offered are practical reasons it hasn't happened yet, but not theoretical reasons.
- tom_mellior 9y ago"System A must do more work than system B" seems a pretty theoretical reason why, in the limit (after sinking an arbitrary number of engineer hours in each), system A must be slower than system B. But your interpretations of the word "theoretical" may differ.
- frankmcsherry 9y agoI think the point is that there is no clear reason System A must do more work than System B. Serious Datalog environments will identify strictly monotonic programs and execute them more efficiently (e.g. with racy asynchrony); they will identify linear recursion and partition work accordingly. They could identify programs corresponding to DannyBee's hypothetical purpose-build industrial winners and execute them using the exact same techniques, but apparently they don't. I suspect the point of disagreement is > Of course you might wish for a generic Datalog solver that you could run in a special mode where you promise that it will not encounter negation in the problem you give it. But that is then no longer a Datalog solver but a "well engineered purpose built solver". which I don't think is correct. A Datalog solver with the property that it can run faster on certain classes of input is great; it is not "no longer a Datalog solver".
- dwtj 9y agoA few years ago as part of my MS program, I used Protobufs and Datalog to try to write program analyses over Java source code. I ended up implementing a simple alias analysis using this framework, and then drafting a paper--essentially a tutorial--about the design of analyses in this style; alias analysis was my detailed example. https://github.com/dwtj/deductive-points-to-analysis-paper/blob/master/Deductive%20Close-To-Source%20Points-To%20Analysis.pdf https://github.com/dwtj/deductive-points-to-analysis-paper/b...