Commit f22ddd2
authored
Fix unreachable-power formula leak in the power distributor (#1411)
The power distributor runs a formula for each set of unreachable
components. They were created on the shared logical-meter pool, which
never evicts unused formulas.
On teardown only the cache was stopped, not the formula — so a
formula-evaluating actor leaked per distinct set, and CPU climbed over
time until a restart.
## Changes
* `FormulaPool`: `stop()` now also stops string formulas; new
`stop_string_formula()` stops + evicts a single one.
* Each `ComponentManager` lazily owns a dedicated `FormulaPool` (new
`_DataPipeline.new_formula_pool`) and stops its formulas on teardown,
via a per-type `_unreachable_power_formula` hook. Battery and PV use it.
* Fix `from_reactive_power_formula` checking the wrong cache dict, which
re-created and leaked the grid reactive-power formula on every access.
## Breaking
* PV distribution now subtracts the power of unreachable PV inverters
from the target, so PV results differ when some inverters are
unreachable.9 files changed
Lines changed: 814 additions & 137 deletions
File tree
- src/frequenz/sdk
- microgrid
- _power_distributing/_component_managers
- _ev_charger_manager
- _pv_inverter_manager
- timeseries/formulas
- tests
- microgrid/power_distributing
- timeseries/_formulas
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
184 | 188 | | |
185 | 189 | | |
186 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
187 | 216 | | |
188 | 217 | | |
189 | 218 | | |
| |||
557 | 586 | | |
558 | 587 | | |
559 | 588 | | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
560 | 602 | | |
561 | 603 | | |
562 | 604 | | |
| |||
Lines changed: 10 additions & 95 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | | - | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
| |||
146 | 144 | | |
147 | 145 | | |
148 | 146 | | |
| 147 | + | |
149 | 148 | | |
150 | 149 | | |
151 | 150 | | |
| |||
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | 165 | | |
181 | 166 | | |
182 | 167 | | |
| |||
219 | 204 | | |
220 | 205 | | |
221 | 206 | | |
| 207 | + | |
222 | 208 | | |
223 | 209 | | |
224 | 210 | | |
| |||
536 | 522 | | |
537 | 523 | | |
538 | 524 | | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
609 | 531 | | |
610 | 532 | | |
611 | 533 | | |
| |||
629 | 551 | | |
630 | 552 | | |
631 | 553 | | |
632 | | - | |
| 554 | + | |
633 | 555 | | |
634 | 556 | | |
635 | 557 | | |
| |||
676 | 598 | | |
677 | 599 | | |
678 | 600 | | |
679 | | - | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | 601 | | |
687 | 602 | | |
688 | | - | |
| 603 | + | |
689 | 604 | | |
690 | 605 | | |
691 | 606 | | |
| |||
0 commit comments