Disclosure at the top, I’m asking a question here that is out of my depth, but I keep thinking about it and would really appreciate the thoughts of smart folks.
A while back, I watched this Strange Loop Talk on Unison, a distributed programming language. Unison’s “thing” is that it identifies functions, not by their name but, by the hash of their AST representation. So if you define two functions with the exact same args and body, it will only compile one, and functions that call either of them will actually point to the same function after compilation. It seems to work really well for the problem Unison is trying to solve which is fragmentation across distributed systems.
It got me thinking, could Julia leverage something like this to help with the (pre/re)compilation time problem. My best understanding of the current reason for long recompilation after updates is that the potential for invalidations and the complexity of many packages adding methods and such means you need to run compilation pretty naively since you don’t know if the body of any given function name is the same after an update.
What if the Expr that represents the lowered, inferred version of a specific method call was hashed and then the native code was then cached with that hash as its key. As long as the body of that function is not changed, then future recompilations could skip the native code gen step.
You could go a step further and replace all variable names with v1, v2, … vN before hashing, so renaming variables wouldn’t cause cache misses.
I’m totally expecting to learn that this is a bad idea for very good and obvious reasons, so thank you in advance for your patience.