多线程 WSARecvFrom 的性能

问题描述

我正在使用 WSARecvFrom 调用在 UDP 服务器中接收 UDP 数据包。观察结果是:当我使用多个线程时,WSARecvFrom性能正在下降。影响socket和WSARecvFrom性能的w.r.t线程有哪些因素?对于高吞吐量情况(每秒约 4000 个数据包),使用 WSASocket 实现 UDP 服务器的最佳做法是什么?

更新

Constructor(...)
{
    io = CreateThreadpoolIo(SocketHandle,IOCompletion,...);
    for(i -> 0 to number_of_parallel_receives)
        ReceivePacket(...);
}

static void CALLBACK IOCompletion(...)
{
    Processpacket(...);
    IncrementCounter();
    ReceivePacket(...); // get next packet
}

void ReceivePacket(...)
{
    StartThreadpoolIo(io);
    WSARecvFrom(...); // callback routine is nullptr and handled with the ThreadPoolIO callback
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)