Repository: aiortc/aiortc
Issue category: Performance Issue

Issue:
Slow sending messages with data channels
When I try to send 10 messages per second in datachannel I observe that messages are sent much slower, at 5 message per second.

I did a docker example to reproduce: https://gist.github.com/le-chat/844272e8d0f91dcbb61ba98ca635cd6b

From logs:
```
08:32:51.808407 sent №100, buffered 1750, queues: _sent 1, _outbound 0, _data_channel 50; _flight_size 35
08:33:01.895772 sent №200, buffered 3600, queues: _sent 1, _outbound 1, _data_channel 100; _flight_size 35
08:33:01.982040, 100 received: №99 at 2022-09-28 08:32:51.808277 (buffered 0)
08:33:11.973638 sent №300, buffered 5436, queues: _sent 1, _outbound 0, _data_channel 151; _flight_size 36
08:33:22.056580 sent №400, buffered 7200, queues: _sent 1, _outbound 1, _data_channel 200; _flight_size 36
08:33:22.160382, 200 received: №199 at 2022-09-28 08:33:01.895633 (buffered 0)
08:33:32.146720 sent №500, buffered 9036, queues: _sent 1, _outbound 0, _data_channel 251; _flight_size 36
08:33:42.228501 sent №600, buffered 10836, queues: _sent 1, _outbound 1, _data_channel 301; _flight_size 36
08:33:42.523312, 300 received: №299 at 2022-09-28 08:33:11.973609 (buffered 0)
08:33:52.314587 sent №700, buffered 12672, queues: _sent 1, _outbound 0, _data_channel 352; _flight_size 36
```
we can see messages are stuck on `_data_channel_queue`, though flight size is low and both `_outbound_queue` and `_sent_queue` are almost empty.

It looks like the second check in https://github.com/aiortc/aiortc/blob/1.3.2/src/aiortc/rtcsctptransport.py#L1651 erroneously breaks the loop in the very beginning and is redundant.


Hints:
We have the same issue:
We try to send data for every frame which fails at 30fps.
For us there is an additional issue: we want the latency to be as low as possible; so the current code has an issue where even after applying your fix it will only send out batches of messages 10 times per second

Patch:
diff --git a/src/aiortc/rtcsctptransport.py b/src/aiortc/rtcsctptransport.py
index de5d0968d..c9439fc2f 100644
--- a/src/aiortc/rtcsctptransport.py
+++ b/src/aiortc/rtcsctptransport.py
@@ -1324,8 +1324,7 @@ async def _send(
             self._outbound_stream_seq[stream_id] = uint16_add(stream_seq, 1)
 
         # transmit outbound data
-        if not self._t3_handle:
-            await self._transmit()
+        await self._transmit()
 
     async def _send_chunk(self, chunk: Chunk) -> None:
         """


Test patch: