Skip to content

Sockets: can-send check with lwIP's select rather than the VFS select - #11

Merged
robdobsn merged 1 commit into
mainfrom
perf/lwip-select
Oct 25, 2026
Merged

robdobsn merged 1 commit into
mainfrom
perf/lwip-select

Conversation

@robdobsn

Copy link
Copy Markdown
Owner

The sockets connection's can-send check (RaftClientConnSockets::canSend()) now calls lwip_select() rather than select().

ESP-IDF's select() goes through the VFS, which sets up semaphores and checks every VFS driver on each call. That took about 0.5 ms on an ESP32-S3, against at most about 50 µs for lwip_select(). The check runs before each HTTP response and each WebSocket publish.

Measured

Plant growth board (ESP32-S3, quad flash in QIO mode), longest WebServer hold on the main loop, one HTTP request (/api/v) a second:

  • can-send check: about 0.48 ms before, at most 0.05 ms after;
  • response step (check, headers, body): 2.2 ms before, 1.2-1.35 ms after;
  • whole request, longest single loop pass: 4.3-4.5 ms before, 2.7-3.2 ms after.

This was meant to go in #10, but was pushed after #10 was merged.

🤖 Generated with Claude Code

select() goes through the VFS, which sets up semaphores and checks every VFS driver on each call: about 0.5 ms on
an ESP32-S3, against 50 us for lwip_select(). The check is made before each HTTP response and each WebSocket
publish. An HTTP request (/api/v) took up to 5.7-6.1 ms of the main loop, and now 2.7-3.2 ms (with QIO flash,
which made the rest of the handling faster too).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant