Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple precompilation example #3559

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

nefrathenrici
Copy link
Member

@nefrathenrici nefrathenrici commented Jan 30, 2025

This PR introduces a local packagePrecompileCI that precompiles common methods in ClimaAtmos. For now, it only precompiles spaces for different spatial configurations, but this can be expanded to precompile more methods. This all happens in .buildkite/PrecompileCI/src/PrecompileCI.jl, and the package is then loaded in the driver to load in the precompiled methods.

To use, just import it before ClimaAtmos:
julia --project=.buildkite, then

using PrecompileCI  # Loads the precompiled methods or precompiles if loaded for the first time
import ClimaAtmos as CA
config = CA.AtmosConfig()
sim = CA.get_simulation(config)
CA.solve_atmos!(sim)

I included this as a separate package because precompiling these methods when ClimaAtmos is loaded will add to the TTFX.

To see which methods are actually getting precompiled, see this gist or run:
julia --project=.buildkite/PrecompileCI

using PrecompileTools
PrecompileTools.verbose[] = true
include(".buildkite/PrecompileCI/src/PrecompileCI.jl")

@nefrathenrici nefrathenrici marked this pull request as ready for review January 31, 2025 18:01
@@ -3,7 +3,7 @@
println("climaformat.jl has been discontinued in favor of JuliaFormatter")
println("To use JuliaFormatter, add it to your base environment with: ")
println()
println("julia -e 'using Pkg. Pkg.add(\"JuliaFormatter\")'")
println("julia -e 'using Pkg; Pkg.add(\"JuliaFormatter\")'")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
println("julia -e 'using Pkg; Pkg.add(\"JuliaFormatter\")'")
println("julia -e 'using Pkg; Pkg.add(\"JuliaFormatter\")'")
println()
println("If you already have it in your local environment, you can use")
println("julia -e 'using JuliaFormatter; format(\".\")")

Copy link
Member

@charleskawczynski charleskawczynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth trying this out, maybe we can loop over more configs? But I think it's a good starting point.

@Sbozzolo
Copy link
Member

With this PR, users using the driver will need to have PrecompileCI in their environments. This will break people's workflow.

Let's make sure we don't break people's workflow. We could take the opportunity to split the driver into ci_driver.jl (which contains PrecompileCI) and other driver that for the time being could just be running + plotting.

@nefrathenrici
Copy link
Member Author

With this PR, users using the driver will need to have PrecompileCI in their environments. This will break people's workflow.

Let's make sure we don't break people's workflow. We could take the opportunity to split the driver into ci_driver.jl (which contains PrecompileCI) and other driver that for the time being could just be running + plotting.

This only breaks the case of including the driver without using the .buildkite Project. I think splitting out the driver is a larger task which would also break people's workflow and should be separate from this PR. As a temporary workaround I could add a check get(ENV, "CI", false) && import PrecompileCI to ensure that this is only loaded in actual CI runs.

@nefrathenrici nefrathenrici force-pushed the ne/precompiletools branch 2 times, most recently from 499216a to e257d49 Compare February 1, 2025 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants