C/C++高频消息发送程序
最近我接触到了 POCO 和 ACE 网络框架,以及我已经了解的 Boost。
我的问题是,这些库传递消息的速度是否比使用 Berkeley 套接字的常规 C 程序更快?这些库只是因为添加了多线程等功能而流行,这有助于提高性能吗?
我想在 Linux 上编写一个高性能消息系统,但我不知道是否应该避免 ACE 、 POCO 和 Boost 而只使用 Linux 线程操作系统函数和 berkeley 套接字?
换句话说,我并不关心通用代码、使我的代码“STL 友好”等。我只想要原始性能(无需编写汇编!)。
Recently I have come across the POCO and ACE networking frameworks, along with Boost which I already knew about.
My question is, are these libraries any faster for passing messages than just a regular C program with Berkeley sockets? Are these libraries only popular because they add in the features of multi-threading etc, which helps the performance factor?
I want to write a high-performance messaging system on Linux, but I cant work out if I should avoid ACE , POCO and Boost and instead just using the Linux thread OS functions along with berkeley sockets?
In other words, I am not bothered about generic code, making my code "STL friendly" etc. I just want raw performance (without having to write assembly!).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您看过 0MQ(又名 ZeroMQ) 了吗?引用自他们的网站:
Have you looked at 0MQ (aka ZeroMQ) yet? Quoting from their website:
您问了很多问题,但没有分享太多有关您的用例的信息。从您所写的内容来看,您似乎需要在连接到网络的计算机之间进行消息传递。都是点对点的,还是有些机器是“服务器”,而其他机器是客户端?诸如 ACE 这样的库提供了一切,从用于包装任何类型的套接字通信和多线程的简单便利类,到完整的服务器,几乎使用您能想到的任何模型。
假设您需要某种服务器,那么关于是否应该使用线程或单线程异步存在着很大的争论。同样,根据用例,一个会比另一个“更好”(这实际上取决于您需要做什么)。
在网络部分,您是否需要可靠的有序消息,或者当您能够检测到数据包丢失时,每条消息是否已过时?为了可靠性,您通常会在 TCP 之上构建,但根据您需要执行的操作,您可以在 UDP 上设计一个运行速度更快的协议。
除非您的需求非常简单和基本,并且/或您之前编写过大量网络多线程代码,否则您最好使用编写良好的包,而不是尝试自己重新发明所有内容。
You are asking a lot without sharing much about your use case. From what you write, it seems you need to do messaging between machines connected to a network. Is it all peer to peer, or are some machines "servers", and others clients? Libraries such as ACE offer everything from simple convenience classes for wrapping any type of socket communication and multithreading, up to full blown servers, using virtually any model you can think of.
Assuming you need some kind of servers, there's the whole debate about whether you should go with threading, or single threaded async. Again, depending on the use case, one will be "better" than the other (it really depends on what you need to do).
On the network part, do you need reliable ordered messages, or is each message obsolete by the time you would be able to detect that a packet got lost? For reliability you would typically build on top of TCP, but depending on what you need to do, you could design a protocol on UDP which will run faster.
Unless you requirements are really simple and basic, and/or you've written lots of networked multithreaded code before, you are most likely better off to use a well written package than trying to reinvent everything on your own.
免责声明:我写的。
如果您正在寻找原始速度,尤其是信号的多个订阅者和简单的集成,我们尝试使用 DSTC(分布式 C)。
优点
缺点:
Disclaimer: I wrote it.
If you are looking for raw speed, especially with multiple subscribers for a signal, and simple integration, we tried to solve that problem with DSTC (Distributed C).
Upsides
Downsides: