feat(inputs.modbus): Optimize requests#11273
Conversation
|
Dear @srebhan , However, I have been doing some reading concerning modbus and it looks like minimising the number of requests is not always the optimal solution. Each request comes with a cost but each field as well, this means that sometimes it can be better to split a large request into two if this means not touching many addresses we are not interested in. See this publication. How much time it takes for each extra request and each extra field depends on the hardware and the network so there is no generic answer to what is optimal. One needs to try, measure, try, measure. One approach that I found online is the following: set a limit on the number of "omitted" fields you are willing to accommodate in order to reduce the number of requests and optimise accordingly. I have pushed on #11106 a possible implementation of this. Instead of choosing an optimisation mode, the user would set the value of The problem I see, however, is that I do not see how the user would choose the value of |
|
@TimurDela thanks for taking the time to test this! Regarding the Regarding the tradeoff between requests vs. number of registers... Currently, |
dc6b1d1 to
43e5f00
Compare
|
Hello @srebhan, I have tried to rebase my branch on master, merge your changes and then add mine but the first step has closed the pull request #11106 and my subsequent push have not reopened it, even though it says Do you have the possibility to re-open PR #11106 ? As you can see, on my fork, I have both your changes and mine: fork |
|
@TimurDela I have reopened your pr :) |
|
Thank you @MyaLongmire but it looks like I have lost the possibility to modify the PR. It is now a draft but I cannot change its status to open nor ask for reviews. Is there something you can do in the settings of the PR? |
|
@powersj and @TimurDela if you both agree I would like to first merge this PR and then add #11106 which extends this code in a nice way. This way, #11106 becomes smaller and can serve as an example of what needs to be done to add more optimization schemes... |
|
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
resolves #12222
This PR adds a
optimizationparameter that allows for optimizing requests sent to the device. Currently there are four modes,nonedoing nothing besides confirming to the max request size and ignoring empty requestsshrinkremoving leading and trailing fields that are omittedrearrangemoving the request boundaries in order to reduce the total request size further while keeping the number of requestsaggressiveautomatically fill gaps in requests in order to reduce their numberto try to reduce the number of requests sent to the device while covering all fields.