OasisLMF / ktools

In-memory simulation kernel for loss modelling.
BSD 3-Clause "New" or "Revised" License
28 stars 19 forks source link

aalcalc Performance Improvements #342

Closed hchagani-oasislmf closed 11 months ago

hchagani-oasislmf commented 1 year ago

Issue Description

The development of a version of aalcalc in Rust indicates that there is room for significant improvement in the performance of this component. Running aalcalc through a profiler reveals that a significant proportion of run time (around 23%) is used in indexing the input files from summarycalc. It would be worth investigating whether there is scope for optimisation.

Version / Environment information

ktools v3.9.5.

Example data / logs

Output of flat profile from gprof profiler, showing functions that contribute > 10% of run time:

Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls   s/call   s/call  name    
 24.10    514.45   514.45                             read
 23.16   1008.78   494.33 4947282156     0.00     0.00  operator<(summary_period const&, summary_period const&)
 11.68   1258.08   249.29                             lseek

Ordering the summary index and reading the input files appear to be the main bottlenecks.

benhayes21 commented 1 year ago

https://github.com/OasisLMF/ktools/blob/482283a642d7d3165a2d3cdcc0615ad145d1402f/docs/md/OutputComponents.md#calculation-3