-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
parameters metadata generate as single static constexpr header #11318
Conversation
6175534
to
f1219f7
Compare
c3c518f
to
8bfa4a8
Compare
8bfa4a8
to
9c5ef10
Compare
cefe5d2
to
79c6e44
Compare
79c6e44
to
76c1dae
Compare
76c1dae
to
da110af
Compare
da110af
to
722784a
Compare
@julianoes @bkueng can I get an initial review here? Verifying some of the specifics like the different indexing (eg |
fc3dbeb
to
4c9a489
Compare
src/lib/parameters/parameters.cpp
Outdated
if (param_index < 0) { | ||
return; | ||
if (handle_in_range(param)) { | ||
// FIXME: this needs locking too |
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.
Can you fix this by letting the bitset use the atomic
class?
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.
Implemented in 33a4f8b with new AtomicBitset.
4c9a489
to
ef0d7f4
Compare
827659b
to
da88109
Compare
Splitting the parameter type and volatile into a separate generated static constexpr array saves about 2 KB of flash. |
- add Bitset and AtomicBitset with testing
522bceb
to
6d2dfe2
Compare
@@ -379,35 +343,19 @@ param_find_no_notification(const char *name) | |||
unsigned | |||
param_count() | |||
{ | |||
return get_param_info_count(); | |||
return param_info_count; |
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.
param_count()
can be const
, right?
|
||
/* perform a binary search of the known parameters */ | ||
|
||
while (front <= last) { | ||
middle = front + (last - front) / 2; | ||
int ret = strcmp(name, param_info_base[middle].name); | ||
int ret = strcmp(name, param_name(middle)); |
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.
Should we be using strncpy
to be safe?
{ | ||
size_t total = 0; | ||
|
||
for (const auto &x : _data) { |
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.
What is x
? Due to auto
and the cryptic variable name I don't know what I'm looking at 🤔.
size_t total = 0; | ||
|
||
for (const auto &x : _data) { | ||
const uint32_t y = x.load(); |
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.
How is this atomic if you're doing a load in every loop iteration?
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.
Yes the count() isn't thread safe, which is kind of lame overall, but only used in a single place for parameters.
TODO: review
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
@dagar would actually be nice to get this in, right? |
Yes definitely. I think last time we got hung up on the atomic bitset, the was only atomic per integer within the bitset. |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
Closing this as stale. |
This PR is some minor parameter system cleanup that I'd like to get in a base before pursuing a few more interesting changes (like additional data types) and reducing the required flash.