Time to first plot clarification

I’m embarrassed to ask given that the phrase is used so often, but I was hoping someone could clarify the phrase time to first plot for me. My understanding is that the first time that a script is run that it can take a while to run because the code is being compiled; however, subsequent runs will be much, much faster as by that time the JIT compiler has done all the hard work.

My confusion is about when this applies. Is this only the case when repeatedly running a script at the REPL? Or, if I have a script — say myscript.jl — and I run it using julia myscript.jl at the command line, will it be slow the first time and quick thereafter? Or will it be slow each time, as it is considered to be the first time the script is run since it starts a new Julia session each time?

The TTFP penalty is paid every time you launch a new Julia executable. Currently, the only way to save the full results of compilation (for a particular set of methods) between Julia sessions is through PackageCompiler.jl. It’s infrequently used for interactive workflows (data exploration, plotting), because you seldom know exactly which set of methods you need to compile until you’re done fiddling around. If you’re working from the Julia REPL (or an IDE), the go-to choice for avoiding TTFP overhead is Revise.jl. If you need to run your scripts from the command line, you can use DaemonMode.jl to keep a Julia server process spinning in the background.

4 Likes