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
Remove &dyn references from GPIO-related HILs and capsules. #1765
Conversation
Note: it seems that these capsules used to be parameterized by the GPIO pin type before the last revamp of the HIL (#1297). However:
|
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.
Note: it seems that these capsules used to be parameterized by the GPIO pin type before the last revamp of the HIL (#1297).
Yes that is what I remember, and since we have generic components either way is fine to me. The dyn approach is cleaner, but the parametrized approach is more in-line with other capsules. If there is some other benefit one way or the other then great.
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.
That's a pretty significant improvement, which make sense given the context for the optimizations that can be made with less dynamic dispatch.
I agree that the "visual overhead" is not too bad here, but I really hate the Rust convention of single-letter types (or double, IP
is good). I feel as these stack up they really impede the readability of code; though maybe it's something that can be addressed with creative UI in IDEs. The rest of Tock goes to lengths to spell out identifiers and make things readable; I don't really think we should do anything differently here, just.. venting into the void a bit.
Awesome! Before I extend this to the other boards, any feedback on the components changes? I moved the GPIO pins from the |
🤷 it looks fine to me -- then again, I'm also in support of collapsing those into one function as proposed in #1618. Maybe @bradjc has opinions. |
Looks good to me. |
This does technically touch a HIL, so it probably qualifies as significant. It's also been in the review queue for a while though, so I think we can move reasonably quickly on this once updated and fully implemented. |
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.
I agree that the design looks good, and the savings are convincing. I think this just needs to be ported to other boards and rebased.
… imix, hail, nucleo_f429zi.
Rebased and migrated all boards. Where is the size report summary supposed to show? |
Click "details" next to the "benchmarks" check, then click the "size report" step. (I included your change to print the git diff there, but it has made the report a little cluttered). |
Ok, thanks. I thought there was some pipeline to show the results directly on the pull request page. |
That pipeline currently only works for PRs submitted from branches on the upstream repo, due to limitations with how Github allows commit status posting. A plan is in the works to get around this limitation by hosting part of the CI on a local server where secrets can safely be stored. |
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.
bors d+
This is great! I've confirmed that buttons still happily button on Hail.
I think this is ready to go unless you have any remaining questions on the size improvements Hudson? That conversation looked mechanistic, but I didn't want to prematurely merge.
✌️ gendx can now approve this pull request. To approve and merge a pull request, simply reply with |
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.
bors r+
Canceled. |
I updated the usage of affected components as well. Will wait a day in case anyone has something to say. |
This PR is still marked as RFC. Is it no longer an RFC? |
Indeed. |
bors r+ |
Build succeeded: |
Build succeeded: |
Pull Request Overview
This pull request experiments with removing
&dyn
references from GPIO-related capsules, as a supporting example for #1761.Until now, the capsules were using dynamic references to use GPIO pins, even though for a given board/chip the GPIOs have a type known at compile time. This pull request proposes to replace such dynamic references with explicit types.
The resulting code is a bit more verbose, but surprisingly not so much. Most of the extra code comes from components, where
static_init_half
is now necessary to instantiate the static types that are now generic.By applying this refactoring to the most common capsules (GPIO, button, LED), savings of the order of ~1KB can be obtained on the boards (depending on how many GPIOs are declared by the board). More savings could be obtained by extending this refactoring to all capsules using GPIOs. And more generally many HILs in the kernel rely on
&dyn
references, so removing them from HILs and capsules in general could achieve even bigger savings.Before:
After:
Testing Strategy
This pull request was tested by building a few boards and checking the binary size. Not much more testing at this stage.
TODO or Help Wanted
This pull request still needs:
Documentation Updated
/docs
, or no updates are required.Formatting
make formatall
.