-
Notifications
You must be signed in to change notification settings - Fork 1.3k
do background tasks and handle interrupt during boundary fill #7678
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
do background tasks and handle interrupt during boundary fill #7678
Conversation
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.
The code looks good to me, my only thought is have you looked at performance? If you are checking every loop that may have an effect on speed more then intended.
I'm not sure why the unix port build is failing. It reports this error:
Which seems like perhaps there is a missing I found the command to build the unix port locally and I see the same error as in the actions. It seems like
but it results in this error:
I'm not not sure that would have been a correct solution anyway though because other usages of |
Looking at other #include "py/runtime.h" |
It's got
Could it need a different order or something more specific to the function where it's used? |
Order shouldn't matter, but I'm wondering if the unix port is not compiling the other files with |
Ahh, it looks like you are correct on that. I added I did also double check with the |
I'm not really sure how to move this forward. I'm guessing it comes down to two high level options:
I don't really know how to do either of those, or which would be preferred. I guessed that the latter would be possible by modifying a .mk file somewhere to disable bitmaptools, and I made an attempt at doing that but was unsuccessful. I tried adding circuitpython/ports/unix/mpconfigport.mk Line 42 in bca7d6e
I also tried setting this to
RUN_BACKGROUND_TASKS undeclared.
|
How about adding |
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.
The code looks fine. Do you see any kind of noticeable performance degradation that might make it worthwhile to run the background tasks only sometimes around the loop?
I only did a handful of trials and there is some variance from run to run, but it seems comparable to me. I used this test code to measure
With latest build from S3:
With build from this PR:
All of my testing was on a Feather ESP32-S2 TFT. |
attempt to resolve #7485
Added code to run background tasks and bail if interrupted.
Tested successfully on PyPortal Titano with the reproducer code in the issue.
This resolves the problem of getting "stuck" during the fill, but the underlying crux is that boundary_fill is fairly slow for filling large spaces. The current implementation is based on this https://en.wikipedia.org/wiki/Flood_fill#Moving_the_recursion_into_a_data_structure There some other more efficient algorithms discussed further down on that page. Perhaps there is some performance to gain using one of those implementations instead, probably still on the slower side for large spaces on some devices, but maybe better than current version.