DOI-USGS / usgscsm

This repository stores USGS Community Sensor Model (CSM) camera models
Other
26 stars 33 forks source link

Speedup in Linescan model by avoiding unneeded computations #385

Closed oleg-alexandrov closed 2 years ago

oleg-alexandrov commented 2 years ago

I made a 23% speed improvement in the linescan sensor logic, without changing the results. This relies on avoiding computing the interpolated velocity and applying adjustments when those are not used by the caller.

To verify this, run:

cd usgscsm/build time ./usgscsm_cam_test --model ../tests/data/toughLroNacLineScan.json --sample-rate 1

before and after applying the fix. On my machine the run time is 155 seconds before the fix, and 118 seconds after it. Granted, not a huge improvement, but it is notable, and the code changes are small.

oleg-alexandrov commented 2 years ago

I'm curious how much time is taken by the lagrangeitnerp function vs applying the adjustments.

It is the lagrange interpolation which takes up almost all the time. I will look later into optimizing that too, as there are too many repeated multiplications which could be done just once.

If the adjustments are non-zero, one has to compute the velocity in order to find the adjusted position. So this optimization trick works only if both there is no need for velocity and there are no adjustments. Hence, these can't be separated.

oleg-alexandrov commented 2 years ago

I addressed the above.