What is harder about saving a Julia session via the REPL whenever?

To achieve this, you can cache compiled machine codes only instead of all the states. But this is basically what PackageCompiler does.

It’s feasible to do this as long as you don’t do this for Main module. Main module is unstable and you should not cache it (definitions may change between sessions). But you have mentioned that you don’t want to develop new codes, so this is not a limitation.

So I guess what you want is like this:

  1. Execute some Julia codes in REPL, which is some function calls to other libraries, for example, Plots.plot.
  2. The compiled binary codes and other necessary serializable runtime metadata are cached.
  3. The next time you open REPL, you re-execute you script to set up those runtime you don’t want to cache, and then these compiled codes are loaded. You don’t need to recompile them, so a lot of time is saved.

If this is what you want, then it can be achieved (as long as you don’t save the global and definitions, you can always reexecute them for they take less time compared to compilation). I have a private fork of Julia’s compiler for this kind of binary cache, which utilizes LLVM’s new linking architecture. It indeed works much like what you just said in this thread. And it has all the limitations I mentioned above, it just works as long as you don’t do strange things.

2 Likes