fermi-ad / acsys-python

Python module to access the Fermilab Control System
MIT License
8 stars 4 forks source link

Improve unmarshaler for doubles. #17

Closed rneswold closed 3 years ago

rneswold commented 3 years ago

https://github.com/fermi-controls/acsys-python/blob/2443be08fcd4e5ded21b263655e5bc50a9aa4b92/acsys/dpm/dpm_protocol.py#L1077

This looks inefficient. If we are sending over arrays of floats, this code may hamper throughout. We should measure this function against the performance of unmarshaling integers, for instance.

rneswold commented 3 years ago

With improved results after applying 21a0c040246c7dac981059c3239639a1df1de1ba, I feel keeping struct.unpack out of the hot path is a good strategy.

rneswold commented 3 years ago

Actually, this is an issue for the protocol compiler. (Keeping it open until the protocol compiler is moved to GitHub.)

rneswold commented 3 years ago

800456340ea93f9268d9c97f9f6e057da783b547 adds an optimization to speed up decoding floating point numbers. It's a 20%-ish improvement. The same fix has been applied to the protocol compiler so all protocols for Python will eventually benefit.