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

OTA #531

Merged
merged 2 commits into from
Dec 22, 2024
Merged

OTA #531

merged 2 commits into from
Dec 22, 2024

Conversation

ivmarkov
Copy link
Collaborator

@ivmarkov ivmarkov commented Dec 22, 2024

Implements a new type EspFirmwareInfoLoad that has a reduced memory consumption, as per the docs.

@ivmarkov ivmarkov marked this pull request as ready for review December 22, 2024 17:50
@ivmarkov ivmarkov merged commit 9b23488 into master Dec 22, 2024
15 checks passed
///
/// Returns `true` if the information was successfully fetched.
/// Returns `false` if the firmware data has not been loaded completely yet.
pub fn fetch(&self, data: &[u8], info: &mut FirmwareInfo) -> Result<bool, EspIOError> {
Copy link

@pbert519 pbert519 Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ivmarkov I'm currently trying to port the EspFirmwareInfoLoader to EspFirmwareInfoLoad.
While i understand the performance changes, i have a few question about this changes.

Why is FirmwareInfo passed as mutable reference, in my point of view it would be much easier to just return Return<Option, EspIOError> instead of the bool.

Also is there any reason why fetch takes &self?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ivmarkov I'm currently trying to port the EspFirmwareInfoLoader to EspFirmwareInfoLoad. While i understand the performance changes, i have a few question about this changes.

Why is FirmwareInfo passed as mutable reference, in my point of view it would be much easier to just return Return<Option, EspIOError> instead of the bool.

That's how it used to be in the previous loader.

However, FirmwareInfo has a relatively large footprint of ~ 500 bytes. Why I designed it like this is another topic, but fixing embedded-svc (from where it comes) is not a topic right now. Therefore, it is not ideal if it is passed with moves as it occupies a large stack size then, especially in an async context, where futures' memory layout is not optimized w.r.t. input arguments (they are duplicated).

Also is there any reason why fetch takes &self?

No particular reason, but doesn't hurt either, as FirmwareInfoLoad is currently an empty struct, so the compiler would optimize away the &self anyway.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how it used to be in the previous loader.

The performance optimatisations i noticed where that EspFirmwareInfoLoader did have a copy of the buffer, while EspFirmwareInfoLoad just works an a slice.
Good point with the copy on return, however for non async cases, the compiler should complety optimize that and the api is much nicer. It dosn't help that Firmwareinfo does not have a default implementation, but that's a embedded_svc topic.

No particular reason, but doesn't hurt either, as FirmwareInfoLoad is currently an empty struct, so the compiler would optimize away the &self anyway.

Sure it doesn't hurt, but it's confusing for user of the API, at least thats my experience.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

however for non async cases, the compiler should complety optimize that and the api is much nicer

I wish I was also as confident as you are in that. Look here.

No particular reason, but doesn't hurt either, as FirmwareInfoLoad is currently an empty struct, so the compiler would optimize away the &self anyway.

Sure it doesn't hurt, but it's confusing for user of the API, at least thats my experience.

If nothing else, these changes were already released, and I don't think the API breakage of removing &self is worth it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the insights.
I agree that a new release is not worth changing the &self.

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