Ask Your Question
1

How "expensive" is getNumSubscribers() of Publisher

asked 2014-11-20 10:55:25 -0600

Wolf gravatar image

I am processing data in a pipeline and I would like to publish out some intermediate results to check what is going on. However, some of these intermediate results are not necessary for the main processing chain but only for introspection. I. e. if everything runs smoothly and nobody watches them, there is no point for calculating them at all. So basically I want to calculate them, only if the respective publisher has a subscriber. However, my the data flows through my pipeline at some 20 to 40 Hz and I do not want to incorporate any heavy function calls at that freq. So the question is, whether or not it is ok to poll getNumSubscribers() at that frequency? Is the number cached somewhere in the node or does it query the master for each function call? Can I poll it? Or should I cache it my self and then only poll each 1 or 2 seconds?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-11-20 11:02:56 -0600

dornhege gravatar image

I assume that any call to getNumSubscribers is cheaper than performing actual computations. In particular it should not connect to the master as this should represent the number of actual subscribers connected to this node right now and not the number of nodes that are listed on the master as listening.

edit flag offensive delete link more

Comments

Exactly. It's just looking up the size of a vector.

Dirk Thomas gravatar imageDirk Thomas ( 2014-11-20 12:17:22 -0600 )edit

Perfect! Then polling should be ok.. Thanks!

Wolf gravatar imageWolf ( 2014-11-20 13:36:15 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-20 10:55:25 -0600

Seen: 778 times

Last updated: Nov 20 '14