You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am a beginner at aioquic. Recently, I'm trying to implement a file transfer protocol demo using aioquic. But I found when tring to download one ~80MB file in local network, it took ~70 sec to finish. I have no idea why it needs that much time. Here are details of my implementation.
In my demo, server reads the binary file content and send it over one stream by calling send_file_to_local(filepath):
In FTP, data connection opens when needed and closes when finishing one transfer task, so I set end_stream=True. To utilize QUIC feature, I use one stream as one data connection.
and what I found is I don't need to slice the data manually, aioquic finishes this.
Cilent will receive data in quic_event_received, and append the data if stream_id is the same. When end_stream is True, then client will write the content to the file:
def quic_event_received(self, event):
if isinstance(event, HandshakeCompleted):
asyncio.create_task(aioconsole.aprint("Handshake completed!"))
elif isinstance(event, StreamDataReceived):
stream_id = event.stream_id
data = event.data
if self.control_stream_id is None:
self.control_stream_id = stream_id
if stream_id == self.control_stream_id:
self.control_queue.put_nowait(data.decode())
else:
if stream_id not in self.stream_buffers:
self.stream_buffers[stream_id] = bytearray()
self.data_queues[stream_id] = asyncio.Queue()
self.stream_buffers[stream_id].extend(data)
if event.end_stream:
full_data = self.stream_buffers.pop(stream_id)
asyncio.create_task(self.data_queues[stream_id].put(full_data))
I tried to download one ~80 MB .exe file in localhost without adding loss rate or delay, but it took ~70 sec to finish, which was too long compared with TCP, ~2 sec only.
I thought I/O operations took too much time, so I didn't execute any I/O operations and only added self.times when the Stream DataReceived event triggered, like this:
def quic_event_received(self, event):
if isinstance(event, HandshakeCompleted):
asyncio.create_task(aioconsole.aprint("Handshake completed!"))
elif isinstance(event, StreamDataReceived):
stream_id = event.stream_id
data = event.data
if self.control_stream_id is None:
self.control_stream_id = stream_id
if stream_id == self.control_stream_id:
self.control_queue.put_nowait(data.decode())
else:
self.times += 1
if event.end_stream:
end = time.time()
print('time:', end - self.start, 'times:', self.times)
self.start will be set when starting receiving file content.
Amazingly, it still took ~70 sec, ~2 sec less compared with the first implementation, and self.times was 71553. I changed SMALLEST_MAX_DATAGRAM_SIZE from 1200 to 1500, and it took ~55 sec to finish, self.times was 56901.
I also used Wireshark to analysis with SMALLEST_MAX_DATAGRAM_SIZE=1500, it captured around 60000 frame (ack frame added the total frame).
I don't know why it took that much time when downloading a file even in local network. It seems the reason was 71553 StreamDataReceived events led to such a long time. I also tried to increase max_stream_data and max_data, but there's no use.
I think one data stream should utilize all its socket resources and work at least as effectively as using TCP. I have tried to find some solutions using Google or ChatGPT, but nothing promising was found. Could you please help me with this issue, thanks!
This discussion was converted from issue #519 on June 24, 2024 11:17.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I am a beginner at aioquic. Recently, I'm trying to implement a file transfer protocol demo using aioquic. But I found when tring to download one ~80MB file in local network, it took ~70 sec to finish. I have no idea why it needs that much time. Here are details of my implementation.
In my demo, server reads the binary file content and send it over one stream by calling
send_file_to_local(filepath)
:In FTP, data connection opens when needed and closes when finishing one transfer task, so I set
end_stream=True
. To utilize QUIC feature, I use one stream as one data connection.and what I found is I don't need to slice the data manually, aioquic finishes this.
Cilent will receive data in
quic_event_received
, and append the data ifstream_id
is the same. Whenend_stream
is True, then client will write the content to the file:I tried to download one ~80 MB .exe file in localhost without adding loss rate or delay, but it took ~70 sec to finish, which was too long compared with TCP, ~2 sec only.
I thought I/O operations took too much time, so I didn't execute any I/O operations and only added self.times when the Stream DataReceived event triggered, like this:
self.start
will be set when starting receiving file content.Amazingly, it still took ~70 sec, ~2 sec less compared with the first implementation, and
self.times
was 71553. I changedSMALLEST_MAX_DATAGRAM_SIZE
from 1200 to 1500, and it took ~55 sec to finish,self.times
was 56901.I also used Wireshark to analysis with
SMALLEST_MAX_DATAGRAM_SIZE=1500
, it captured around 60000 frame (ack frame added the total frame).I don't know why it took that much time when downloading a file even in local network. It seems the reason was 71553 StreamDataReceived events led to such a long time. I also tried to increase
max_stream_data
andmax_data
, but there's no use.I think one data stream should utilize all its socket resources and work at least as effectively as using TCP. I have tried to find some solutions using Google or ChatGPT, but nothing promising was found. Could you please help me with this issue, thanks!
Beta Was this translation helpful? Give feedback.
All reactions