Repository navigation
Conversation
To start with, the critical scripts _boot.py and flashbdev.py are frozen to improve performance and reduce RAM consumption. Saves about 1000 bytes of heap RAM for a bare boot with filesystem.
|
Issue #2066 now seems to be fixed, so this PR could be merged. Freezing webrepl (not part of this PR) takes heap usage (during a webrepl session) from about 9700 bytes used down to 7300, so about 2400 bytes of RAM saved. |
|
Hello Damien, did you tell above that webrepl is not supported yet with this PR? If yes, then I can confirm. Otherwise, starting webrepl from frozen byte code causes an error: Other test code like ntptime and port_diag runs, as well as my test software, which used to crash with the previous attempt when used through webrepl. |
Actually, for me, frozen webrepl is now supported with this PR (ie moving all scripts from scripts/ to modules/ works). Note that you need to upgrade to the latest esp-open-sdk and do: |
|
After downloading and rebuilding the esp-open-sdk again and doing the same with the esp8266 port, now webrepl works. I had rebuilt the esp-open-sdk already a week ago. Something might have changed in between. Thanks for the great work! |
|
Continuing from #2201 (comment) . I believe I fixed all issues reported on esp side which were on critical path to make this work, so this should be ok to merge. I myself didn't test it though, and don't know when I will be able to. So, I think it should be there just not-yet-official feature, for advanced users to play with. Unless @dpgeorge actually wants to switch any frozen scripts to bytecode soon, then please lead on that (but it wasn't part of KS campaign, so I think we should work on it in background, giving priority to esp-specific issues and stretch goals; in particular, I don't think that enabling frozen bytecode is a panacea to memory allocation issues). |
|
It is certainly not the panacea but it is needed to avoid the issue of parsing code on board blowing up memory. I totally agree that this won't very much at all if you are not diligent with memory allocation and collection for your application first. |
|
Merged in db80c0e. |
This PR allows to use frozen bytecode with the ESP8266. The directory to freeze is called "modules/".
To start with, only the critical scripts _boot.py and flashbdev.py are frozen to improve performance and reduce RAM consumption. By freezing these 2 files the firmware size is reduced by about 900 bytes (.mpy is smaller than .py source file) and it saves about 1000 bytes of heap RAM for a bare boot with filesystem. (Actually, firmware size increases by about 1.3k to enable this feature, but then drops by about 900 bytes when moving the 2 files from scripts/ to modules/, so net change in firmware size is about +400 bytes; would be expected to go down once more scripts are frozen.)
Results from a fresh boot, then gc.collect(), then micropython.mem_info() are:
Freezing other scripts is blocked by #2066.
Unfortunately there is a hit in performance of about 12%: