Skip to content

Improve performance and use less locks #2

Description

@Frando

Currently all reads and writes on all channels share a Mutex onto a UdxSocket. This leads to high congestion and sub-par performance, especially with many channels (UdxStreams).

The solution is to use a lock-free design. Options are:

  • Channels (e.g. from async-channel) - this means, at least for writing, that we'd have to allocate additional buffers. For reading it might work to send Packets over the channel without allocating, and send back a read cursor which ticks garbage collection for read packets.
  • An async pipe like tokio::io::DuplexStream or sluice::pipe::Pipe. I have tried an implementation based on these, but have not succeeded because the types are not Clone, and wrapping them into a Mutex is not easy either, because the impl of AsyncBufRead (which we want if we don't want to allocate on each write) contains a reference to the pipe, which prohibits mutable access to self while holding onto the read buffer.

Either of those can work out likely with some more thought about alias and lifetime rules.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions