sot / kadi

Chandra commands and events
https://sot.github.io/kadi
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

Performance improvement kadi states #266

Closed taldcroft closed 7 months ago

taldcroft commented 1 year ago

Description

This is part of the Performance project. It speeds up get_states by a factor of 2 to 3.

Interface impacts

None

Testing

Unit tests

Independent check of unit tests by Jean

Functional tests

Test script

import time

import kadi
from kadi.commands import get_cmds
from kadi.commands.states import get_states

print(f"{kadi.__version__=}")

start, stop = "2021:001", "2022:001"
cmds = get_cmds(start, stop, scenario="flight")

t0 = time.time()
states = get_states(start, stop)
print(f"get_states took {time.time() - t0:.1f} sec")

t0 = time.time()
states = get_states(start, stop)
print(f"2nd get_states took {time.time() - t0:.1f} sec")

Results on older Intel Mac with WIP versions

Flight

kadi.__version__='7.0.2'
get_states took 18.5 sec
2nd get_states took 18.1 sec

PR 266

kadi.__version__='7.1.1.dev68+ge0dd365'
get_states took 5.5 sec
2nd get_states took 4.8 sec

Results with newer M2 Mac (emulation)

Flight

(ska3) ➜  validate git:(performance) python performance_states.py
kadi.__version__='7.6.0'
get_states took 6.0 sec
2nd get_states took 5.6 sec

Dev

Versions:

$ conda list | grep pypi | grep \.dev
chandra-aca               4.42.1.dev13+gcf5cbc1          pypi_0    pypi
chandra-maneuver          4.0.1.dev8+g3e2cc1c          pypi_0    pypi
cxotime                   3.6.2.dev1+g47d1e30          pypi_0    pypi
kadi                      7.6.1.dev19+g4e92cf7          pypi_0    pypi
quaternion                4.1.2.dev10+g4795e33          pypi_0    pypi
ska-helpers               0.12.1.dev2+gbee8099          pypi_0    pypi
ska-sun                   3.10.2.dev13+gc811fa4          pypi_0    pypi
(ska3-perf) ➜  validate git:(performance) python performance_states.py
kadi.__version__='7.6.1.dev19+g4e92cf7'
get_states took 2.7 sec
2nd get_states took 2.3 sec
jeanconn commented 7 months ago

For this, tests aren't passing for me on kady with ska3-masters against this PR or against kadi in master, so I don't have passing tests available to sign off.

jeanconn commented 7 months ago

With https://github.com/sot/cxotime/pull/42 and https://github.com/sot/chandra_maneuver/pull/26 tests are now passing in for this PR (and master).