Jens Geyer created THRIFT-6267:
----------------------------------
Summary: Python: TNonblockingServer rebuilds its whole read buffer
on every socket read
Key: THRIFT-6267
URL: https://issues.apache.org/jira/browse/THRIFT-6267
Project: Thrift
Issue Type: Improvement
Components: Python - Library
Reporter: Jens Geyer
{{lib/py/src/server/TNonblockingServer.py:145}}, in {{Connection.read()}}:
{code:python}
self._rbuf += read
{code}
{{bytes}} is immutable, so each append copies everything received so far.
Reading a message in n chunks costs O(n^2) bytes copied; for a message that
arrives in many small segments, most of the work is recopying.
The frame maximum added for this server bounds how far it can run, so this is a
cost question rather than a correctness one.
h2. Suggested
Accumulate into a {{list}} of chunks and {{b"".join()}} once the frame is
complete, or read into a {{bytearray}} and slice it.
_Drafted with AI assistance (Claude Opus 5); reviewed and filed by Jens Geyer._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)