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

7.2.x autoreload rework (again) #6142

Merged
merged 1 commit into from
Mar 12, 2022

Conversation

dhalbert
Copy link
Collaborator

#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:

  • Moved sleep countdown to main.c.
  • Lengthened CIRCUITPY_AUTORELOAD_DELAY_MS from 500 ms to 750 ms. At 500 ms I sometimes saw IOErrors or filesystem corruption, especially when using emacs, which writes backup files.
  • Interrupt running program immediately on write to CIRCUITPY. This makes the program stop faster, and gives the user immediate feedback which ameliorates the lengthened delay. It's also safer, because the program is not running while the filesystem is changing.
  • Renamed supervisor/shared/autoreload.* to supervisor/shared/reload.* because of the next change.
  • Moved code in py/reload.* code to supervisor/shared/reload.*
  • Changed some function names again, after Make autoreload checking more robust #6132's changes.

Tested on CPX, Feather nRF52840, MagTag, and Feather RP2040.

Basic test program (which I edited repeatedly):

for j in range(10000):
    for i in range(1000):
        pass
    print("doing stuff", j)

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.

@jepler
Copy link
Member

jepler commented Mar 11, 2022

I raise the exception immediately, and then wait in main.c for the auto-reload delay, restarting the clock if new writes occur.

This sounds good! It will help with a problem I often saw, where a program would stutter just before auto-reload would kick in.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Nice! I love the simplification.

@tannewt tannewt merged commit 7cb66dd into adafruit:7.2.x Mar 12, 2022
@dhalbert dhalbert deleted the 7.2.x-autoreload-fake-sleep branch March 12, 2022 02:41
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