dbus2 / zbus-old

Rust D-Bus crate.
https://gitlab.freedesktop.org/dbus/zbus
Other
49 stars 13 forks source link

The performance of zbus is about 40% of dbus-rs #6

Closed tonysongtl closed 2 years ago

tonysongtl commented 2 years ago

Test method: One server application with one client program in same enviroment, running 10000 times method calls, zbus consumes more than twice as much time as dbus. Running four client programs at the same time, the results are still the same.

interface.xml is:

zeenix commented 2 years ago

One server application with one client program in same enviroment, running 10000 times method calls, zbus consumes more than twice as much time as dbus. Running four client programs at the same time, the results are still the same.

I assume you mean the dbus-rs project. Thanks for the report but we'll need more details than that (e.g how much time we're talking exactly, if you're using the tokio feature and disabling the default features or not, multithreaded runtime or not etc). Could you share the test code?

interface.xml is:

You forgot to paste the interface xml? This would be very useful info too cause zvariant might just need some optimizations to deserialize certain types.

tonysongtl commented 2 years ago

Thanks for your response. The signature of the method is very simple as busctl show: NAME TYPE SIGNATURE RESULT/VALUE FLAGS .TestMethod method i i - and the server side is just adding 1 to an integer per call.

The code is just like the example code of this project, expect that ‘async_std‘ is replaced by tokio.

zeenix commented 2 years ago

Thanks.

The code is just like the example code of this project, expect that ‘async_std‘ is replaced by tokio.

Is the performance any better with async_std?


I'm moving this to the main repo in gitlab for my own convenience but feel free to add comments here even if the issue is "closed".

zeenix commented 2 years ago

@tonysongtl Actually, could you kindly provide the equivalent dbus-rs code, since you already have it? I would hate to have to go through their docs and figure it out (that API being very hard to figure out was the main reason I decided to write zbus :laughing:).

zeenix commented 2 years ago

I tried the similar example from dbus-tokio (I removed the sleep and signals etc) and got the following results:

❯ time for i in {0..1000} ; do  busctl --user call org.zbus.MyGreeter /org/zbus/MyGreeter org.zbus.MyGreeter1 SayHello s "Maria" &> /dev/null; done

real    0m6.917s
user    0m2.210s
sys 0m3.367s

❯ time for i in {0..1000} ; do busctl --user call com.example.dbustest /hello com.example.dbustest Hello s "Maria" &> /dev/null; done

real    0m7.443s
user    0m2.671s
sys 0m4.310s

As you can see the results are quite similar.