{"action":"created","issue":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/2397","repository_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware","labels_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/2397/labels{/name}","comments_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/2397/comments","events_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/2397/events","html_url":"https://github.com/nodemcu/nodemcu-firmware/issues/2397","id":330960713,"node_id":"MDU6SXNzdWUzMzA5NjA3MTM=","number":2397,"title":"Performance regression in WiFi connection since SDK 2.2","user":{"login":"eyaleb","id":8308047,"node_id":"MDQ6VXNlcjgzMDgwNDc=","avatar_url":"https://avatars2.githubusercontent.com/u/8308047?v=4","gravatar_id":"","url":"https://api.github.com/users/eyaleb","html_url":"https://github.com/eyaleb","followers_url":"https://api.github.com/users/eyaleb/followers","following_url":"https://api.github.com/users/eyaleb/following{/other_user}","gists_url":"https://api.github.com/users/eyaleb/gists{/gist_id}","starred_url":"https://api.github.com/users/eyaleb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eyaleb/subscriptions","organizations_url":"https://api.github.com/users/eyaleb/orgs","repos_url":"https://api.github.com/users/eyaleb/repos","events_url":"https://api.github.com/users/eyaleb/events{/privacy}","received_events_url":"https://api.github.com/users/eyaleb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-06-10T11:25:59Z","updated_at":"2018-08-07T13:27:59Z","closed_at":null,"author_association":"NONE","body":"8<------------------------ BUG REPORT -----------------------------------------\r\n\r\nIn the last few months I noticed that my esp8266 devices run out of battery power sooner than before.\r\nLooking at the timing data (which the devices include in each report) I see a consistent slowdown.\r\n\r\nMost connections are fast at about 500ms, so my app sleeps after about 600. This did not change.\r\n\r\nIf the connection fails at first (there are over 10 devices on a 1m loop so they clash about 15% of the time) then the connection takes about 2s longer to establish.\r\n\r\nSince the change to `SDK 2.2` this second case takes an extra 600ms.\r\n\r\nThe program just waits for a `GOT_IP` condition, having set a static IP, and using the a/p credentials stored internally.\r\n\r\nBTW, if the 2s delay is due to a clash, is the timing controlled by the esp or by the a/p?\r\n\r\n### Expected behavior\r\n\r\nConnection time, when the fast path fails, takes about 2.6s.\r\n\r\n### Actual behavior\r\n\r\nConnection time, when the fast path fails, takes about 3.2s.\r\n\r\ncode using the last SDK 2.1:\r\n```\r\nNodeMCU 2.1.0 build dev-20180609-2330-4367e6e9e0-1m-all powered by Lua 5.1.4 on SDK 2.1.0(116b762)\r\n\r\n0.187675 main: code 2 reason 5 cause 99\r\n0.202800 main: using node.dsleep\r\n0.223415 main: static IP set to '192.168.2.47' for 'esp-12f'\r\n0.291979 read: reading 'ds18b20'\r\n0.377738 read: read[1]=18.1250\r\n0.395416 read: have Reading 18.1250\r\n0.497170 wifi: GOT_IP after 0.061069 seconds, ip=192.168.2.47 status=5 channel=11\r\n\r\n0.187977 main: code 2 reason 5 cause 99\r\n0.203099 main: using node.dsleep\r\n0.223724 main: static IP set to '192.168.2.47' for 'esp-12f'\r\n0.290711 read: reading 'ds18b20'\r\n0.376455 read: read[1]=17.8750\r\n0.394129 read: have Reading 17.8750\r\n2.586672 wifi: GOT_IP after 2.151689 seconds, ip=192.168.2.47 status=5 channel=11\r\n```\r\ncode using the first SDK 2.2:\r\n```\r\nNodeMCU 2.2.0.0 build dev-20180910-1012-f3ebfa9bfe-1m-all powered by Lua 5.1.4 on SDK 2.2.0(f28eaf2)\r\n\r\n0.188819 main: code 2 reason 5 cause 99\r\n0.204287 main: using node.dsleep\r\n0.225542 main: static IP set to '192.168.2.47' for 'esp-12f'\r\n0.294239 read: reading 'ds18b20'\r\n0.380305 read: read[1]=19.2500\r\n0.398011 read: have Reading 19.2500\r\n0.500400 wifi: GOT_IP after 0.061582 seconds, ip=192.168.2.47 status=5 channel=11\r\n\r\n0.185920 main: code 2 reason 5 cause 99\r\n0.201375 main: using node.dsleep\r\n0.222637 main: static IP set to '192.168.2.47' for 'esp-12f'\r\n0.288547 read: reading 'ds18b20'\r\n0.374579 read: read[1]=19.0000\r\n0.392287 read: have Reading 19.0000\r\n3.152458 wifi: GOT_IP after 2.718079 seconds, ip=192.168.2.47 status=5 channel=11\r\n```\r\nNote how the ds18b20 reading time is practically identical for all cycles. It is then that the app waits for an IP:\r\n```\r\neventmon.register(eventmon.STA_GOT_IP, function(T) have_connection(\"GOT_IP\") end)\r\n```\r\nI checked and the latest dev timing is identical to the first SDK 2.2 commit. The above builds were made locally from a git commit tag (downloaded the zip file).\r\n\r\n### NodeMCU version\r\nI am on the dev branch, and the above two show the commits after the date-time.\r\n\r\n### Hardware\r\nAny, but the above examples use a naked esp-12f on a small breadboard.\r\n"},"comment":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/comments/411055573","html_url":"https://github.com/nodemcu/nodemcu-firmware/issues/2397#issuecomment-411055573","issue_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/2397","id":411055573,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMTA1NTU3Mw==","user":{"login":"eyaleb","id":8308047,"node_id":"MDQ6VXNlcjgzMDgwNDc=","avatar_url":"https://avatars2.githubusercontent.com/u/8308047?v=4","gravatar_id":"","url":"https://api.github.com/users/eyaleb","html_url":"https://github.com/eyaleb","followers_url":"https://api.github.com/users/eyaleb/followers","following_url":"https://api.github.com/users/eyaleb/following{/other_user}","gists_url":"https://api.github.com/users/eyaleb/gists{/gist_id}","starred_url":"https://api.github.com/users/eyaleb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eyaleb/subscriptions","organizations_url":"https://api.github.com/users/eyaleb/orgs","repos_url":"https://api.github.com/users/eyaleb/repos","events_url":"https://api.github.com/users/eyaleb/events{/privacy}","received_events_url":"https://api.github.com/users/eyaleb/received_events","type":"User","site_admin":false},"created_at":"2018-08-07T13:27:59Z","updated_at":"2018-08-07T13:27:59Z","author_association":"NONE","body":"Thanks @TerryE, I need to find the time to read the SDK doco, and learn more about the details of wifi connection. I expect `COUNTRY_AUTO` is what I should use.\r\n\r\nI use autoconnect (I do not set any credentials). I do set static IP as it is not saved. The result is that I get a connection rather fast, often 100-200ms after the app starts (if it does not hog the CPU).\r\n\r\nThe app is simple:\r\n- set IP\r\n- read sensors\r\n- wait for a connection (e.g. eventmon)\r\n\r\nIf I do manual connection then the process is very much longer, a few seconds. My understanding is that issuing manual connection requests restarts the whole wifi connection.\r\n\r\n[As an aside, this discussion should really move elsewhere, the subject of this issue is the performance regression when we upgraded to SDK 2.2. I need to establish an SDK app that demonstrates the issue and submit it to espressif].\r\n"}}
{"actor":{"display_login":"eyaleb"}}