zenoh icon indicating copy to clipboard operation
zenoh copied to clipboard

Unclear what the difference between Publisher and Put is

Open hassomehide opened this issue 1 year ago • 4 comments

Describe the bug

I am reporting this because it doesn’t seem to be documented anywhere. Are there any performance benefits or any optimizations involved when I declare a Publisher and send data through that instead of just using Put without declaring anything?

To reproduce

N/A

System info

Zenoh 1.0.0-beta.1

hassomehide avatar Sep 07 '24 18:09 hassomehide

Hi @hassomehide,

Publisher does indeed an optimizations, so it can be used when publishing the same key expression multiple times, while the put is more to one-shot or sporadic publications on a certain key-expression.

gabrik avatar Sep 09 '24 07:09 gabrik

@gabrik thanks for the response. Are these optimizations related to just reusing the key expression or is there more? To put it in another way, is there any difference between sending data through a Publisher vs declaring a reusable KeyExpr and using the Put operation without any Publisher?

hassomehide avatar Sep 11 '24 06:09 hassomehide

The number of optimizations depends on the configuration of the publisher, it can include the declaration of liveliness tokens, configuration of congestion control, etc.

Some of those can also be configured for a put.

gabrik avatar Sep 12 '24 06:09 gabrik

The number and extension of optimizations are implementation dependent and may vary at any point in time.

The rule to retain and follow is:

  • Use session.put for one-off publication on a specific key expression
  • Use session.declare_publisher for any periodic/long-lived publication

Mallets avatar Sep 12 '24 08:09 Mallets

@hassomehide if you don't have any additional comment I suggest to close this issue as complete.

Mallets avatar Nov 28 '24 14:11 Mallets