Skip to content

Commit bca59e1

Browse files
Merge pull request #19 from ChrisRackauckas-Claude/precompile-improvements-20260107-185513
Add PrecompileTools workload to improve startup time
2 parents 050efee + 80bff1f commit bca59e1

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ version = "1.2.0"
55

66
[deps]
77
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
8+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
89
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
910
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1011

1112
[compat]
12-
julia = "1"
1313
CommonSolve = "0.2"
14+
PrecompileTools = "1"
1415
SciMLBase = "2"
16+
julia = "1"
1517

1618
[extras]
1719
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"

src/FiniteVolumeMethod1D.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ include("solve.jl")
2525
(obj::Returns)(@nospecialize(args...); @nospecialize(kw...)) = obj.value
2626
end
2727

28+
include("precompilation.jl")
29+
2830
end # module

src/precompilation.jl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using PrecompileTools
2+
3+
@setup_workload begin
4+
# Minimal setup - these are lightweight and don't add much to precompilation time
5+
mesh_points = LinRange(0.0, 1.0, 10)
6+
7+
@compile_workload begin
8+
# Precompile FVMGeometry creation - common entry point
9+
geom = FVMGeometry(mesh_points)
10+
11+
# Precompile boundary condition types with common cases
12+
lhs_dir = Dirichlet(0.0)
13+
rhs_dir = Dirichlet(1.0)
14+
lhs_neu = Neumann(0.0)
15+
rhs_neu = Neumann(0.0)
16+
17+
# Precompile BoundaryConditions with different combinations
18+
bc_dir = BoundaryConditions(lhs = lhs_dir, rhs = rhs_dir)
19+
bc_neu = BoundaryConditions(lhs = lhs_neu, rhs = rhs_neu)
20+
bc_mix = BoundaryConditions(lhs = lhs_dir, rhs = rhs_neu)
21+
22+
# Precompile FVMProblem creation
23+
diffusion_function = (u, x, t, p) -> one(u)
24+
initial_condition = collect(mesh_points)
25+
26+
prob = FVMProblem(
27+
mesh_points, lhs_dir, rhs_dir;
28+
diffusion_function = diffusion_function,
29+
initial_condition = initial_condition,
30+
final_time = 1.0
31+
)
32+
33+
# Precompile ODEProblem creation - this is a common operation
34+
ode_prob = SciMLBase.ODEProblem(prob)
35+
36+
# Precompile jacobian_sparsity
37+
jac_sp = jacobian_sparsity(prob)
38+
end
39+
end

0 commit comments

Comments
 (0)