Skip to content

Commit

Permalink
Improving the performance of the read_message by not splitting the da… (
Browse files Browse the repository at this point in the history
#90)

* Improving the performance of the read_message by not splitting the data into 1024 chunks and stitching them together as you go, instead receiving the entire message all at once.

* Updating the changelog
  • Loading branch information
P3TE authored Sep 2, 2021
1 parent 26f3285 commit 2620cfd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Add linter, unit tests, and test coverage reporting

### Changed

Improving the performance of the read_message in client.py, This is done by receiving the entire message all at once instead of reading 1024 byte chunks and stitching them together as you go.

### Deprecated

### Removed
Expand Down
11 changes: 1 addition & 10 deletions src/ros_tcp_endpoint/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,7 @@ def read_message(conn):
destination = ClientThread.read_string(conn)
full_message_size = ClientThread.read_int32(conn)

while len(data) < full_message_size:
# Only grabs max of 1024 bytes TODO: change to TCPServer's buffer_size
grab = 1024 if full_message_size - len(data) > 1024 else full_message_size - len(data)
packet = ClientThread.recvall(conn, grab)

if not packet:
rospy.logerr("No packets...")
break

data += packet
data = ClientThread.recvall(conn, full_message_size)

if full_message_size > 0 and not data:
rospy.logerr("No data for a message size of {}, breaking!".format(full_message_size))
Expand Down

0 comments on commit 2620cfd

Please sign in to comment.