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

modules: dataman: Optimize memory usage #6809

Merged
merged 3 commits into from
Jul 13, 2017
Merged

Conversation

zehortigoza
Copy link
Contributor

Use the size of each item type instead of the biggest one.

In AeroFC that runs is constrained mode it was using 7860 bytes
and now it uses 6930 bytes almost 1KB less.

@LorenzMeier
Copy link
Member

I have not fully reviewed this - but what happens if you already have a mission stored and its re-loaded after this diff is applied? Did you guard against that?

@zehortigoza
Copy link
Contributor Author

The DM_KEY_COMPAT will not match and it will erase all missions.
I was thinking that is fine to lose missions...
Well I can change the size of each item to the previous one and when a macro is define use this new size.

@LorenzMeier
Copy link
Member

As long as you have tested that it deletes the mission that's fine.

@zehortigoza
Copy link
Contributor Author

As long as you have tested that it deletes the mission that's fine.

Tested with file backend over STIL and RAM_FLASH over AeroFC.

@zehortigoza zehortigoza force-pushed the dataman-size branch 3 times, most recently from 4b799cb to 4288a7f Compare March 24, 2017 19:52
@zehortigoza
Copy link
Contributor Author

ping?

struct dataman_compat_s compat;
} dataman_max_size_t;

#define DM_MAX_DATA_SIZE sizeof(dataman_max_size_t)
Copy link
Member

Choose a reason for hiding this comment

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

I think we can simplify this to #define DM_MAX_DATA_SIZE sizeof(struct mission_s) so we don't need the struct.

Also, not related, but I noticed the return of task_main is not checked, thus the unit test can fail but the result still shows as success.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well I just moved it I think is good keep this way in case the structs change size and other struct becomes bigger than struct mission_s also the compiler will optimize it anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Sure but we don't really need the maximum size here. My reasoning is that wenn adding new dataman item types or exchange structs, this place will likely be forgotten to be updated. So by simplifying we make it less prone to mistakes.
Also since we change the internal semantics, there is no global maximum item size anymore, but the size depends on the item type. The tests should take that into account.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well this buffers is used to read more than one type of dm_item_t but if you think is better I just pushed a version changing to struct mission_s and also another patch that check for the result of each task.

Use the size of each item type instead of the biggest one.

In AeroFC that runs is constrained mode it was using 7860 bytes
and now it uses 6930 bytes almost 1KB less.
…need to persist

Just update in RAM is enough.
Copy link
Member

@bkueng bkueng left a comment

Choose a reason for hiding this comment

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

Thanks @zehortigoza

@zehortigoza
Copy link
Contributor Author

ping2?
Or this will be left to be integrated after the PX4 pro release?

@bkueng
Copy link
Member

bkueng commented Apr 18, 2017

We plan to merge this after the next release.

@zehortigoza
Copy link
Contributor Author

ping?

@bkueng
Copy link
Member

bkueng commented Jul 13, 2017

Release is out, time to merge this!

@bkueng bkueng merged commit ac7127f into PX4:master Jul 13, 2017
@zehortigoza
Copy link
Contributor Author

Thanks =D

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.

3 participants