Repository navigation
perf(smartfuel): keep the configuration and compare the restart values instead of rebuilding both every wake #789
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
Merged
heliflieger
merged 4 commits into
rotorflight:master
from
flugifix:pr/smartfuel-config-hoist
Oct 18, 2026
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
97b48a8
perf(smartfuel): keep the configuration and compare the reset signatu…
flugifix 32908eb
perf(smartfuel): read the configuration inputs once, and build from them
flugifix 0ce4aa6
docs(release-notes): name every value whose restart the numeric compa…
flugifix 35f641b
docs(smartfuel): say that the kept configuration is returned, not copied
flugifix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - **SmartFuel no longer rebuilds its configuration and reset signature on every wake (`tasks/events/telemetry_bg/smart.lua`)**: | ||
| - `Smart.wakeup` computes once a second in every Lua state that runs the event runtime (the dashboard and service widgets, the tool). Each of those wakes built a new configuration table through three fresh closures and a parsed API version, although the configuration only changes when a setting does, and joined seven `tostring` results into a string to decide whether to restart the estimate, although those values only change with the settings, the battery configuration, the active battery profile or the pack's cell count. The helpers are now file-level functions, the configuration is rebuilt only when one of its input values differs from the last wake (compared by value, so a page writing into the session's tables in place is still seen), and the restart test compares the seven values field by field. Measured on desktop Lua 5.3, a computing wake with unchanged inputs allocates nothing instead of 945 bytes, and costs 510 instructions instead of 697 (firmware source) or 749 instead of 927 (local voltage source). The configuration and every restart decision are unchanged, with one exception: the restart values are now compared as numbers, so a value that changes only between an integer and a float of the same size (a cell count reported as `6.0` where it was `6`, a capacity of `2000.0` where it was `2000`) no longer restarts the estimate. The string comparison restarted it, because Lua 5.3 prints the two differently (#768). |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cached table is now returned by reference. Its only caller is
Smart.wakeup(:620), which readssource,firmwareSource,stabilizeDelaySecondsandstableWindowVoltsand writes none of them, so the cache cannot be polluted today. If a later caller ever writes intocfg, this is the line where that becomes a stale-configuration bug.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. 35f641b puts that rule into the comment above the cache: the kept table is handed out itself, not a copy, so a caller must not write into it.