-
-
Notifications
You must be signed in to change notification settings - Fork 706
fix(core): presize __main__ module to avoid heap fragmentation #4842
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
Conversation
|
a86bd59
to
1d3ba69
Compare
Currently, |
that's less than useful could we at least enable it for the frozen build? the test suite is where we would normally discover the overflows |
in fact it's a good idea to only enable this flag in debug builds -- in production, we'll prefer performance degradation (fragmented memory) to a full crash |
Sounds good - 40f4061 enables |
core/embed/projects/firmware/main.c
Outdated
@@ -76,6 +76,7 @@ int main(uint32_t cmd, void *arg) { | |||
// Interpreter init | |||
printf("CORE: Starting interpreter\n"); | |||
mp_init(); | |||
|
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.
maybe omit this noise?
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.
Oops, my bad... I removed the code from firmware build, instead of disabling it for non-debug builds.
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.
Rewrote in 24a3284.
// .used = MP_ARRAY_SIZE(table_name), | ||
// .alloc = MP_ARRAY_SIZE(table_name), | ||
let bits = 0b111 | N << 3; | ||
let bits = 0b1111 | N << 4; |
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.
could you please have a look at bindgen, to see whether the above limitation was lifted?
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.
Unfortunately, I haven't found a way to generate const
accessors in https://rust-lang.github.io/rust-bindgen/?search=const & https://docs.rs/bindgen/latest/bindgen/struct.Builder.html?search=const :(
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.
24a3284 doesn't require changing MicroPython code & its Rust bindings.
ac30529
to
887506d
Compare
does the failure come from if the latter, we can just bump the limit if iirc profiling only works if you make a special build for it? if yes, let's freeze if there's no build flag for profiling, then uhhh let's not spend more time on it and only enable it on hw debug |
60d160c
to
24a3284
Compare
IIUC, we always build the emulator with tracing enabled so I think that we can simplify the PR by periodically checking for reallocations - as currently done by The new code in 24a3284 uses the pre-allocation constants from WDYT? |
yeah, this approach makes more sense |
Rewrite the static comparison in `utils.unimport_end()` in C. [no changelog]
f94735f
to
fe09331
Compare
It seems that there is no |
It has caused also the CI hardware tests to fail. |
Also, check for
main
globals andsys.modules
reallocations.