Yes, I am using a Wemos D1 Mini and I am connecting to my local wifi in STA mode.
ws: tiny asynchronous webserver framework without uasyncio
Re: ws: tiny asynchronous webserver framework without uasyncio
@bitninja
802.11n? What version of MicroPython? Do you have anything else running at startup (besides webrepl)?
@pythoncoder
I prepared a minimal test case:
http://jacobstoner.com/test.py
It isn't quite as minimal as I would like, but the discrepancy goes away in the simplest of examples where there aren't any function calls in the loop. The script serves ~100kB of spaces as soon as the port is opened, alternately between identical functions where one uses native code and the other does not. The time spent waiting on select.poll is printed each time.
Here's a shell command to make the requests:
for ((n=0;n<10;n++)); do sh -c 'nc 10.0.0.172 9999 > /dev/zero'; done
The timed output is printed on the REPL:
Not Native: 12669ms
Native: 3646ms
Not Native: 15057ms
Native: 3725ms
Not Native: 11584ms
Native: 3922ms
Not Native: 11080ms
Native: 4232ms
Not Native: 11839ms
Native: 3939ms
Here we see a 2X-3X difference, but for real work loads like file serving the difference is a more dramatic 5X-7X. This is just the time spent waiting on select.poll, other differences in execution speed between native and non-native code should not be reflected here. I'll open an issue on the micropython github repo when I get a chance.
802.11n? What version of MicroPython? Do you have anything else running at startup (besides webrepl)?
@pythoncoder
I prepared a minimal test case:
http://jacobstoner.com/test.py
It isn't quite as minimal as I would like, but the discrepancy goes away in the simplest of examples where there aren't any function calls in the loop. The script serves ~100kB of spaces as soon as the port is opened, alternately between identical functions where one uses native code and the other does not. The time spent waiting on select.poll is printed each time.
Here's a shell command to make the requests:
for ((n=0;n<10;n++)); do sh -c 'nc 10.0.0.172 9999 > /dev/zero'; done
The timed output is printed on the REPL:
Not Native: 12669ms
Native: 3646ms
Not Native: 15057ms
Native: 3725ms
Not Native: 11584ms
Native: 3922ms
Not Native: 11080ms
Native: 4232ms
Not Native: 11839ms
Native: 3939ms
Here we see a 2X-3X difference, but for real work loads like file serving the difference is a more dramatic 5X-7X. This is just the time spent waiting on select.poll, other differences in execution speed between native and non-native code should not be reflected here. I'll open an issue on the micropython github repo when I get a chance.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: ws: tiny asynchronous webserver framework without uasyncio
That would be very useful.
Worth pointing out when you raise the issue; also the point about the resultant heavy performance hit when using uasyncio.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: ws: tiny asynchronous webserver framework without uasyncio
https://github.com/micropython/micropython/issues/3451
The overwhelming majority of commits to micropython are from dpgeorge, the creator, and from pfalcon. There are well over 300 open issues. These guys are stretched thin.
Edit: Good news, Damien just submitted a patch that improves the ESP8266 TCP upload performance by >10X and eliminates the performance difference. I will be using asyncio henceforth.
The overwhelming majority of commits to micropython are from dpgeorge, the creator, and from pfalcon. There are well over 300 open issues. These guys are stretched thin.
Edit: Good news, Damien just submitted a patch that improves the ESP8266 TCP upload performance by >10X and eliminates the performance difference. I will be using asyncio henceforth.