-
Notifications
You must be signed in to change notification settings - Fork 211
Feature/rec faster callbacks #2573
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| This license file applies to everything in this repository except that which | ||
| is explicitly annotated as being written by other authors, i.e. the Boost | ||
| queue (included in the benchmarks for comparison), Intel's TBB library (ditto), | ||
| dlib::pipe (ditto), | ||
| the CDSChecker tool (used for verification), the Relacy model checker (ditto), | ||
| and Jeff Preshing's semaphore implementation (used in the blocking queue) which | ||
| has a zlib license (embedded in lightweightsempahore.h). | ||
|
|
||
| --- | ||
|
|
||
| Simplified BSD License: | ||
|
|
||
| Copyright (c) 2013-2016, Cameron Desrochers. | ||
| All rights reserved. | ||
|
|
||
| Redistribution and use in source and binary forms, with or without modification, | ||
| are permitted provided that the following conditions are met: | ||
|
|
||
| - Redistributions of source code must retain the above copyright notice, this list of | ||
| conditions and the following disclaimer. | ||
| - Redistributions in binary form must reproduce the above copyright notice, this list of | ||
| conditions and the following disclaimer in the documentation and/or other materials | ||
| provided with the distribution. | ||
|
|
||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
| EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | ||
| THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
| OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
| TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
| EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| --- | ||
|
|
||
| I have also chosen to dual-license under the Boost Software License as an alternative to | ||
| the Simplified BSD license above: | ||
|
|
||
| Boost Software License - Version 1.0 - August 17th, 2003 | ||
|
|
||
| Permission is hereby granted, free of charge, to any person or organization | ||
| obtaining a copy of the software and accompanying documentation covered by | ||
| this license (the "Software") to use, reproduce, display, distribute, | ||
| execute, and transmit the Software, and to prepare derivative works of the | ||
| Software, and to permit third-parties to whom the Software is furnished to | ||
| do so, all subject to the following: | ||
|
|
||
| The copyright notices in the Software and this entire statement, including | ||
| the above license grant, this restriction and the following disclaimer, | ||
| must be included in all copies of the Software, in whole or in part, and | ||
| all derivative works of the Software, unless such copies or derivative | ||
| works are solely in the form of machine-executable object code generated by | ||
| a source language processor. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | ||
| SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | ||
| FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | ||
| ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| DEALINGS IN THE SOFTWARE. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -39,6 +39,7 @@ | |||||
| #include "rec_client_core/topic_info.h" | ||||||
| #include "rec_client_core/upload_config.h" | ||||||
|
|
||||||
| #include <array> | ||||||
| #include <chrono> | ||||||
| #include <cstdint> | ||||||
| #include <algorithm> | ||||||
|
|
@@ -66,6 +67,61 @@ namespace eCAL | |||||
| { | ||||||
| namespace rec | ||||||
| { | ||||||
| class EcalRecImpl::ReceiveDispatchThread : public InterruptibleLoopThread | ||||||
| { | ||||||
| public: | ||||||
| ReceiveDispatchThread(EcalRecImpl& ecal_rec_impl_) | ||||||
| : InterruptibleLoopThread(std::chrono::milliseconds(10)) | ||||||
| , ecal_rec_impl(ecal_rec_impl_) | ||||||
| , token(ecal_rec_impl_.receive_dispatch_queue_) | ||||||
| { | ||||||
| } | ||||||
|
|
||||||
| ~ReceiveDispatchThread() | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: annotate this function with 'override' or (rarely) 'final' [cppcoreguidelines-explicit-virtual-functions]
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: use '= default' to define a trivial destructor [modernize-use-equals-default] app/rec/rec_client_core/src/ecal_rec_impl.cpp:80: - {
- }
+ = default; |
||||||
| { | ||||||
| } | ||||||
| protected: | ||||||
| // forward data from the queue to the actual buffer | ||||||
| void Loop() override | ||||||
| { | ||||||
| std::array<std::shared_ptr<Frame>, 16> frames; | ||||||
| size_t no_items = 0; | ||||||
| do | ||||||
| { | ||||||
| no_items = ecal_rec_impl.receive_dispatch_queue_.try_dequeue_bulk(token, frames.data(), frames.size()); | ||||||
| for (size_t i = 0; i < no_items; ++i) | ||||||
| { | ||||||
| auto& frame = frames[i]; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: do not use array subscript when the index is not an integer constant expression [cppcoreguidelines-pro-bounds-constant-array-index] auto& frame = frames[i];
^ |
||||||
| // Add to the pre-buffer (it is thread-safe by using a mutex internally) | ||||||
| for (size_t i = 0; i < no_items; ++i) | ||||||
| { | ||||||
| ecal_rec_impl.pre_buffer_.push_back(frames[i]); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: do not use array subscript when the index is not an integer constant expression [cppcoreguidelines-pro-bounds-constant-array-index] ecal_rec_impl.pre_buffer_.push_back(frames[i]);
^ |
||||||
| } | ||||||
|
|
||||||
| { | ||||||
| // Add to the currently recording job (if there is any) | ||||||
| std::shared_lock<decltype(ecal_rec_impl.recorder_mutex_)> recorder_lock(ecal_rec_impl.recorder_mutex_); | ||||||
|
KerstinKeller marked this conversation as resolved.
Outdated
|
||||||
| if (ecal_rec_impl.recording_recorder_job_ != nullptr) | ||||||
| { | ||||||
| ecal_rec_impl.recording_recorder_job_->AddFrame(std::move(frame)); | ||||||
|
KerstinKeller marked this conversation as resolved.
Outdated
|
||||||
| } | ||||||
| } | ||||||
|
|
||||||
| { | ||||||
| // Add to the subscriber statistics | ||||||
| const std::lock_guard<decltype(ecal_rec_impl.subscriber_throughput_mutex_)> subscriber_statistics_lock(ecal_rec_impl.subscriber_throughput_mutex_); | ||||||
| ecal_rec_impl.subscriber_throughput_statistics_.AddFrame(frame->data_.size()); | ||||||
|
KerstinKeller marked this conversation as resolved.
|
||||||
| } | ||||||
| } | ||||||
| } while (no_items > 0); | ||||||
| } | ||||||
|
|
||||||
| private: | ||||||
| EcalRecImpl& ecal_rec_impl; | ||||||
| moodycamel::ConsumerToken token; | ||||||
| }; | ||||||
|
|
||||||
|
|
||||||
| EcalRecImpl::EcalRecImpl() | ||||||
| : addon_manager_(std::make_unique<AddonManager>([this](int64_t job_id, const std::string& addon_id, const RecAddonJobStatus& job_status) | ||||||
| { | ||||||
|
|
@@ -90,19 +146,23 @@ namespace eCAL | |||||
|
|
||||||
| monitoring_thread_ = std::make_unique<MonitoringThread>(*this); | ||||||
| monitoring_thread_->Start(); | ||||||
|
|
||||||
| receive_dispatch_thread = std::make_unique<ReceiveDispatchThread>(*this); | ||||||
| receive_dispatch_thread->Start(); | ||||||
| } | ||||||
|
|
||||||
| EcalRecImpl::~EcalRecImpl() | ||||||
| { | ||||||
| DisconnectFromEcal(); | ||||||
| receive_dispatch_thread->Interrupt(); | ||||||
| receive_dispatch_thread->Join(); | ||||||
|
|
||||||
| // Interrupt monitoring thread | ||||||
| monitoring_thread_->Interrupt(); | ||||||
| monitoring_thread_->Join(); | ||||||
|
|
||||||
| // Interrupt garbage collector | ||||||
| garbage_collector_trigger_thread_->Interrupt(); | ||||||
| garbage_collector_trigger_thread_->Join(); | ||||||
| garbage_collector_trigger_thread_->Join(); | ||||||
|
|
||||||
| { | ||||||
| std::unique_lock<decltype(recorder_mutex_)> recorder_lock(recorder_mutex_); | ||||||
|
|
@@ -723,28 +783,14 @@ namespace eCAL | |||||
|
|
||||||
| void EcalRecImpl::EcalMessageReceived(const eCAL::STopicId& topic_id_, const eCAL::SReceiveCallbackData& data_) | ||||||
| { | ||||||
| thread_local moodycamel::ProducerToken token(receive_dispatch_queue_); | ||||||
|
KerstinKeller marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| auto ecal_receive_time = eCAL::Time::ecal_clock::now(); | ||||||
| auto system_receive_time = std::chrono::steady_clock::now(); | ||||||
|
|
||||||
| std::shared_ptr<Frame> frame = std::make_shared<Frame>(&data_, topic_id_.topic_name, ecal_receive_time, system_receive_time); | ||||||
|
|
||||||
| // Add to the pre-buffer (it is thread-safe by using a mutex internally) | ||||||
| pre_buffer_.push_back(frame); | ||||||
|
|
||||||
| { | ||||||
| // Add to the currently recording job (if there is any) | ||||||
| std::shared_lock<decltype(recorder_mutex_)> recorder_lock(recorder_mutex_); | ||||||
| if (recording_recorder_job_ != nullptr) | ||||||
| { | ||||||
| recording_recorder_job_->AddFrame(std::move(frame)); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| { | ||||||
| // Add to the subscriber statistics | ||||||
| const std::lock_guard<decltype(subscriber_throughput_mutex_)> subscriber_statistics_lock(subscriber_throughput_mutex_); | ||||||
| subscriber_throughput_statistics_.AddFrame(data_.buffer_size); | ||||||
| } | ||||||
| receive_dispatch_queue_.enqueue(token, std::move(frame)); | ||||||
| } | ||||||
|
|
||||||
| Throughput EcalRecImpl::GetSubscriberThroughput() const | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| .. | ||
| THIS FILE IS AUTO-GENERATED AND SHOULD NOT BE EDITED MANUALLY. | ||
|
|
||
| .. include:: /include.txt | ||
|
|
||
| .. _thirdparty_licenses_concurrentqueue: | ||
|
|
||
| =============================================== | ||
| concurrentqueue | ||
| =============================================== | ||
|
|
||
| .. list-table:: | ||
| :widths: 20 80 | ||
| :header-rows: 0 | ||
|
|
||
| * - **License** | ||
|
|
||
| - BSD-2-Clause | ||
|
|
||
| * - **Copyright** | ||
|
|
||
| - Copyright (c) 2013-2016, Cameron Desrochers. | ||
|
|
||
| * - **Repository** | ||
|
|
||
| - https://github.com/cameron314/concurrentqueue | ||
|
|
||
| * - **Upstream version** [#upstreamversion]_ | ||
|
|
||
| - `593df78ec309be7a7b456b3334025ccade1d2d66 <https://github.com/cameron314/concurrentqueue/tree/593df78ec309be7a7b456b3334025ccade1d2d66>`_ | ||
|
|
||
| * - **Integration** | ||
|
|
||
| - | ||
|
|
||
| - |fa-github| Git Submodule :file:`/thirdparty/concurrentqueue/concurrentqueue` | ||
|
|
||
| - |fa-windows| Windows builds | ||
|
|
||
| - |fa-ubuntu| Linux builds | ||
|
|
||
| .. [#upstreamversion] *The actual version used for building may differ from the listed dependency version.* | ||
| *Especially Linux binaries are often built against system packages, if available.* | ||
| *Check build files for further information.* | ||
|
|
||
| License Files | ||
| ============= | ||
|
|
||
| :file:`LICENSE.md` | ||
| -------------------------------------------------------------------------------- | ||
|
|
||
| .. literalinclude:: concurrentqueue/LICENSE.md | ||
| :language: none |
Uh oh!
There was an error while loading. Please reload this page.