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.
POSIX message queues are a means by which processes exchange data in the form of messages to accomplish their tasks. They enable processes to synchronise their reads and writes to speed up processes. POSIX message queues are distinct from System V messages.
The /dev/mqueue directory doesn't appear until you actually create a queue. The traditional POSIX message queue manager is a resource manager that uses messages to communicate with its clients. You can access it locally or remotely, allowing for network-wide message queues.
System calls used for message queues: ftok(): is use to generate a unique key. msgget(): either returns the message queue identifier for a newly created message queue or returns the identifiers for a queue which exists with the same key value.
On Linux, POSIX message queues are implemented as i-nodes in a virtual file system, and message queue descriptors and open message queue descriptions are implemented as file descriptors and open file descriptions, respectively.
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With