GLib 的 GAsyncQueue 与 POSIX message_queue
有谁知道 GLib 的 GAsyncQueue 与 POSIX message_queue 在线程间通信方面的相对性能吗?我将有许多小消息(单向和请求响应类型),将在 Linux 之上用 C 实现(目前;可能稍后移植到 Windows)。我正在尝试决定使用哪一个。
我发现使用 GLib 更适合可移植性,但 POSIX mq 的优点是能够选择或轮询它们。
不过,我还没有找到任何关于谁的表现更好的信息。
Does anyone have any idea of the relative performance of GLib's GAsyncQueue vs. POSIX message_queue for inter-thread communication? I will have many small messages (both one way and request-response types), to be implemented in C on top of Linux (for now; may be ported to Windows later). I am trying to decide which one to use.
What I have found out is that using GLib is better for portability purposes, but POSIX mq's have the advantage of being able to select or poll on them.
However, I have not found any information on whose performance is better.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于我的问题没有得到答复,我决定自己运行一些性能测试。主要思想取自http://cybertiggyr.com/throughput/throughput.html。测试思路是:
我测试了 4、64、256、512 和 1024 字节的块大小。
我使用 GAsyncQueue(使用 gthreads)、POSIX 消息队列和 UNIX 域套接字(使用 pthreads)进行了测试。
这是获得的结果:
总而言之, perf(GAsyncQueue) >性能(mq)> perf(UNIX 套接字),尽管 GAsyncQueue 和 POSIX 消息队列的性能在大多数情况下具有可比性 - 差异仅在消息大小较小时发生。
我想知道 GAsyncQueue 是如何实现的,以提供比 Linux 本地消息队列实现更好的性能。遗憾的是它不能像其他两个那样用于进程间通信。
Since there were no responses to my question, I decided to run some performance tests myself. The main idea was taken from http://cybertiggyr.com/throughput/throughput.html. The test idea was:
I tested with chunk sizes of 4, 64, 256, 512 and 1024 bytes.
I tested with GAsyncQueue (with gthreads), POSIX message queue and UNIX domain sockets (with pthreads).
Here is the result obtained:
To summarize, perf(GAsyncQueue) > perf(mq) > perf(UNIX socket), though the performances of GAsyncQueue and POSIX message queue are comparable in most cases - the difference occurs only with small message sizes.
I was wondering how GAsyncQueue is implemented to give comparable of even better performance than Linux's native message queue implementation. It is a pity that it cannot be used for inter process communication, like the other two can.