Deploying AOT compiled libraries?

The significant downside of AOT’ed code is that it is inherently the product of a particular version of the Clojure compiler. While we do try pretty hard not to break the runtime interface (particularly stuff like the RT and Reflector APIs) we don’t exhaustively test for that.

In general, I would recommend NOT AOT compiling libraries (or at least not only distributing that). In a few cases we publish contrib libs under both source and AOT version (with “aot” classifier). Also, there are issues around loading related to having AOT libs that depend on non-AOT libs. If you want better performance at the app level, I think it’s pretty reasonable to AOT a final app uber jar as that avoids most of the issues with most of the benefits.

Rich and I have been kicking around some interesting ideas on a class compilation cache that would be integrated with core and that research is in scope for Clojure 1.10 but no guarantees on anything. Potentially it would combine the benefits of publishing source-only but the performance of AOT. It is inherently silly to recompile the same lib source file over and over when it’s not changing.

8 Likes