7.2.x autoreload rework (again)#6142
Merged
Merged
Conversation
This sounds good! It will help with a problem I often saw, where a program would stutter just before auto-reload would kick in. |
tannewt
approved these changes
Mar 12, 2022
tannewt
left a comment
Member
There was a problem hiding this comment.
Nice! I love the simplification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#6132 had a regression: when doing fake deep sleep, a write to CIRCUITPY waited until sleep was done instead of restarting immediately. I fixed this but still saw some flakiness.
After some cogitation, I reworked the basic logic of auto-reload. Instead of using ticks to count down a time before raising the reload exception, I raise the exception immediately, and then wait in main.c for the auto-reload delay, restarting the clock if new writes occur. auto-reload is also check in the fake/real sleep loop in main.c, as before. The new code is a little smaller.
Summary:
CIRCUITPY_AUTORELOAD_DELAY_MSfrom 500 ms to 750 ms. At 500 ms I sometimes saw IOErrors or filesystem corruption, especially when using emacs, which writes backup files.supervisor/shared/autoreload.*tosupervisor/shared/reload.*because of the next change.py/reload.*code tosupervisor/shared/reload.*Tested on CPX, Feather nRF52840, MagTag, and Feather RP2040.
Basic test program (which I edited repeatedly):
Also tested with simulated deep sleep on MagTag and Feather nRF52840.
I'd be happy if others tried this too, to see if fixes #6007 for them.