Description
We are seeing massive latency increases in ClimaAtmos.jl
with Julia 1.11, starting from the alphas and continuing in 1.11-rc1 (CliMA/ClimaAtmos.jl#3186).
ClimaAtmos.jl
does no longer compile in any reasonable time with Julia 1.11-rc1. I identified that the offending function is get_atmos
, a simple function that returns a keyword-defined type. For the most part, this function simply converts string keywords read from YAML files to types, then, it returns a AtmosModel
(defined below).
I used SnoopCompile
(master
) to try to get a little more insight. The get_atmos
function, as it is, takes too long to compile (on Julia 1.10, this is instantaneous), so I had to remove part of it (as mentioned in the referenced issue). Once I do so, I see with @snoop_inference
that:
InferenceTimingNode: 1.171199/288.711156 on Core.Compiler.Timings.ROOT() with 21 direct children
All the time is spent in types.jl
line 329. This line simply defines our struct:
Base.@kwdef struct AtmosModel{
MC,
MM,
PM,
CM,
CCDPS,
F,
S,
RM,
LA,
EXTFORCING,
EC,
AT,
TM,
EEM,
EDM,
ESMF,
ESDF,
ENP,
EVR,
TCM,
NOGW,
OGW,
HD,
VD,
DM,
SAM,
VS,
RS,
ST,
IN,
SM,
SA,
NUM,
}
model_config::MC = nothing
moisture_model::MM = nothing
precip_model::PM = nothing
cloud_model::CM = nothing
call_cloud_diagnostics_per_stage::CCDPS = nothing
forcing_type::F = nothing
subsidence::S = nothing
radiation_mode::RM = nothing
ls_adv::LA = nothing
external_forcing::EXTFORCING = nothing
edmf_coriolis::EC = nothing
advection_test::AT = nothing
tendency_model::TM = nothing
edmfx_entr_model::EEM = nothing
edmfx_detr_model::EDM = nothing
edmfx_sgs_mass_flux::ESMF = nothing
edmfx_sgs_diffusive_flux::ESDF = nothing
edmfx_nh_pressure::ENP = nothing
edmfx_filter::EVR = nothing
turbconv_model::TCM = nothing
non_orographic_gravity_wave::NOGW = nothing
orographic_gravity_wave::OGW = nothing
hyperdiff::HD = nothing
vert_diff::VD = nothing
diff_mode::DM = nothing
sgs_adv_mode::SAM = nothing
viscous_sponge::VS = nothing
rayleigh_sponge::RS = nothing
sfc_temperature::ST = nothing
insolation::IN = nothing
surface_model::SM = nothing
surface_albedo::SA = nothing
numerics::NUM = nothing
end
I have not tried without keyword arguments.
I don't think that what we are doing up to this point is particularly complex or unorthodox, and most of the types involved are very simple (mostly singletons and bools, all immutable).
Originally posted by @Sbozzolo in #55171 (comment)