Huge performance improvement #338
Replies: 3 comments 1 reply
-
@pliniofpa this is a great observation, and I am sure this optimization for data contained in a That said, D-Bus is a remote procedure call framework and I would advise against using D-Bus messages for high bandwidth data transfer. All messages must be proxied through a broker service and this introduces unnecessary overhead when sending a large amount of data from process A to process B. Instead, D-Bus provides the ability to open a dedicated channel for high-bandwidth data exchange. It does this by supporting a Unix file descriptor data type ( Also a note on the above test code. The |
Beta Was this translation helpful? Give feedback.
-
Thanks @pliniofpa for coming up with this and for the PR. I'm now looking into it. Thanks @dleeds-cpi for additional comments. |
Beta Was this translation helpful? Give feedback.
-
#340 has been merged. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am working on a replacement for a 30+ years old IPC tool and I am investigating if D-Bus meets the performance that we see with our current (old) solution.
I understand that D-Bus is not meant to carry a lot of data from everything I read online but at this moment my job is only to compare how fast our old system can move data vs how fast can D-Bus move the same amount of data.
I started my testing using a std::vector<uint8_t> with 20*1024 items. I then call a method that receives that vector in a loop for 10000 times. So I am moving a total of 200MB of data and I measure how long it takes (in wall clock and CPU clock).
For my surprise this code was taking over 15 seconds (wall clock) to execute while our current IPC solution takes only 6 seconds. Even more intriguing, CPU was being consumed for ~10 seconds (out of the 15 total wall clock seconds).
Investigating the source code I realized that, under the hood, sdbus-c++ is sending item by item of a vector using
sd_bus_message_append_basic()
instead of sending the whole data at once usingsd_bus_message_append_array()
.I modified the source code of sdbus-c++ to use
sd_bus_message_append_array()
andsd_bus_message_read_array()
when dealing with std::vector<> of typesint16_t
,int32_t
,int64_t
,uint8_t
,uint16_t
,uint32_t
,uint64_t
, anddouble
as the specification allow for those types to be sent as arrays.When retesting with my local mods the same code mentioned above took less than 3 seconds to execute with less than 0.5 second spent by CPU. This is a great improvement.
Please consider the Pull Request I am submitting with those changes.
Here is the whole code used for testing:
Beta Was this translation helpful? Give feedback.
All reactions