Cache SSB astrometry calculations#1992
Conversation
|
amazing ! |
All component level methods are inherited by the timing model. But that brings up a good point which is that there could be other caches elsewhere that we want to deal with. So I changed the name to |
|
So this mostly works. But oddly not 100%. I added env variables to aid testing. And I find that when I test with/without the cache I usually get the results I expect (without cache is slow, and chi^2 changes very slightly). But not always. I don't yet understand why. |
|
So I am now more confused. Using the master branch or this PR, with or without caching I see bimodal results: sometimes slower, sometimes faster, but when faster I always see a slightly different chi^2 (at the 1e-3 level). I could understand variation in wall-clock time just due to CPU load. But not variation in chi^2. That should be deterministic? |
|
OK, I think I understand more. For some reason, different fits use different numbers of iterations/calls. That leads to pretty different clock times as well as slightly different chi^2. Still not sure why that is, but now I understand the origin of the variation that I see. Nonetheless, I do see improved performance with this PR in terms of time/call for the ssb methods. With caching enabled: or and without: and |
|
This looks OK. Shall I merge this? |
I think this is OK, and it's something we can turn off, but it should be checked closely. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1992 +/- ##
==========================================
- Coverage 70.34% 70.33% -0.01%
==========================================
Files 109 109
Lines 25652 25709 +57
Branches 4081 4092 +11
==========================================
+ Hits 18044 18082 +38
- Misses 6453 6465 +12
- Partials 1155 1162 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Look at: |
|
Is this ready to go? |
I would like somebody (you, @scottransom , ...) to check it a little, just to make sure I didn't do anything foolish. Maybe you have already looked. |
|
Also,
|
I don't know that making them invalidate the cache directly is possible, since those methods only apply to TOAs, not models. But for the methods that change TOAs the cache will invalidate and the values will be recomputed. I added some tests for those (not sure it should apply for
Works as expected. The cache is invalidated since the times change, and is recomputed. |
|
Shall I merge this once the tests pass? |
Your concerns over the various operations are all OK? If so then OK to merge I think. |
Claude-recommended speedup: #1984
On J0437 data, tried 5 iterations. chi^2 was within 1e-3 with both versions. Average time went from 19.3s to 10.9s.
Have
model.clear_ssb_cache()to clear the cache, and also can control with either:$PINT_DISABLE_CACHE=1or$PINT_DISABLE_ASTROMETRY_CACHE=1