-
Notifications
You must be signed in to change notification settings - Fork 27
Fix Async polling interval to 1 second #77
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,7 @@ struct tcp_core_guard { | |
TCP poll interval is specified in terms of the TCP coarse timer interval, which is called twice a second | ||
https://github.com/espressif/esp-lwip/blob/2acf959a2bb559313cd2bf9306c24612ba3d0e19/src/core/tcp.c#L1895 | ||
*/ | ||
#define CONFIG_ASYNC_TCP_POLL_TIMER 1 | ||
#define CONFIG_ASYNC_TCP_POLL_TIMER 2 // Called every 2 * 500ms | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this change ? if you need to make such change, should this me a config, like core, size size, etc ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reviewed the function The function To align with the original design intention of using a polling interval in seconds, I suggest updating the configuration to CONFIG_ASYNC_TCP_POLL_TIMER = 2. I also referred to the TCP poll interval specification at: Let me know if I’ve misunderstood something. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @willmmiles @me-no-dev WDYT ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the current default of 500ms (the smallest possible poll interval) is probably the best default value for most use cases. Given that it's a compile time selection, it's much easier for client applications to ignore extra polls than add another task to poll more often.
I don't think this is correct, do you have a source for this? The comment on line 95 is quite clear that the polling interval is specified in LwIP TCP ticks, and it doesn't appear in any other documentation. The use cases of the LwIP poll callback aren't just - or even primarily - about timeouts; it's most useful as an application feature for scheduling connection-related work on the async thread. Frequent polling is an asset IMO; personally I've wished it could be set to a smaller value! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your comments! I’m confident that this configuration does not change the default polling interval of the LwIP core. What I meant is that this change only affects the Async thread, where the intended polling interval is 1 second. I reviewed the _poll function and the API settings for ACK timeout and RX timeout, and their intention appears to be in seconds, not 500ms. However, the current configuration using a 500ms polling interval works fine because the logic inside the _poll function correctly checks for a timeout after 1000ms. I believe this update is just an improvement to make the behavior more consistent and easier to understand. I may have misunderstood the original design concept, but it works fine for me. Please let me know if this update is invalid, and I will cancel it. Thank you! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not think we should change the default polling interval. I think you may have missed that the the _poll function has three tasks:
Although the first two are configured in seconds, the third is not, and so the whole There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your feedback! You are right about the third task. However, I don’t fully understand the point you mentioned regarding the user application. The current default configuration sets the ACK timeout to 3 seconds. The user application, such as AsyncWebServer, also uses a default RX timeout of 3 seconds. Could you share some use cases for the motivation behind this configuration? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some use cases that come to mind:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks a lot for sharing! On the other hand, do you think we should support a function to configure the polling interval for other types of client applications, such as the one I intend to use? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for taking so long to follow up on this one. With respect to the default behaviour of an Another key point is that the poll timer is also the maximum latency before an application will be notified of a timeout. For example, if you set the poll timer to 2 seconds, with an Rx timeout of 2 seconds, you could see something like:
That said: I don't have any objections to adding a new |
||
|
||
/* | ||
* TCP/IP Event Task | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider defining a named constant (e.g.,
COARSE_TIMER_TICKS_PER_SECOND
) instead of using the magic number2
to improve readability.Copilot uses AI. Check for mistakes.