Topic subscription scalability fix(#1078)#12
Conversation
1ee218b to
91541a4
Compare
| #else | ||
| #include <cstring> // strerror | ||
| #include <fcntl.h> // for non-blocking configuration | ||
| #include <sys/epoll.h> |
There was a problem hiding this comment.
This is going to cause trouble on POSIX platforms where epoll isn't a thing, especially OS X and BSD. I think you'll need to test for the header in CMake and then have an #ifdef that only optionally includes it.
You can do this easily with CMake's check_include_file macro, see: https://cmake.org/cmake/help/v3.5/module/CheckIncludeFile.html
There was a problem hiding this comment.
Does that also mean we need to support all three implementation? Windows / poll / epoll ?
If that's the case, I'd much rather have an implementation file per OS.
io_win.cpp / io_posix.cpp / io_epoll.cpp.
That way, implementation file can be neat and clean (could be all in one file as well though.)
There was a problem hiding this comment.
Summoning @dirk-thomas for an opinion on this.
There was a problem hiding this comment.
I am not opposed to any of the options. But I would think that maintaining the current pattern of keeping the implementations in the same file will likely be easier to review. If you decide to split the implementation please make sure to use separate commits for the following steps:
- copy existing file to new files without any changes
- remove redundant parts
- make the code work again from the new files
This will ensure that the git history is easy to follow.
| ROS_ERROR("Unable to add FD to epoll: %s", strerror(errno)); | ||
| } | ||
| #endif | ||
| } |
There was a problem hiding this comment.
I haven't fully digested all of what's going on here, but this if/else stuff going on everywhere feels like it's going to be a big pain to maintain. Should we be contemplating supplying multiple distinct implementations (epoll, poll, windows), and using a single branch somewhere to select which one is used?
There was a problem hiding this comment.
I followed the existing model doing my best not to disrupt too much. But I agree, a single branch is likely best.
| */ | ||
| int poll_sockets(socket_pollfd *fds, nfds_t nfds, int timeout) { | ||
| boost::shared_ptr<std::vector<socket_pollfd> > poll_sockets(int epfd, socket_pollfd *fds, nfds_t nfds, int timeout) { | ||
| #if defined(WIN32) |
There was a problem hiding this comment.
This return type is gross enough that I'd consider supplying a typedef for it.
| if (fd_cnt < 0) | ||
| { | ||
| ROS_ERROR("Error in epoll_wait! %s", strerror(errno)); | ||
| } |
There was a problem hiding this comment.
Do we know what conditions would cause this, and if there's something else we need to be doing about them?
There was a problem hiding this comment.
The answer is "no". don't know when this would happen. And the best I can do now is retry next time hoping the failure will go away.
I am suspecting that may be the computer going into sleep mode might cause the syscall to fail on return. But have not tested it thoroughly yet. There are some flags to control that part which I want to play with once the overall structure is solidified.
There was a problem hiding this comment.
Actually, the one case I know (taken care of in latest push), is that the syscall can be interrupted. In this case, we just return and try again later.
|
Some performance numbers using a played bag with 317 topics (bags plays in a loop) Legacy rosbag recorder (Linux version using This version of This version of I did not try the windows version so don't know the numbers there... |
91541a4 to
e3a33f9
Compare
|
Please try to avoid any unrelated white space changes. I know that it is tempting to "clean things up" on the go but it makes reviewing the patch more effort than necessary and make potential backports more problematic. |
|
I'll scrub again for unrelated white-space changes. Sorry about that. |
32d303d to
2856125
Compare
Switching to using epoll system calls to improve performance of the topic polling code by a factor of 2.
2856125 to
4ca9af0
Compare
|
This looks sane to me. Let's give it a try. |
|
Pushed to upstream's lunar-edge branch: https://github.com/ros/ros_comm/tree/lunar-edge |
Improve performance of topic socket polling.