You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the LRU cache decorator from Python 3.2+ (and a vendored copy in poppy.vendor.lru_cache for back-compatibility), cache individual Zernike polynomial arrays to speed ZernikeWFE computations.
This adds a test case that generates an input wavefront and compares calling zernike1() with rho and theta arrays (the way previous implementation did, but alas un-cacheable) to a new style where we pass in enough information to reproduce the rho and theta aways within cached_zernike1().
~~The performance improvements ended up being "modest" (that is, ~2x), so there may be further productive profiling to be done.~~ Performance improved by a factor of ~6x for code that used zernike1 a lot.
An obvious next step would be to cache ZernikeWFE phasors with an internal instance attribute and some way to mark it dirty when self.coefficients or self.radius are assigned to (or make those attributes read-only).
Comment by josePhoenix Monday Jul 06, 2015 at 20:57 GMT
The WIP WFIRST field dependence stuff hits zernike1 ~220 times in a monochromatic calculation, so it's a good realistic test-case to see if we made this any better.
In the uncached case this is 55 seconds for a 10 wavelength calculation incorporating field dependent aberration.
All else being equal, caching makes the first calculation ~17 seconds, and subsequent calculations are ~9 seconds.
Issue by josePhoenix
Monday Jul 06, 2015 at 19:26 GMT
Originally opened as mperrin/poppy#99
Using the LRU cache decorator from Python 3.2+ (and a vendored copy in
poppy.vendor.lru_cache
for back-compatibility), cache individual Zernike polynomial arrays to speed ZernikeWFE computations.This adds a test case that generates an input wavefront and compares calling
zernike1()
withrho
andtheta
arrays (the way previous implementation did, but alas un-cacheable) to a new style where we pass in enough information to reproduce the rho and theta aways withincached_zernike1()
.~~The performance improvements ended up being "modest" (that is, ~2x), so there may be further productive profiling to be done.~~ Performance improved by a factor of ~6x for code that used zernike1 a lot.
An obvious next step would be to cache ZernikeWFE phasors with an internal instance attribute and some way to mark it dirty when
self.coefficients
orself.radius
are assigned to (or make those attributes read-only).josePhoenix included the following code: https://github.com/mperrin/poppy/pull/99/commits
The text was updated successfully, but these errors were encountered: