GenXProject / GenX.jl

GenX: a configurable power system capacity expansion model for studying low-carbon energy futures. More details at : https://genx.mit.edu
https://genxproject.github.io/GenX.jl/
GNU General Public License v2.0
256 stars 105 forks source link

Add option to precompile run_genx_case! function #718

Closed lbonaldo closed 6 days ago

lbonaldo commented 1 week ago

Description

This PR adds the option to precompile the run_genx_case! function, reducing the latency of the first execution of GenX in a Julia environment.

What type of PR is this? (check all applicable)

Related Tickets & Documents

This addresses #519.

Checklist

How this can be tested

As described in the documentation, this can be tested by running the following commands:

julia> ENV["GENX_PRECOMPILE"] = "true"
julia> using GenX
julia> include("example_systems/1_three_zones/Run.jl")

The user should see a speedup in the model generation and the functions for writing outputs.

Post-approval checklist for GenX core developers

After the PR is approved

lbonaldo commented 6 days ago

Hi @sambuddhac! The precompile folder contains input files for a simple case that I created, which is used by Julia to compile some of the GenX functions. Here are some benchmarks:

Setup:

Results:

precompile

sambuddhac commented 6 days ago

Hi @sambuddhac! The precompile folder contains input files for a simple case that I created, which is used by Julia to compile some of the GenX functions. Here are some benchmarks:

Setup:

  • CPU model: Apple M2
  • Julia version: 1.10.4
  • GenX versions:

Results:

  • Precompilation Additional Time: 40s
  • Time to first execution (TTFX):

precompile

Thank you so much !!! Enlightening !!!