Currently, websockify/websocket.py will give a warning if "numpy" is not available:
WARNING: no 'numpy' module, HyBi protocol is slower or disabled
This is somewhat confusing. First of all, HyBi is definitely not "disabled". And is it really slower? I've done some tests with noVNC, and even when playing Youtube videos with a high frame rate, the process using websocket.py doesn't consume much CPU at all; it rarely shows up in the "top" listing at all. So I'm wondering, has any real measurements been done on this? I've done some Googling and failed to find anything (except problems with numpy...). IMHO, unless we can measure that numpy makes a substantial difference, I think it would be better and more clean to only require standard Python functionality.
The "slower or disabled" part is because there are 4 different python modules that are optional and checked using the same code at the top of websocket.py. For example, if the ssl module is not found, then TLS/wss is disabled. I just pushed a change that will make this clearer.
Numpy is definitely faster. Using the tests/latency.py + tests/latency.html test I get the following results (with 10ms send delay and just running on localhost):
Packet size 2000 bytes:
Packet size 20000 bytes:
Packet size 100000 bytes:
In addition, with 100kb packet sizes, no only is the latency more 6 times higher without numpy, but the server starts to get behind and the client has to back off repeatedly during the test.
Note that numpy really only affects client->server data unmasking, so for uses like noVNC it will be basically irrelevant. However, websockify is not just for noVNC, so in the case where the client is sending a lot of data to server, numpy provides significant performance improvement.
Thanks!
Most helpful comment
The "slower or disabled" part is because there are 4 different python modules that are optional and checked using the same code at the top of websocket.py. For example, if the ssl module is not found, then TLS/wss is disabled. I just pushed a change that will make this clearer.
Numpy is definitely faster. Using the tests/latency.py + tests/latency.html test I get the following results (with 10ms send delay and just running on localhost):
Packet size 2000 bytes:
Packet size 20000 bytes:
Packet size 100000 bytes:
In addition, with 100kb packet sizes, no only is the latency more 6 times higher without numpy, but the server starts to get behind and the client has to back off repeatedly during the test.
Note that numpy really only affects client->server data unmasking, so for uses like noVNC it will be basically irrelevant. However, websockify is not just for noVNC, so in the case where the client is sending a lot of data to server, numpy provides significant performance improvement.