CliMA / ClimaCore.jl

CliMA model dycore
https://clima.github.io/ClimaCore.jl/dev
Apache License 2.0
86 stars 8 forks source link

Improve inference in space constructors #1797

Open charleskawczynski opened 3 months ago

charleskawczynski commented 3 months ago

In particular, I'm seeing a bunch of jet failures in warpedspace of test/Spaces/terrain_warp.jl. We should probably add more systematic tests, as this can improve compile times.

charleskawczynski commented 3 months ago

It turns out that a big culprit here is the OBJECT_CACHE, which is inherently type stable since it takes a type-unbounded dict.

IMO, this is not really the correct way to test if two spaces are compatible (and won't generally work, even for the coupler). Removing the get!-OBJECT_CACHE logic from all the constructors fixes a huge number of type instabilities, ironically speeding up the construction of the space. Subsequent calls can be faster, but I'm wondering if this is worth it