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

threaded=True is slow #46

Closed
silverchen0402 opened this issue Oct 29, 2018 · 9 comments
Closed

threaded=True is slow #46

silverchen0402 opened this issue Oct 29, 2018 · 9 comments

Comments

@silverchen0402
Copy link

Hi

I use your great module for my nodemcu-32s v1.1 board, micropython version 1.9.4, everything looks fine, but when I start webserver with threaded=True, the response is slow, about 4s, however it's ~200ms when threaded mode is False.

I have no idea why this happens, my micropython is clean, no other modules and I use IP to connect the device, so it seems not an DNS issue, could you give me some hints about this?

Thanks a lot.
-Silver

@jczic
Copy link
Owner

jczic commented Dec 9, 2018

Hello and sorry for my very late answer!
It is strange indeed..
Just, can you try on your platform to increase the stack size before creating the threaded server with a call to _thread.stack_size([size]) ?

@jczic
Copy link
Owner

jczic commented Dec 9, 2018

microWebSrv uses just one synchronous pipe-line (threaded or not) and more for websockets connections.
I'll remake it with my async lib : https://github.com/jczic/XAsyncSockets :)

@gengshenghong
Copy link

Thank you for your nice work.

Same issue here, it takes 3 seconds to respond with very simple http server (same with #42). I can confirm it works with "mws.Start(threaded=False)"

Suggestion:
Document it clearly about the limitation or by default set it as False at least. For first-time users, this waste some time as we usually use "default configuration" for testing purpose, and I started to think what is wrong with my network (as I cannot imagine a http test request takes 3 secs!). Of course, if it can be root-cased and fixed, that is better. :) Looking forward to the synchronous version.

Thanks,
Shenghong

@jczic
Copy link
Owner

jczic commented Dec 19, 2018

Ok thanks.
I will test further because it doesn't make sense for a single thread on the server to take so long.

@jczic
Copy link
Owner

jczic commented Dec 19, 2018

So, I have removed the thread allocation testing :
73cd549
But on computer or my emmbeded controller, the thread mode is faster than the no-threaded.
Strange ?

@gengshenghong
Copy link

Sorry, I was using Lyrat which has psRAM, but running normal micro-python. It seems there are some issues for normal micro-python on Lyrat (with psRAM) and there is a special version for it. Whatever, my actual intention is to use esp32 WROOM (without psRAM), on this board, it seems OK with or without threads, I'll focus on this board and test further.

Thanks,
Shenghong

@gengshenghong
Copy link

@jczic some updates, please take a look at micropython/micropython#4372

Now I focus on esp32 WROOM (no psRAM) module and take some careful tests.
I got same results using MicroWebSrv for the testing. It seems like thread behavior is strange in micropython....

@jczic
Copy link
Owner

jczic commented Feb 3, 2019

Hello @gengshenghong, some news about this problem with readline IO ?

@jczic jczic closed this as completed Feb 28, 2019
@jczic
Copy link
Owner

jczic commented Oct 20, 2019 via email

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

No branches or pull requests

3 participants