6 ms·
I changed memg.py to use sockfile.write()/.flush() instead of socket.sendall(). This makes the memg.py server > x100 faster. It outperforms a gevent-based impl
by codeape 15y ago
I changed memg.py to use sockfile.write()/.flush() instead of socket.sendall().
This makes the memg.py server > x100 faster. It outperforms a gevent-based implementation by 10%.
See https://github.com/codeape2/Key-Value-Polyglot/commit/cbc53af2ed32c3d54f265cf056d5680ce7ea3957 https://github.com/codeape2/Key-Value-Polyglot/commit/cbc53a...
EDIT: It does not outperform the gevent-based implementation. More performance testing indicates that gevent is around 2x faster. But it outperforms the original version by an order of magnitude.
- irahul 15y agosock.sendall() isn't the same as `sock.send(); sock.flush()` sendall will look something like: def sendall(sock, msg): totalsent = 0 MSGLEN = len(msg) while totalsent < MSGLEN: sent = sock.send(msg[totalsent:]) if sent == 0: raise RuntimeError("socket connection broken") totalsent = totalsent + sent
- codeape 15y agoI don't use socket.send/flush. I use sockfile.write/flush.