Skip to content

Bugfix/improve event handling path timing - #168

Open
alisitsyn wants to merge 2 commits into
mainfrom
bugfix/improve_event_handling_path_timing
Open

Bugfix/improve event handling path timing#168
alisitsyn wants to merge 2 commits into
mainfrom
bugfix/improve_event_handling_path_timing

Conversation

@alisitsyn

@alisitsyn alisitsyn commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

Description

This MR addresses the throughput issues in Modbus TCP Slave. The investigation of timing aspects in the loop is performed as part of this PR. The event loop has been improved to decrease gap time between reading of different registers when more events (IO + sock events) are happened with multi-master connections. Different events can be processed sequentially avoiding additional time gaps with the select() timeouts. Additional kconfig values are added for fine tune of the TCP event loop processing.

Related

Fixes: EPROT-50
Related: EPROT-55

Testing

The testing is performed manually with four masters connected to the same ESP32 Modbus TCP Slave. The event loop related parameters and their impact to overall processing are investigated and moved to kconfig configuration allowing better turning in user applications.

Kconfig Option Default Range Macro Impact
FMB_TCP_SELECT_WAIT_MS 50 10–500 MB_SELECT_WAIT_MS Driver loop select() blocking time. Lower = faster wake-up when events arrive mid-block
FMB_TCP_READ_TIMEOUT_MS 150 1–500 MB_READ_TICK SO_RCVTIMEO for MBAP header read. The biggest latency risk — a partial TCP segment stalls the entire loop
FMB_TCP_SEND_TIMEOUT_MS 100 10–1000 MB_TCP_SEND_TIMEOUT_MS Writability check + send timeout. Under congestion, this is a per-response stall
FMB_TCP_EVENT_LOOP_TICK_MS 50 5–200 MB_TCP_EVENT_LOOP_TICK_MS Event loop time budget. Controls how long events block before returning to sockets

Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary (manual tests).
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

@mo-rige

mo-rige commented May 5, 2026

Copy link
Copy Markdown

I hope to promote the code version for easy testing and use as soon as possible

@alisitsyn

Copy link
Copy Markdown
Collaborator Author

@mo-rige,

In order to check the issue we need the example code to reproduce issue on both sides with existing environments (base standpoint). As I said the communication timings depend on many aspects and I have different results on my side (wifi for now). If you can, please publish your simplified project which can be used for verification and the sdkconfig file. I will take a look ASAP.

Thanks.

@mo-rige

mo-rige commented May 13, 2026

Copy link
Copy Markdown

@alisitsyn Ok, I will try to streamline the project and achieve its objectives. Please hold on while I upload the complete version of my current project first

@mo-rige

mo-rige commented May 13, 2026

Copy link
Copy Markdown

ESP32S3-M0001.zip
MyProject

@alisitsyn
alisitsyn force-pushed the bugfix/improve_event_handling_path_timing branch from 37dd099 to b3b7066 Compare May 13, 2026 12:08
@alisitsyn
alisitsyn force-pushed the bugfix/improve_event_handling_path_timing branch from b3b7066 to bff8193 Compare July 1, 2026 09:22
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.

Modbus TCP Slave response time (EPROT-50)

2 participants