[issue18329] for line in socket.makefile() speed degradation

Christian Heimes report at bugs.python.org
Thu Jul 4 12:37:05 CEST 2013


Christian Heimes added the comment:

I first suspected that file based IO involves too many syscalls and context switches. However ``strace -c`` showed only minor differences in the amount of syscalls. The difference between read() and recvfrom() should not make any difference.

perf revealed that the makefile() test uses much more CPU cycles. A quick check with python3.3 -m profile points to Python method call overhead. Five methods are called more than 122,000 times each and a couple of attributes are checked, too. Perhaps we can optimize away _checkReadable() and _checkClosed()?

I think I know what's going on here. For socket IO readline() uses a readahead buffer size of 1. For each char a cascade of Python functions is called. os.fdopen() uses a default buffering of 4096 (or more) so it's not affected.

----------
Added file: http://bugs.python.org/file30770/perf.txt

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18329>
_______________________________________


More information about the Python-bugs-list mailing list