The current load process of an App is done internally by Revise.includet().
This doesn't take advantage of the fact that the App is typically a module (not necessarily, though) and could be precompiled.
Alternatively one could load the App with a using statement, which speeds up loading drastically and even more when using PrecompileTools.
There are some pitfalls with this approach, but I'd like to discuss what could be the best approach.
Here's my MWE
module MyApp.jl
module MyApp
using PrecompileTools
using GenieFramework
@app HH begin
@in x = 10
@out y = 11
end
ui() = [
row(cell(class = "st-module", row([
h3("Hello")
numberfield("x", :x)
])))
]
# any definition that sets up runtime variables needs to go into the `__init__` function.
# That's in any case the page or route command. But also any global variable, e.g. a DataFrame that is loaded at the beginning
# needs to go here.
function __init__()
route("/") do
model = init(HH) |> handlers
page(model, ui) |> html
end
end
# include typical calls in the section below
# The `Timer()` command in Stipple.jl had to be escaped during precompilation, because the process wouldn't stop otherwise.
@compile_workload begin
Stipple.PRECOMPILE[] = true
ui()
init(HH)
Stipple.PRECOMPILE[] = false
end
end
classical bootstrap.jl
using Revise
Revise.includet("MyApp.jl")
alternative bootstrap.jl
pushfirst!(LOAD_PATH, ".")
using MyApp
Testing
using GenieFramework
@time begin Genie.loadapp(); MyApp.ui(); init(MyApp.HH) end
Result is
- classical:
4.626385 seconds (2.23 M allocations: 151.089 MiB, 95.21% compilation time: <1% of which was recompilation
- alternative:
0.351679 seconds (58.67 k allocations: 3.758 MiB, 20.45% compilation time)
The current load process of an App is done internally by
Revise.includet().This doesn't take advantage of the fact that the App is typically a module (not necessarily, though) and could be precompiled.
Alternatively one could load the App with a using statement, which speeds up loading drastically and even more when using PrecompileTools.
There are some pitfalls with this approach, but I'd like to discuss what could be the best approach.
Here's my MWE
module MyApp.jl
classical bootstrap.jl
alternative bootstrap.jl
Testing
Result is
4.626385 seconds (2.23 M allocations: 151.089 MiB, 95.21% compilation time: <1% of which was recompilation0.351679 seconds (58.67 k allocations: 3.758 MiB, 20.45% compilation time)