Skip to content
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

Use 75% of the buffer for speeds higher than 115200 #22774

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

mrkev-gh
Copy link
Contributor

@mrkev-gh mrkev-gh commented Jan 6, 2025

Higher speeds need larger buffer. Processing takes longer, so let's put the threshold at 75% of the buffer size to have some headroom. E.g. for 1Mbit with 2.5kB buffer 2048 characters would be roughly still around 20ms, and reserve additional 512 chars / 5ms to handle the buffer after the threshold is reached

Description:

Related issue (if applicable): fixes #

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.8
  • The code change is tested and works with Tasmota core ESP32 V.3.1.0.241206
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

I do not expect 8266 would be able to handle 1Mbit+ speeds.
To use with TCP Serial Bridge TCP_BRIDGE_BUF_SIZE needs to be increased.
Tested on ESP32-C3 and 1.5Mbit (rockchip serial console speed) with a 4kB buffer

Higher speeds need larger buffer. Processing takes longer, so let's put the threshold at
75% of the buffer size to have some headroom. E.g. for 1Mbit with 2.5KB buffer 2048 characters
would be roughly still around 20ms, and reserve additional 512 chars / 5ms to handle the
buffer after the threshold is reached
@s-hadinger
Copy link
Collaborator

Looks ok to me, but note that I never use serial above 115200

@arendst arendst merged commit b472e82 into arendst:development Jan 6, 2025
59 checks passed
@mrkev-gh
Copy link
Contributor Author

mrkev-gh commented Jan 6, 2025

@s-hadinger Thanks for the review. The only outstanding thing is the need to redefine the TCP_BRIDGE_BUF_SIZE. Would you be open to dynamic buffer allocation in TCP Bridge? E.g. for >115200 to allocate the size based on TCPBaudRate setting to keep 20ms worth of chars and 5ms for processing, so...assuming 8N1 that would be something like 25/(1/(baudrate/9)*1000) bytes. , for 1,5Mbit that's 4.07kB total - roughly what I'm successfully running with on ESP32. I don't have anything else to really test it on, but OTOH the current 256 byte buffer is insufficient for anything over 115200.

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.

3 participants