csnazell / plant-model

Plant model
Apache License 2.0
0 stars 0 forks source link

Improve Memory Usage #4

Open csnazell opened 1 week ago

csnazell commented 1 week ago

During review it was decided that the memory performance of a RODAS5P-based clock + phenology simulation is very high (145 Gb) (using BenchmarkTools.jl).

Identify where memory is being used and optimise memory usage to improve performance.

csnazell commented 1 week ago

I suspect this is due to a shortcut taken during development where the solution item returns from the algorithmic solver is directly kept in the output struct of the simulation frame.

The original MATLAB code captured a matrix of # differential equations x (27 hrs / time step) (typically 540 x # differential equations). Linear interpolation was then used to interpolate between points. In porting to Julia it was decided just to capture the solution item and then use the solution's default handling for interpolation which the docs imply is algorithm-specific. In hindsight this might be the source of the memory consumption. The memory benchmarking indicates consumption is dependent on the algorithm being used.

Assuming linear interpolation of output matrix is good enough then replicating the MATLAB behaviour will probably reduce memory consumption.