trio-websocket
trio-websocket copied to clipboard
server high CPU load
I'm seeing high CPU load of the server relative to my current implementation, which is running https://github.com/dpallot/simple-websocket-server via trio.run_sync_in_worker_thread().
The workload is many small messages, typically < 80 bytes, mostly one-way communication. trio-websocket consumes 2-3x more CPU.
with simple-websocket-server the sends are synchronous, so no backpressure, but it means that the Trio scheduler is much less used
Have you tried profiling? I find vmprof particularly useful because it combines low-overhead, useful visualization, and a nice web interface so you can share profiles with other people. (Do be warned if you have proprietary code though that it uploads some data to the web, which is why it can do the nice sharing but OTOH some people get antsy.)
Basically:
pip install vmprof
python -m vmprof --web <your script that runs too slow>
Did you install wsaccel? It was not included as a dependency in the current PyPI release (0.0.1) but it is a dependency now on master. I haven't benchmarked with and without wsaccel, so I don't know how much of a difference it makes.
Yes, wsaccel installed. I checked and it doesn't make any difference.