Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve asynchonous publishing performance #374

Merged
merged 1 commit into from
Mar 14, 2014

Conversation

dirk-thomas
Copy link
Member

@esteve @tfoote @wjwwood Please review.

@wjwwood
Copy link
Member

wjwwood commented Mar 6, 2014

Reading briefly about using time.sleep(0) as a yield reveals that it may not work that way on OS X or Windows. What are you trying to accomplish with that? It seems like there should be a better way to do that.

@wjwwood
Copy link
Member

wjwwood commented Mar 6, 2014

Maybe not, that seems to be the recommended way to do it.

@wjwwood
Copy link
Member

wjwwood commented Mar 6, 2014

At least this recommends calling a delayfunc with 0:

http://docs.python.org/2/library/sched.html

And later mentions that delayfunc is usually time.sleep.

@dirk-thomas
Copy link
Member Author

Please try the above example script with e.g. three listening rostopics on OS X in order to figure out how it behaves on that system.

I was able to get to 1kHz without a problem - and I think that is a restriction of the above script. If you e.g. invoke publish five times per loop I could easily go beyond that frequency.

@wjwwood
Copy link
Member

wjwwood commented Mar 6, 2014

When disconnecting a rostopic hz I get this traceback:

Exception in thread Thread-14:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 808, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 761, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/william/hydro/install/lib/python2.7/site-packages/rospy/impl/tcpros_pubsub.py", line 422, in _run
    with self._cond:
  File "/Users/william/hydro/install/lib/python2.7/site-packages/rospy/impl/tcpros_pubsub.py", line 388, in __getattr__
    return getattr(self._connection, name)
AttributeError: 'TCPROSTransport' object has no attribute '_cond'

From what I can see, this should never have worked? Maybe it was always broken, but this change exposed it?

@wjwwood
Copy link
Member

wjwwood commented Mar 6, 2014

Other than the traceback from above, this patch does indeed resolve the issue described in #373.

@dirk-thomas
Copy link
Member Author

You are running old code: #369.

@jonbinney
Copy link

I tested this on my system, and it does fix #373 for me.

@jonbinney
Copy link

Assuming this patch gets merged, will it get backported to hydro-devel?

@dirk-thomas
Copy link
Member Author

Yes, it will definitely be backported due to its significant impact and the fact that nearly no code is actually using the queuing yet and therefore the chance of a regression a very slim.

dirk-thomas added a commit that referenced this pull request Mar 14, 2014
improve asynchonous publishing performance
@dirk-thomas dirk-thomas merged commit ef7a917 into indigo-devel Mar 14, 2014
@dirk-thomas dirk-thomas deleted the rospy_async_publish_performance branch March 14, 2014 22:53
@dirk-thomas
Copy link
Member Author

Cherry-picked to hydro-devel: f577021

@jonbinney
Copy link

Thanks @dirk-thomas !

rsinnet pushed a commit to MisoRobotics/ros_comm that referenced this pull request Jun 19, 2017
improve asynchonous publishing performance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants