Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Re-)Optimizes Zernike computation #99

Closed
mperrin opened this issue Aug 23, 2018 · 2 comments
Closed

(Re-)Optimizes Zernike computation #99

mperrin opened this issue Aug 23, 2018 · 2 comments

Comments

@mperrin
Copy link
Collaborator

mperrin commented Aug 23, 2018

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() 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).


josePhoenix included the following code: https://github.com/mperrin/poppy/pull/99/commits

@mperrin
Copy link
Collaborator Author

mperrin commented Aug 23, 2018

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.

@mperrin
Copy link
Collaborator Author

mperrin commented Aug 23, 2018

Comment by josePhoenix
Tuesday Jul 14, 2015 at 15:31 GMT


As discussed, refactored Wavefront.coordinates into static methods for image- and pupil-plane coordinates, then used those in cached_zernike1.

@mperrin mperrin closed this as completed Aug 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant