Hi Thrift developers,

I'd appreciate a review of this small Python transport performance improvement:

https://github.com/apache/thrift/pull/4028

JIRA: https://issues.apache.org/jira/browse/THRIFT-6436

TTransportBase.readAll() currently accumulates data using repeated bytes 
concatenation. For large responses received in
many chunks, this repeatedly copies the data already received and adds CPU 
overhead. In GIL-enabled CPython, the extra
copying may also delay other Python threads, although multithreaded effects 
were not measured.

The patch collects the chunks in a list and joins them once at the end. It 
includes regression tests for fragmented
reads, requested read sizes, EOF handling, and exception propagation.

In a local benchmark using a Thrift server in a separate process over loopback 
TCP, with 30 MiB responses and a Python
framed-transport client, median throughput increased from approximately 393 
MiB/s to 589 MiB/s, while client CPU time
per response decreased from 39.6 ms to 14.9 ms. These results are specific to 
the benchmark environment; the setup and
additional measurements are documented in the PR.

The change is limited to the implementation and transport tests. Feedback on 
compatibility and test coverage would be
especially welcome.

Thanks for your time!

Best regards,
Xinyu Tan

Reply via email to