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
Use thread pool to run benchmark publishers #1171
Conversation
cc: @james-rms |
rosbag2_performance/rosbag2_performance_benchmarking/src/benchmark_publishers.cpp
Outdated
Show resolved
Hide resolved
This PR adds a source of confusion - previously the number of threads was controlled by the producers configuration, now it's controlled by Why run so many publishers, rather than publishing more messages from each individual publisher? |
Thanks for the review.
We could expose this parameter to make it configurable. For the default value I see tow options:
The motivation for us is to be able to benchmark exactly a specific real setup. Publishing more messages from each individual publisher would be a different scenario in terms of resources, queues, concurrency, etc. |
@carlossvg Could you please reiterate on this PR and rebase it on top of latest rolling? |
880f453
to
e27187a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlossvg Thanks for the PR and rebasing. I like the idea with tread pool.
However I have a number of suggestions and findings for improvements.
Side note: It was a conflicts in CMake file, I've tried to resolve it but git somehow managed to add one commit from baseline Rolling
branch above your changes. Sorry for mess.
Feel free to rebase.
...e/rosbag2_performance_benchmarking/include/rosbag2_performance_benchmarking/config_utils.hpp
Outdated
Show resolved
Hide resolved
...ce/rosbag2_performance_benchmarking/include/rosbag2_performance_benchmarking/thread_pool.hpp
Outdated
Show resolved
Hide resolved
...ce/rosbag2_performance_benchmarking/include/rosbag2_performance_benchmarking/thread_pool.hpp
Outdated
Show resolved
Hide resolved
...ce/rosbag2_performance_benchmarking/include/rosbag2_performance_benchmarking/thread_pool.hpp
Outdated
Show resolved
Hide resolved
...ce/rosbag2_performance_benchmarking/include/rosbag2_performance_benchmarking/thread_pool.hpp
Outdated
Show resolved
Hide resolved
rosbag2_performance/rosbag2_performance_benchmarking/src/benchmark_publishers.cpp
Outdated
Show resolved
Hide resolved
rosbag2_performance/rosbag2_performance_benchmarking/src/benchmark_publishers.cpp
Outdated
Show resolved
Hide resolved
rosbag2_performance/rosbag2_performance_benchmarking/src/benchmark_publishers.cpp
Outdated
Show resolved
Hide resolved
rosbag2_performance/rosbag2_performance_benchmarking/src/benchmark_publishers.cpp
Outdated
Show resolved
Hide resolved
rosbag2_performance/rosbag2_performance_benchmarking/src/benchmark_publishers.cpp
Outdated
Show resolved
Hide resolved
d749fda
to
5be606b
Compare
@MichaelOrlov I think there are a couple of things left to do:
|
@carlossvg As regards to the
I have been thinking about it yesterday. Although come to the conclusion that it is not necessary and would be useless by design.
Update: |
...ce/rosbag2_performance_benchmarking/include/rosbag2_performance_benchmarking/thread_pool.hpp
Outdated
Show resolved
Hide resolved
5be606b
to
3247ac3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlossvg Semantically PR looks good for me.
Although I tried to test performance benchmarking with your branch and found a few issues.
Could you please fix them?
- Need remove
std::this_thread::sleep_for(1ms);
invoid WriterBenchmark::start_benchmark()
it basically usles and could affect reproduction rate for figh frequency topics. - Need change topic.type from
topic.type = "std_msgs::msgs::ByteMultiArray";
to the "rosbag2_performance_benchmarking_msgs/msg/ByteArray"; Thewriter_benchmark
crashes without this fix if start benchmarking withno_transport = True
. - It would be nice to add
number_of_threads: 16
or 50 to some of the producers config files to show users in what exact place it's expected to be.
If we do that the loop becomes a busy wait loop while waiting on new messages, right? As pointed out by this comment the proper fix would be to use a conditional variable to implement the wait.
I would implement that change in a separate MR.
Good catch, fixed
I order to make more explicit this parameter exists I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlossvg We can fix issue with delay in separate PR - I agree.
However delimiters in topic type is expected to be with slashes instead of the ::
rosbag2_performance/rosbag2_performance_benchmarking/src/writer_benchmark.cpp
Outdated
Show resolved
Hide resolved
c7ea72e
to
eb1fd35
Compare
@carlossvg Could you please rebase your branch? There are merge conflicts. |
eb1fd35
to
260e20e
Compare
@carlossvg It seems something went wrong with your rebase. |
@MichaelOrlov It looks like the PR was merged automatically when syncing the fork. I created a new PR here #1250 |
Related to: #688
Depends on #1153
This PR changes
benchmark_publishers
to use a thread pool instead of running each publisher in separate threads. The motivation for this change is to overcome a limitation on the number of threads imposed by Cyclone DDS (limited to 128 threads).