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

Optimize mask, flat, and dark loading with caching #382

Draft
wants to merge 8 commits into
base: prerelease
Choose a base branch
from

Conversation

Cybis320
Copy link
Contributor

@Cybis320 Cybis320 commented Aug 22, 2024

Optimize image calibration loading with caching and improved logging (issue #336 )

  • Implement ImageCalibrationLoader class for efficient file caching
  • Reduce I/O operations by only reloading files when modified
  • Add detailed logging for mask, dark, and flat field image loading
  • Fix logging accuracy for all-white mask scenarios (issue No mask found even though mask is present #376)
  • Implement singleton pattern for consistent cache usage across modules
  • Optimize all-white mask check to avoid unnecessary rechecks

This commit should reduces strain on SD cards and hopefully speed up performance on slow storage.
Tested on MCL. Need testing on Pi 4 and 3.

@dvida dvida requested review from g7gpr and markmac99 August 23, 2024 14:39
@Cybis320
Copy link
Contributor Author

This PR just caches the non-bin versions. Should I cache the bins too? Not sure how often the conversions occur, but it wouldn’t be too much work.

@g7gpr
Copy link
Contributor

g7gpr commented Aug 24, 2024

Can test on Pi4, Pi5 tonight.

@Cybis320 Cybis320 marked this pull request as draft August 24, 2024 18:19
@Cybis320
Copy link
Contributor Author

Thank you Dave.
I flagged the PR as draft for the moment. It probably work fine as is but it could still be improved.
I’ll cache the binned versions too. The cache also currently keeps old versions instead of only keeping the most current. Also, there should be a better cleanup process.
Sorry for asking to test a bit too early.

@g7gpr
Copy link
Contributor

g7gpr commented Aug 24, 2024

It was running fine on Debian, Pi5, 4 last night. I'll check after sunrise, happy to leave those stations there.

@Cybis320
Copy link
Contributor Author

Cybis320 commented Aug 26, 2024

I'm testing this version tonight. It caches all binned and non-binned mask, dark, and flat files. The cache should update incrementally if there are any changes to the files. This should reduce I/O operations significantly and decrease CPU load somewhat, as binning is only done when a new file is detected, and checking for all-white masks is only performed when a new mask file is detected - as opposed to every time the files are used (which is continuously).

So far, the only testing I've done is to confirm that it doesn't crash on MCL using mask-only operation and that it loads the correct mask.

What needs to be tested:

  1. Verification that the cache actually updates when new files are added
  2. Confirmation that it works with flat and dark files
  3. Validation that the expected files are loaded correctly

I'm unsure about the actual usage of dark and flat files. I note that dark is disabled by default, and there are currently no options exposed in the config to enable it.

@Cybis320
Copy link
Contributor Author

I verified the cache does update when a mask file is updated. Now, if someone could test the flat and dark functions which I have no experience with.

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

Successfully merging this pull request may close these issues.

2 participants