Memory reduction fixes#4176
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR targets memory and allocation hot-spots in Predbat’s planning and history-handling paths by reducing deep-copies, compacting cached history storage, and avoiding repeated list materialisation/hashing during scenario exploration.
Changes:
- Switch
str2timeto preferdatetime.fromisoformat()(with strptime fallback) and add targeted unit tests. - Introduce a compact
EntityHistorycolumnar store for HA history caching, replacing prior deep-copy behavior and updating HAHistory tests accordingly. - Reduce planner allocation/log volume via incremental scenario hashing and gating detailed per-slot logs behind
debug_enable.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| coverage/cases/predbat_debug_pre_saving1.yaml.expected.json | Updates expected regression output after planning/history changes. |
| apps/predbat/utils.py | Adds fromisoformat fast-path for time parsing and routes callers through str2time(). |
| apps/predbat/unit_test.py | Registers the new str2time test. |
| apps/predbat/tests/test_str2time.py | Adds coverage for str2time parsing behavior across formats and modes. |
| apps/predbat/tests/test_single_debug.py | Enables a faster, quieter regression-test path by toggling debug/kernel flags. |
| apps/predbat/tests/test_hahistory.py | Updates tests for the new EntityHistory storage and adds dedicated store tests. |
| apps/predbat/plan.py | Adds incremental scenario hashing to avoid copying/hashing full limit lists; gates detailed logs on debug_enable. |
| apps/predbat/inverter.py | Allows minute_data to mutate history in specific paths to avoid deep-copy overhead. |
| apps/predbat/ha.py | Implements EntityHistory and updates HAHistory caching/pruning/merge behavior to use the compact store. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.