diff options
author | 2016-03-22 17:49:56 +0000 | |
---|---|---|
committer | 2016-03-22 17:49:56 +0000 | |
commit | ce379382552e118a499db95c0d311849557d0227 (patch) | |
tree | ff3be6cf171762a5b29563c22b23c7eabecc12e4 /tools/run_tests/post_tests_php.sh | |
parent | 04961a09220bdfb5665d8017af0a698af9f4c422 (diff) |
Make grpc-python ByteBuffer.bytes() linear cost.
Currently ByteBuffer.bytes() reads from the underlying grpc byte_buffer
a slice at a time, and appends each to a Python string (bytes). In
Python strings are immutable, so appending creates a new string by
copying the previous data. This means the current implementation is
quadratic.
The effect is very noticeable when messages have repeated (or large)
string fields. We traced execution between two services and observed
that when the payload size approached 600kb, the receiving service took
~10s at full CPU to read a response that had taken fractions of a second
the send over the network.
This commit changes ByteBuffer.bytes() to use an intermediate bytearray,
instead of strings, for the in-progress bytes. Once all slices are
read, the buffer is converted to a string.
Diffstat (limited to 'tools/run_tests/post_tests_php.sh')
0 files changed, 0 insertions, 0 deletions