Closed iamcalledrob closed 2 years ago
Relatedly, the same issue can be seen in the TestStressDuplex
test by increasing the MsgCount (mux_test.go, Line 39)
On my machine:
MsgSize: 2048, MsgCount: 200
never fails. This makes sense because 2048*200 < 1MB, (the fixed buffer size)MsgSize: 2048, MsgCount: 2000
has about a 10% chance of failure when the machine is under heavy load.Screen cap:
https://user-images.githubusercontent.com/87964/159099838-c3a1d146-68aa-46bc-bdea-6e6ee02f8656.mp4
Your environment.
What did you do?
I've been running into this when using dataChannels in a high-throughput scenario. As a simple repro, the problem is demonstrable using the built-in "data-channels-flow-control" example.
Easy repro steps:
cd examples/data-channels-flow-control; go run main.go
)yes > /dev/null &
x number of cores to keep them all busy)What did you expect?
What happened?
Throughput: 632.810 Mbps
.top
shows meaningful CPU usage (~250%) and the process with theSTATE
ofrunning
most of the time.mux ERROR: 2022/03/18 14:18:20 mux: ending readLoop dispatch error packetio.Buffer is full, discarding write
It seems like there may be a race condition regarding this buffer that's more easily triggered under load?
Notably, in internal/mux/mux.go, there's a comment when setting the packetio buffer suggesting that the buffer should never be able to be full. https://github.com/pion/webrtc/blob/655daa9689576421c194059dd4f3a05cae544a07/internal/mux/mux.go#L59-L62
Video of repro attached.
https://user-images.githubusercontent.com/87964/159092362-3dae173a-5c4e-4117-99ea-e993b2c47fd8.mp4