Page 3 of 3

Re: ws: tiny asynchronous webserver framework without uasyncio

Posted: Fri Nov 17, 2017 7:07 pm
by bitninja
jacob019 wrote:
Fri Nov 17, 2017 6:21 pm
I would really like to figure out why you are not getting the same results:
1. Are you on the ESP8266?
2. Is the device connected to the network in STA mode?
Yes, I am using a Wemos D1 Mini and I am connecting to my local wifi in STA mode.

Re: ws: tiny asynchronous webserver framework without uasyncio

Posted: Fri Nov 17, 2017 7:08 pm
by jacob019
@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.

Re: ws: tiny asynchronous webserver framework without uasyncio

Posted: Sat Nov 18, 2017 9:22 am
by pythoncoder
jacob019 wrote:
Fri Nov 17, 2017 7:08 pm
...I'll open an issue on the micropython github repo when I get a chance...
That would be very useful.
jacob019 wrote:
Fri Nov 17, 2017 7:08 pm
......the discrepancy goes away in the simplest of examples where there aren't any function calls in the loop...
Worth pointing out when you raise the issue; also the point about the resultant heavy performance hit when using uasyncio.

Re: ws: tiny asynchronous webserver framework without uasyncio

Posted: Tue Nov 21, 2017 10:00 pm
by jacob019
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.