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

Pico-W: bad network throughput running as a webserver #9837

Open
bablokb opened this issue Nov 27, 2024 · 3 comments
Open

Pico-W: bad network throughput running as a webserver #9837

bablokb opened this issue Nov 27, 2024 · 3 comments
Labels
bug network rp2 Both RP2 microcontrollers
Milestone

Comments

@bablokb
Copy link

bablokb commented Nov 27, 2024

CircuitPython version

at least since 8.0.5

Code/REPL

see https://github.com/bablokb/circuitpython-examples/tree/master/webserver

Behavior

see below

Description

The example scenario runs a webserver. The main page sources a number of js and css-files. This triggers multiple parallel requests from the browser to the server. Total download size is about 140KB, throughputs (measured as total download time from within the browser development tools) are as follows:

  • Pico-W (8.0.5 and 9.2.1): about 11s
  • Pico Plus2 W: about 11s
  • Adafruit Feather ESP32-S3 (4MB/2MB): about 1s

Additional information

This issue is opened on request of @eightycc, see #9826 (comment)

Searching the web for throughput figures for the Pico-W does not turn up many results. Some tests use iperf, but this is an artificial tool and does not test the given scenario. But maybe iperf could help to track down the cause. It seems there is a Python/MicroPython version available, so it might be worth a look.

@bablokb bablokb added the bug label Nov 27, 2024
@dhalbert dhalbert added this to the 9.2.x milestone Nov 27, 2024
@dhalbert dhalbert added network rp2 Both RP2 microcontrollers labels Nov 27, 2024
@bablokb
Copy link
Author

bablokb commented Nov 27, 2024

See this post: https://forums.raspberrypi.com/viewtopic.php?t=339512

They claim using iperf they see

near 10 Mbits/sec at data size greater than 1 MByte

But this is with the Pico-W running as a client and it is a huge data size for an MCU, so this is not realistic in any way.

@eightycc
Copy link

@bablokb Thank you for opening the issue and providing the diagnostic. I was able to easily reproduce the performance glitch.

Capturing a trace with WireShark, I can see that TCP PSH/ACK packets from the server are sometimes delayed by up to 500 ms. Interestingly, the delayed packets always arrive on exact 500 ms offsets from the start of the trace, i.e., +4.620 ms, +5.120 ms, and so on. This tells me that ACKs from the client aren't always causing an IRQ or the IRQ is getting ignored. The reason we're beating at 500 ms is that a periodic timer in CircuitPython (or less likely the CYW43) is causing a poll of pending interrupts to occur.

@bablokb
Copy link
Author

bablokb commented Nov 30, 2024

I ported iperf to CircuitPython: https://github.com/bablokb/circuitpython-iperf. Might be useful for anybody tweaking network code.

Still needs some polishing and it is currently only tested with a Pico-W. The results reproduce what we already know:

> iperf3 -l 4K -c 192.xxx.x.xxx
Connecting to host 192.xxx.x.xxx, port 5201
[  5] local 192.xxx.x.xxx port 35514 connected to 192.xxx.x.xxx port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   792 KBytes  6.49 Mbits/sec    0   27.1 KBytes       
[  5]   1.00-2.00   sec   600 KBytes  4.91 Mbits/sec    0   27.1 KBytes       
[  5]   2.00-3.00   sec   640 KBytes  5.24 Mbits/sec    0   27.1 KBytes       
[  5]   3.00-4.00   sec   600 KBytes  4.92 Mbits/sec    0   27.1 KBytes       
[  5]   4.00-5.00   sec   720 KBytes  5.90 Mbits/sec    0   27.1 KBytes       
[  5]   5.00-6.00   sec   680 KBytes  5.57 Mbits/sec    0   27.1 KBytes       
[  5]   6.00-7.00   sec   640 KBytes  5.24 Mbits/sec    0   27.1 KBytes       
[  5]   7.00-8.00   sec   680 KBytes  5.57 Mbits/sec    0   27.1 KBytes       
[  5]   8.00-9.00   sec   600 KBytes  4.92 Mbits/sec    0   27.1 KBytes       
[  5]   9.00-10.00  sec   680 KBytes  5.57 Mbits/sec    0   27.1 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  6.48 MBytes  5.43 Mbits/sec    0   sender
[  5]   0.00-10.41  sec  6.38 MBytes  5.14 Mbits/sec        receiver

iperf Done.

> iperf3 -l 4K -R -c 192.xxx.x.xxx
Connecting to host 192.xxx.x.xxx, port 5201
Reverse mode, remote host 192.xxx.x.xxx is sending
[  5] local 192.xxx.x.xxx port 57898 connected to 192.xxx.x.xxx port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.02   sec  60.0 KBytes   483 Kbits/sec                  
[  5]   1.02-2.01   sec  52.0 KBytes   432 Kbits/sec                  
[  5]   2.01-3.04   sec  52.0 KBytes   411 Kbits/sec                  
[  5]   3.04-4.03   sec  52.0 KBytes   433 Kbits/sec                  
[  5]   4.03-5.01   sec  52.0 KBytes   433 Kbits/sec                  
[  5]   5.01-6.01   sec  52.0 KBytes   426 Kbits/sec                  
[  5]   6.01-7.09   sec  56.0 KBytes   425 Kbits/sec                  
[  5]   7.09-8.01   sec  48.0 KBytes   426 Kbits/sec                  
[  5]   8.01-9.12   sec  36.0 KBytes   267 Kbits/sec                  
[  5]   9.12-10.19  sec  32.0 KBytes   244 Kbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.47  sec   498 KBytes   389 Kbits/sec    0   sender
[  5]   0.00-10.19  sec   492 KBytes   396 Kbits/sec        receiver

iperf Done.

The first run is my laptop sending data, the second run (with the -R i.e. reverse mode option) the Pico-W is sending and the laptop is the receiver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug network rp2 Both RP2 microcontrollers
Projects
None yet
Development

No branches or pull requests

3 participants