Skip to content

Commit

Permalink
Don't explicitly pass a default (small) receive size, let trio choose.
Browse files Browse the repository at this point in the history
The default size of 4 KiB is very small, and caused a lot of loops receiving buffers, that were clearly visible in benchmarks.

Also, it's not needed: ` Optional; if omitted, then the stream object is free to pick a reasonable default.`

By passing None, it currently means we end up in 64 KiB instead:
https://github.com/python-trio/trio/blob/master/src/trio/_highlevel_socket.py#L21-L25
And it can be hoped that later this will automagically become more intelligent if they implement the TODO.
  • Loading branch information
palkeo authored Nov 15, 2023
1 parent 52ce346 commit 1e06e0f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions trio_websocket/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
CONN_TIMEOUT = 60 # default connect & disconnect timeout, in seconds
MESSAGE_QUEUE_SIZE = 1
MAX_MESSAGE_SIZE = 2 ** 20 # 1 MiB
RECEIVE_BYTES = 4 * 2 ** 10 # 4 KiB
logger = logging.getLogger('trio-websocket')


Expand Down Expand Up @@ -1232,7 +1231,7 @@ async def _reader_task(self):

# Get network data.
try:
data = await self._stream.receive_some(RECEIVE_BYTES)
data = await self._stream.receive_some()
except (trio.BrokenResourceError, trio.ClosedResourceError):
await self._abort_web_socket()
break
Expand Down

0 comments on commit 1e06e0f

Please sign in to comment.