trio-websocket icon indicating copy to clipboard operation
trio-websocket copied to clipboard

server high CPU load

Open belm0 opened this issue 7 years ago • 3 comments

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

belm0 avatar Sep 19 '18 12:09 belm0

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>

njsmith avatar Sep 20 '18 06:09 njsmith

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.

mehaase avatar Sep 20 '18 12:09 mehaase

Yes, wsaccel installed. I checked and it doesn't make any difference.

belm0 avatar Sep 20 '18 13:09 belm0