[Feature Request] Improve performance of TCP stack

Aperta
#1,380 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
15/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c

Direzione di ricerca

The payload names no source files, only the FreeRTOS-Plus-TCP library and the ordered table of five stack changes (TCP ACK handling, segment bursting, jumbo frames, ARP lookup skipping, and larger TCP buffers). Start by reading the issue's table and the TCP send and receive paths in the library, then reproduce the transmit and receive loops on a comparable target. Done would mean the proposed changes land as separate pull requests with before-and-after throughput numbers. The issue asks for design work, so a newcomer should first confirm scope with the maintainers.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Is your feature request related to a problem? Please describe.

Running the stack on a 125MHz Nios-V core with a mailbox-DMA 10GbE network driver gives throughput of about 2.4MB/s.

Tests include both sends and receives of various buffer sizes. The CPU clock being 125MHz limits the achievable performance well short of 10GbE, the theoretical max being 70MB/s ie the limit to how fast the CPU can produce data from DDR cache-line traffic, but with the stack the way it is, with two copies of each byte, 12MB/s should be achievable, and with only one copy, 24MB/s may be achievable.

Before touching the TCP stack, I have improved the performance of my application and the memory allocator and started profiling the transfers.

Describe the solution you'd like

I'd like to tune the TCP stack to get better performance, aiming for about 10MB/s transfer or receive on this setup. This should also benefit all users of the TCP stack by providing better throughput and round-trip latency of both small and large requests and responses.

Describe alternatives you've considered

I have done single-concern changes in my application and done transmit and send test loops with varying buffer sizes for each concern. These led to 11 changes in the application including 5 different improvements in the TCP stack itself - I include the changes to the application in the below table so that anyone else seeking network performance in their embedded application might apply the same techniques.

The last 5 changes, in bold, necessitate changes in the TCP stack

Commit TX, 1460 B sends TX, 16 KB sends TX, 256 KB sends RX
Start (kB/s) 1766 2181 – 3077
word-wise memcpy +31% +39% – +58%
larger TCP buffers −2% +29% +24% +75%
no network task wake per sent frame +1% +6% +5% +3%
no per-frame receive lookups +2% +5% +9% +1%
one IP task event per burst of received frames 0% −2% −5% +15%
lean DMA descriptor submit +6% +5% +5% +1%
fewer TCP ACKs from Linux 0% +27% +28% –
send TCP segments in bursts −7% +36% +34% +1%
send TCP jumbo frames +5% +39% +60% −1%
TCP jumbo fallback +4% 0% −1% +1%
skip TCP ARP lookup +8% +3% +2% 0%
End (kB/s) 2598 8909 9648 6307

While single-MSS transfers didn't change much, due to the amount of work the stack does per send, I've so far achieved a 4x increase in performance for multi-MSS receives and sends, with half of the improvement necessitating changes in the FreeRTOS-Plus-TCP stack.

Additional context

Tried and dropped, against the image without the change:

Change TX, 1460 B sends TX, 16 KB sends TX, 256 KB sends RX
TX stream buffer of 8 x MSS, small enough for the data cache +5% −15% −10% +1%
Stack and kernel built with -Os instead of -O2 −9% −10% – −16%

I'd like to follow up this ticket with PRs for the 5 changes above, and I am also actively seeking other remedies to increase TCP throughput, so if any readers out there have other ideas, I'm all 👂🏼

Lingua principale
C
Stelle
215
Fork
222
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di FreeRTOS/FreeRTOS-Plus-TCP

Tutte le issue di FreeRTOS/FreeRTOS-Plus-TCP

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.