-
Notifications
You must be signed in to change notification settings - Fork 22
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
Cache specsim #178
Cache specsim #178
Conversation
I think we ideally want a working (and unit tested) Does the fact that travis tests are passing on this PR mean that your list above is sufficient for these tests? |
Agreed. This is a workaround in the meantime to make it easier to work with these tests.
Yes. I pulled the list of items to cache and reset from the list of items that quickbrick / quickgen update (in their code and in their tests). Under normal use, calling quickbrick or quickgen will only create one Simulator object anyway so this issue doesn't apply. If one is concerned that the reset isn't being done completely, one can always call |
With the test config, the Simulator ctor only takes ~0.5s, so I suspect that most of the extra desi-config setup time is spent reading and parsing large ascii files. Just replacing these with binary files could make a big dent in those ~9 seconds. |
Checking on the status of this. Some alternate suggestions have been raised:
Either of these is admittedly better, but they need more work and in the meantime this PR has a pragmatic fix. Any objections to merging this now and then replacing it with a better solution if/when those are ready? |
The current solution is a bit fragile (since it copies a list of attributes by hand that depends on the exact tests being run), but I am ok with merging now and then updating after desihub/specsim#51 is resolved. |
I agree that it is fragile. If we continue to use this as-is and some additional parameter gets added we'll probably forget to update it here and then I'll have to do some penance. But noting:
Merging now as a pragmatic step toward better testing... |
This PR makes the quickbrick and quickgen tests ~2x faster by caching the
specsim.simulator.Simulator
object instead of recreating it anew every time. It also enables these tests on Travis using specsim master and desisim master, now that specsim fits within the memory limits of Travis (as a side effect, the tests were also faster due to that change, even before this caching). After the next tag of specsim, we can update this to use that tag instead.Since the cached
Simulator
object may have been altered by the previous test, the caching code also caches the state for a few key variables and puts them back to their original state before returning the cached object:Are there other variables that should also be reset?
The new
desisim.specsim
module could also be the namespace landing spot for other desi-specific wrappers tospecsim
to unify the common code from quickbrick and quickgen. If having bothdesisim.specsim
andspecsim
is confusing, please suggest an alternate name for desi-specific convenience wrappers ofspecsim
.