-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
LFS flashing alters core firmware behavior resulting in panic #3109
Comments
The existence of a flashed LFS implies the existence of a LFS string table, which will be loaded even if no code from LFS is ever fetched explicitly; AIUI, this is an artefact of Lua's desire to intern strings for pointer equality testing. Now why that increases the runtime of |
The reason for the increases runtime is an easy one to answer and is discussed in some of my performance papers. Moving If you replace the search string by "([A-Z]+) /([^?])%??(.)".." HTTP" then this will be created in the RAM string table and so will execute at H/W speed. BTW: Your response header doesn't include the
Lua patterns are not regexps and the greedy matches where they aren't needed will always require the match to scan to then end of the string. The URI cannot have embedded space characters so by far the easiest pattern to use is
If you need to split out field 2 into 2A and 2B depending on the parameter separator '?' The panic might be an entirely valid response as the search using a ROM string will be so inefficient. You also need to use the function f(payload,text)
local t0,a,b=tmr.now(), payload:match('^(%w-) +([^ ]-) +HTTP')
print(text,tmr.now()-t0,a,b)
end drops the find execution time from the 50-700 mSec range down by over a factor of a 1,000 to a few hundred uSec. Also note that in this case the find engine isn't doing a triple do loop across the whole string backtracking inside the pattern so the overhead of the extra unaligned exceptions is small and can be ignored. |
BTW, good work for the feedback so thank-you , even if this one was a false alarm. 😄 Post back if you want some extra explanation. I've just closed this because it isn't really an open issue, IMO. |
Expected behavior
The act of node.flashreload() should not change the behavior of the underlying firmware if nothing is ever called from LFS.
Actual behavior
Adding bits of code to LFS, even it never executed, causes string.find() to take 5.5x longer than if those bits of code did not exist in LFS. For more time consuming string.find requests, this causes a watchdog panic.
Scope
Sample Results
Mitigation
Test code
Provide a Minimal, Complete, and Verifiable example which will reproduce the problem.
NodeMCU startup banner, master branch
You MUST include the firmware startup banner to describe the version you are using. We reserve the right to immediately close any bug that doesn't.
NodeMCU 3.0.0.0 built on nodemcu-build.com provided by frightanic.com
branch: master
commit: 3d91785
release:
release DTS: 202002231746
SSL: false
build type: float
LFS: 0x40000
modules: adc,bit,cron,dht,enduser_setup,file,gpio,mqtt,net,node,ow,pwm2,rtcmem,rtctime,sntp,struct,tmr,uart,wifi
build 2020-05-01 12:54 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)
lua: cannot open init.lua
NodeMCU startup banner, dev branch
You MUST include the firmware startup banner to describe the version you are using. We reserve the right to immediately close any bug that doesn't.
NodeMCU 3.0.0.0 built on nodemcu-build.com provided by frightanic.com
branch: dev
commit: 5e2ea5a
release:
release DTS: 202005120049
SSL: false
build type: float
LFS: 0x40000 bytes total capacity
modules: adc,bit,cron,dht,file,gpio,mqtt,net,node,ow,pwm,rtcmem,rtctime,sntp,softuart,struct,tmr,uart,wifi
build 2020-05-12 14:43 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)
cannot open init.lua:
Hardware
Describe which ESP8266/ESP32 device you use and document any special hardware setup
required to reproduce the problem.
The text was updated successfully, but these errors were encountered: