codypiersall / pynng

Python bindings for Nanomsg Next Generation.
https://pynng.readthedocs.io
MIT License
260 stars 58 forks source link

Question: Arecv much slower than sync recv #124

Open pumpthis opened 6 months ago

pumpthis commented 6 months ago

Testing on my server shows that comparing sync recv with async arecv, performance is very different.

msg = sub0.recv() The minimum time gap between two messages is 2us

when I change the code to msg = await sub0.arecv() The minimum time gap between two messages is 35us

I've tried both asyncio and trio. Is there any way to improve the async client performance? Too many sync clients cause significant context switches, but the message speed in async client seems slow.

carlodri commented 6 months ago

Shouldn't you be saying msg = await sub0.arecv()?

pumpthis commented 6 months ago

Shouldn't you be saying msg = await sub0.arecv()?

sorry it's a typo.

codypiersall commented 5 months ago

If you have a few test scripts I would be interested in trying them out.