Use buffered IO for packet processing #36
Labels
No labels
complexity
high
complexity
low
complexity
medium
importance
high
importance
low
importance
medium
type
bug
type
chore
type
feature suggestion
type
missing feature
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
thetxt/oxide#36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In Rust, reads on a
TcpStreamare unbuffered, i.e. they invoke a syscall for every read. This is incredibly inefficient. See the docs ofBufReaderinstd.The
read_packetfunction should ideally take aBufReaderto avoid the excessive system call overhead. This may be explicit through a parameter with type&mut BufReader<TcpStream>or implicit by taking animpl Read, and providing aBufReaderat all call sites. The latter allows for easier testing.(Note that
&mut RforR: std::io::ReadimplementsReadas well, so the function should not take a reference, just animpl Read)Good point! I remember looking into using a buffered Reader at some point, but don't remember why I didn't end up using one. If you want to, you can open a pr with your proposed changes or otherwise I will leave the issue open and look into it myself at some point in the future.
implemented for the server in 0.8.0