Skip to content

Commit

Permalink
Add LOT implementation and benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Costin Iordache committed Jul 16, 2021
1 parent 62ad030 commit 0224eb6
Show file tree
Hide file tree
Showing 55 changed files with 193 additions and 189 deletions.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# FiveSHM
# LOT - Low Overhead Transport

## General description

Expand All @@ -10,7 +10,7 @@ The code can be built either directly on the host machine _or_ within a Docker c

The benchmarks - either the entire suite or individual tests - can be executed following the procedure described below. Currently, four protocols are supported: TCP, UDP, SHM and TZC.

When executed from within the Docker containers, the benchmarks results are generated under `${HOME}/fiveshm` folder. Otherwise, environment variable `FIVESHM_HOME` dictates the results folder.
When executed from within the Docker containers, the benchmarks results are generated under `${HOME}/lot` folder. Otherwise, environment variable `lot_HOME` dictates the results folder.

### Notes on provided code

Expand All @@ -22,9 +22,9 @@ We apply the following bug fixes on top of ROS 1.12.14 in addition to our own co

### Third party code

[Boost.Process 1_65_0](https://www.boost.org/doc/libs/1_65_0/doc/html/process.html) has been imported into the source tree to support [unit tests](./test/test_roscpp/test/test_shm.cpp). We note that Boost is released under the [Boost Software License](http://www.boost.org/LICENSE_1_0.txt).
[Boost.Process 1_65_0](https://www.boost.org/doc/libs/1_65_0/doc/html/process.html) has been imported into the source tree to support [unit tests](./test/test_roscpp/test/test_shm.cpp). We note that [Boost 1.65.0](https://github.com/boostorg/boost/tree/boost-1.65.0) is released under the [Boost Software License](http://www.boost.org/LICENSE_1_0.txt).

For convenience of running the benchmarks, we have also included TZC in this repository. TZC was developed by a group researchers afilliated to Tsinghua University, China and University of Maryland, USA and is described more fully in the _TZC: Efficient Inter-Process Communication for Robotics Middleware with Partial Serialization_. Its authors have released it under the [BSD](https://github.com/qboticslabs/tzc_transport/blob/master/package.xml) license.
For convenience of running the benchmarks, we have also included [TZC](https://github.com/qboticslabs/tzc_transport) in this repository. TZC was developed by a group researchers afilliated to Tsinghua University, China and University of Maryland, USA and is described more fully in the _TZC: Efficient Inter-Process Communication for Robotics Middleware with Partial Serialization_. Its authors have released it under the [BSD](https://github.com/qboticslabs/tzc_transport/blob/master/package.xml) license.

## Cloning the repository and switching to the target branch

Expand All @@ -33,7 +33,7 @@ Note that we clone the repository into `$HOME/ros_comm/src/ros_comm` in this ste
```
git clone [email protected]:fiveai/ros_comm.git $HOME/ros_comm/src/ros_comm
cd $HOME/ros_comm/src/ros_comm
git checkout fiveshm
git checkout lot
```

## Building and running the benchmarks natively
Expand Down Expand Up @@ -71,12 +71,12 @@ roslaunch --screen -v benchmark launch.xml \
```
cd ~/ros_comm/src/ros_comm/clients/benchmark/docker
export DOCKER_BUILDKIT=1
docker build --ssh default --tag fiveshm .
docker build --ssh default --tag lot .
```

### Executing the benchmark suite, deploying the ROS nodes in separate docker images

Assuming the Docker container built as above, with a tag of `fiveshm`:
Assuming the Docker container built as above, with a tag of `lot`:

```
cd ~/ros_comm/src/ros_comm/clients/benchmark/docker
Expand All @@ -97,6 +97,7 @@ The next sections provides examples of such commands.
### Benchmark execution command examples

1. Execute the benchmarks suite for 1p5s using TZC protocol, in separate Docker containers, enforcing the subscribers start up order, allocating 16GB of shared memory to be used by the publishers, and telling the subscriber to wait 15 seconds before starting publishing messages, `TCP_NODELAY` enabled.

```
python2 /ros_comm/src/ros_comm/clients/benchmark/execute.py \
--tcp=no --shm=no --tzc=yes --udp=no \
Expand All @@ -106,17 +107,18 @@ python2 /ros_comm/src/ros_comm/clients/benchmark/execute.py \
shm_size_mega_bytes:=16000
```


2. Execute the benchmarks suite for 5p1s using TZC protocol, in separate Docker containers, with each publisher waiting for the subscriber to establish connection and with the subscriber start up delayed by 15secs, `TCP_NODELAY` enabled.

```
python2 /ros_comm/src/ros_comm/clients/benchmark/execute.py \
--tcp=no --shm=no --tzc=yes --udp=no \
--use_case=5p1s_separate_docker --no_pool=yes --pool=no \
--extra_params pub_wait_for_subscribers:=true \
sub_extra_delay_ms:=15000
sub_extra_delay_ms:=15000
```

3. Execute the benchmarks suite for 5p1s using TZC protocol, in separate Docker containers, with each publisher waiting for the subscriber to establish connection and with the publishers start up order enforced, `TCP_NODELAY` enabled, overriding the default results path..
3. Execute the benchmarks suite for 5p1s using TZC protocol, in separate Docker containers, with each publisher waiting for the subscriber to establish connection and with the publishers start up order enforced, `TCP_NODELAY` enabled, overriding the default results path.

```
python2 /ros_comm/src/ros_comm/clients/benchmark/execute.py \
--tcp=no --shm=no --tzc=yes --udp=no \
Expand All @@ -126,17 +128,18 @@ python2 /ros_comm/src/ros_comm/clients/benchmark/execute.py \
sub_stats_file_path:=/path/to/results
```


3. Execute the benchmarks suite for 5p1s using SHM protocol, in separate Docker containers, with each publisher waiting for the subscriber to establish connection and with the publishers start up order enforced, and image pools disabled.

```
python2 /ros_comm/src/ros_comm/clients/benchmark/execute.py \
--tcp=no --shm=yes --tzc=no --udp=no \
--use_case=5p1s_separate_docker --no_pool=yes --pool=no \
--extra_params pub_wait_for_subscribers:=true \
pub_enable_synch_startup:=true
pub_enable_synch_startup:=true
```

4. Execute _one single test_ using TCP protocol, in same docker container, with image pool disabled.

```
roslaunch --screen -v benchmark launch.xml \
pub_image_count:=200 \
Expand Down
4 changes: 2 additions & 2 deletions clients/benchmark/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ RUN echo "export VISIBLE=now" >> /etc/profile
RUN echo "/usr/sbin/sshd" >> ~/.bashrc
RUN echo "export ROSLAUNCH_SSH_UNKNOWN=1" >> ~/.bashrc
RUN echo "source /ros_comm/devel-release/setup.sh" >> ~/.bashrc
RUN echo "mkdir -p \${FIVESHM_HOME}" >> ~/.bashrc
RUN echo "mkdir -p \${LOT_HOME}" >> ~/.bashrc
# This line is need to workaround a roslaunch bug where multiple instances of roscore are launched
RUN echo "export ROS_MASTER_URI=http://\$(uname -n):11311" >> ~/.bashrc
RUN echo "nano /ros_comm/src/ros_comm/clients/benchmark/launch/launch.xml" >> ~/.bash_history
Expand All @@ -54,7 +54,7 @@ RUN echo "python2 /ros_comm/src/ros_comm/clients/benchmark/execute.py --use_case
RUN --mount=type=ssh git clone [email protected]:fiveai/ros_comm.git /ros_comm/src/ros_comm && \
cd /ros_comm/src/ros_comm && \
git pull && \
git checkout fiveshm && \
git checkout lot && \
cd /ros_comm

RUN /bin/bash -c "source /opt/ros/kinetic/setup.sh && \
Expand Down
4 changes: 2 additions & 2 deletions clients/benchmark/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
version: "3.7"

x-base_node: &base_node
image: fiveshm
image: lot
ipc: host
volumes:
- "${HOME}:${HOME}"
stdin_open: true # docker run -i
tty: true # docker run -t
environment:
- FIVESHM_HOME=${HOME}/fiveshm
- LOT_HOME=${HOME}/lot

services:
# define the nodes as copies of the base node
Expand Down
2 changes: 1 addition & 1 deletion clients/benchmark/launch/launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<arg name="sub_queue_size" default="100" />
<arg name="sub_output_stats" default="false" />
<arg name="sub_tcp_no_delay" default="true" />
<arg name="sub_stats_file_path" default="$(env FIVESHM_HOME)" />
<arg name="sub_stats_file_path" default="$(env LOT_HOME)" />
<arg name="sub_stats_file_name"
default="$(arg transport)_$(arg use_case)_$(arg image_width_pixels)x$(arg image_height_pixels)_pool$(arg pub_pool_size)_Hz$(arg pub_hz)_count$(arg pub_image_count).txt"
/>
Expand Down
6 changes: 3 additions & 3 deletions clients/benchmark/src/Publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
* the subscriber(s) are required.
*/

using SharedPtrConstShmImage = fiveai::shm_msgs::SharedPtrConstShmImage;
using SharedPtrShmImage = fiveai::shm_msgs::SharedPtrShmImage;
using SharedPtrConstShmImage = ros::shm_msgs::SharedPtrConstShmImage;
using SharedPtrShmImage = ros::shm_msgs::SharedPtrShmImage;
using SharedPtrImage = sensor_msgs::ImagePtr;
using SharedPtrConstImage = sensor_msgs::ImageConstPtr;

using SizePixels = fiveai::util::SizePixels;
using SizePixels = ros::util::SizePixels;

struct Params
{
Expand Down
4 changes: 2 additions & 2 deletions clients/benchmark/src/Subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
* the publisher(s) are required.
*/

using SharedPtrConstShmImage = fiveai::shm_msgs::SharedPtrConstShmImage;
using SharedPtrConstShmImage = ros::shm_msgs::SharedPtrConstShmImage;
using SharedPtrConstImage = sensor_msgs::ImageConstPtr;
using SizePixels = fiveai::util::SizePixels;
using SizePixels = ros::util::SizePixels;

struct Data
{
Expand Down
42 changes: 21 additions & 21 deletions clients/roscpp/include/msgs/ShmHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <boost/interprocess/managed_shared_memory.hpp>

namespace fiveai { namespace shm_msgs
namespace ros { namespace shm_msgs
{
template <class Sa>
struct Header_
Expand All @@ -26,7 +26,7 @@ namespace fiveai { namespace shm_msgs
using SegmentManager = boost::interprocess::managed_shared_memory::segment_manager;
using Sequence = uint32_t;
using Timestamp = ros::Time;
using String = fiveai::shm::_String<typename StringAllocator::value_type, StringAllocator>;
using String = ros::shm::_String<typename StringAllocator::value_type, StringAllocator>;

explicit Header_(SegmentManager& segmentManager) :
seq{0},
Expand All @@ -51,9 +51,9 @@ namespace fiveai { namespace shm_msgs
String frame_id;
};

using Header = shm_msgs::Header_<fiveai::shm::StringAllocator>;
using HeaderShmPtr = fiveai::shm::SharedPtr<shm_msgs::Header>;
using HeaderConstShmPtr = fiveai::shm::SharedPtr<const shm_msgs::Header>;
using Header = shm_msgs::Header_<ros::shm::StringAllocator>;
using HeaderShmPtr = ros::shm::SharedPtr<shm_msgs::Header>;
using HeaderConstShmPtr = ros::shm::SharedPtr<const shm_msgs::Header>;

template<typename A>
std::ostream& operator<<(std::ostream& s, const shm_msgs::Header_<A>& v)
Expand All @@ -69,69 +69,69 @@ namespace message_traits
{

template <class ContainerAllocator>
struct IsFixedSize< ::fiveai::shm_msgs::Header_<ContainerAllocator> >
struct IsFixedSize< shm_msgs::Header_<ContainerAllocator> >
: FalseType
{ };

template <class ContainerAllocator>
struct IsFixedSize< ::fiveai::shm_msgs::Header_<ContainerAllocator> const>
struct IsFixedSize< shm_msgs::Header_<ContainerAllocator> const>
: FalseType
{ };

template <class ContainerAllocator>
struct IsMessage< ::fiveai::shm_msgs::Header_<ContainerAllocator> >
struct IsMessage< shm_msgs::Header_<ContainerAllocator> >
: TrueType
{ };

template <class ContainerAllocator>
struct IsMessage< ::fiveai::shm_msgs::Header_<ContainerAllocator> const>
struct IsMessage< shm_msgs::Header_<ContainerAllocator> const>
: TrueType
{ };

template <class ContainerAllocator>
struct HasHeader< ::fiveai::shm_msgs::Header_<ContainerAllocator> >
struct HasHeader< shm_msgs::Header_<ContainerAllocator> >
: FalseType
{ };

template <class ContainerAllocator>
struct HasHeader< ::fiveai::shm_msgs::Header_<ContainerAllocator> const>
struct HasHeader< shm_msgs::Header_<ContainerAllocator> const>
: FalseType
{ };


template<class ContainerAllocator>
struct MD5Sum< ::fiveai::shm_msgs::Header_<ContainerAllocator> >
struct MD5Sum< shm_msgs::Header_<ContainerAllocator> >
{
static const char* value()
{
return "55bf682044a302f2fdf00c1fcd1a70a9";
}

static const char* value(const ::fiveai::shm_msgs::Header_<ContainerAllocator>&) { return value(); }
static const char* value(const shm_msgs::Header_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0x2176decaecbce78aULL;
static const uint64_t static_value2 = 0xbc3b96ef049fabedULL;
};

template<class ContainerAllocator>
struct DataType< ::fiveai::shm_msgs::Header_<ContainerAllocator> >
struct DataType< shm_msgs::Header_<ContainerAllocator> >
{
static const char* value()
{
return "std_msgs/ShmHeader";
}

static const char* value(const ::fiveai::shm_msgs::Header_<ContainerAllocator>&) { return value(); }
static const char* value(const shm_msgs::Header_<ContainerAllocator>&) { return value(); }
};

template<class ContainerAllocator>
struct Definition< ::fiveai::shm_msgs::Header_<ContainerAllocator> >
struct Definition< shm_msgs::Header_<ContainerAllocator> >
{
static const char* value()
{
return "Same as std_msgs/Header with addition that it can be placed in shm";
}

static const char* value(const ::fiveai::shm_msgs::Header_<ContainerAllocator>&) { return value(); }
static const char* value(const shm_msgs::Header_<ContainerAllocator>&) { return value(); }
};

} // namespace message_traits
Expand All @@ -142,7 +142,7 @@ namespace ros
namespace serialization
{

template<class ContainerAllocator> struct Serializer< ::fiveai::shm_msgs::Header_<ContainerAllocator> >
template<class ContainerAllocator> struct Serializer< shm_msgs::Header_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
Expand All @@ -163,16 +163,16 @@ namespace message_operations
{

template<class ContainerAllocator>
struct Printer< ::fiveai::shm_msgs::Header_<ContainerAllocator> >
struct Printer< shm_msgs::Header_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::fiveai::shm_msgs::Header_<ContainerAllocator>& v)
template<typename Stream> static void stream(Stream& s, const std::string& indent, const shm_msgs::Header_<ContainerAllocator>& v)
{
s << indent << "seq: ";
Printer<uint32_t>::stream(s, indent + " ", v.seq);
s << indent << "stamp: ";
Printer<ros::Time>::stream(s, indent + " ", v.stamp);
s << indent << "frame_id: ";
Printer<typename ::fiveai::shm_msgs::Header_<ContainerAllocator>::String>::stream(s, indent + " ", v.frame_id);
Printer<typename shm_msgs::Header_<ContainerAllocator>::String>::stream(s, indent + " ", v.frame_id);
}
};

Expand Down
Loading

0 comments on commit 0224eb6

Please sign in to comment.