Skip to content

Commit

Permalink
Removed iceoryx/2.0.5 and Transport<IOX>
Browse files Browse the repository at this point in the history
  • Loading branch information
pkarneliuk committed Apr 30, 2024
1 parent 804659c commit 60228ef
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 230 deletions.
1 change: 0 additions & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class DLSM(ConanFile):
]
requires = [
"flatbuffers/24.3.25@#8fc25e15ac8ef302e2c42497d10c95e9",
"iceoryx/2.0.5@#88b8a0808574661ee715ec35ebe85175",
"nlohmann_json/3.11.3@#45828be26eb619a2e04ca517bb7b828d",
"spdlog/1.13.0@#8e88198fd5b9ee31d329431a6d0ccaa2",
"zeromq/4.3.5@#dd23b6f3e4e0131e696c3a0cd8092277",
Expand Down
10 changes: 0 additions & 10 deletions scripts/conan/tsan.suppressions
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,3 @@ race:Tsan_DataRace_Test

# zeromq/4.3.5
race:zmq::pipe_t::set_hwms

# iceoryx/2.0.5 looks totally broken
race:iox::posix::PosixUser::getUserName
race:iox::popo::BasePortData::BasePortData
race:iox::mepoo::ShmSafeUnmanagedChunk::releaseToSharedChunk
race:iox::popo::PublisherPortUser::sendChunk
race:iox::popo::PublisherPortUser::tryAllocateChunk
race:iox::popo::SubscriberPortUser::tryGetChunk
race:dlsm::Transport<dlsm::IOX>::Pub::send
race:dlsm::Transport<dlsm::IOX>::Sub::recv
5 changes: 1 addition & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
find_package(iceoryx REQUIRED COMPONENTS iceoryx_posh)
find_package(spdlog REQUIRED)
find_package(ZeroMQ REQUIRED)

Expand Down Expand Up @@ -26,11 +25,9 @@ target_link_libraries (dlsm
$<TARGET_NAME_IF_EXISTS:Coverage>
fbs
spdlog::spdlog
atomic
PRIVATE
libzmq-static
iceoryx_posh::iceoryx_posh
iceoryx_posh::iceoryx_posh_config
iceoryx_posh::iceoryx_posh_roudi
)

add_library (dlsmRuntime SHARED Public.cpp ${INTERNAL_HDRS} ${PUBLIC_HDRS})
Expand Down
137 changes: 0 additions & 137 deletions src/Transport.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
#include "impl/Transport.hpp"

#include <zmq.h>

#include <iceoryx_hoofs/log/logging.hpp>
#include <iceoryx_posh/iceoryx_posh_config.hpp>
#include <iceoryx_posh/internal/roudi/roudi.hpp>
#include <iceoryx_posh/popo/untyped_publisher.hpp>
#include <iceoryx_posh/popo/untyped_subscriber.hpp>
#include <iceoryx_posh/roudi/iceoryx_roudi_components.hpp>
#include <iceoryx_posh/roudi/roudi_config.hpp>
#include <iceoryx_posh/runtime/posh_runtime.hpp>
#include <iceoryx_posh/runtime/posh_runtime_single_process.hpp>
#include <map>
#include <memory>
#include <thread>
Expand All @@ -19,132 +9,6 @@

namespace dlsm {

struct IOX {
std::unique_ptr<iox::roudi::IceOryxRouDiComponents> components_;
std::unique_ptr<iox::roudi::RouDi> roudi_;
std::unique_ptr<iox::runtime::PoshRuntimeSingleProcess> runtime_;

IOX(std::string_view options) {
const auto opts = dlsm::Str::ParseOpts(options);
auto name = iox::RuntimeName_t{iox::cxx::TruncateToCapacity, opts.required("name")};

if (opts.get("inproc", "default") == "on") {
using L = iox::log::LogLevel;
static const auto levels = std::map<std::string_view, L>{
// clang-format off
{"off", L::kOff},
{"fatal", L::kFatal},
{"error", L::kError},
{"warning", L::kWarn},
{"info", L::kInfo},
{"debug", L::kDebug},
{"verbose", L::kVerbose},
// clang-format on
};
iox::log::LogManager::GetLogManager().SetDefaultLogLevel(levels.at(opts.get("log", "info")));

auto config = iox::RouDiConfig_t().setDefaults();

if (const auto pools = opts.get("pools", "default"); pools != "default") { // 64x10000/128x1000/512x100
auto& cfg = config.m_sharedMemorySegments[0].m_mempoolConfig;
cfg.m_mempoolConfig.clear();
for (const auto& entry : dlsm::Str::split(pools, "/")) {
auto pair = dlsm::Str::xpair(entry);
cfg.addMemPool({pair.first, pair.second});
}
cfg.optimize();
}

components_ = std::make_unique<iox::roudi::IceOryxRouDiComponents>(config);

auto params = iox::roudi::RouDi::RoudiStartupParameters{
((opts.get("monitor", "default") == "on") ? iox::roudi::MonitoringMode::ON
: iox::roudi::MonitoringMode::OFF),
false,
};

roudi_ =
std::make_unique<iox::roudi::RouDi>(components_->rouDiMemoryManager, components_->portManager, params);
runtime_ = std::make_unique<iox::runtime::PoshRuntimeSingleProcess>(name);
} else {
iox::runtime::PoshRuntime::initRuntime(name);
}
}

static iox::capro::ServiceDescription service(const dlsm::Str::ParseOpts& opts) {
const auto str = opts.required("service");
const auto p = dlsm::Str::split(str, "/");
if (p.size() != 3) {
throw std::invalid_argument("Unexpected IOX option value: service=" + str +
" expected: service/instance/event");
}
auto s = iox::capro::IdString_t{iox::cxx::TruncateToCapacity, p[0]};
auto i = iox::capro::IdString_t{iox::cxx::TruncateToCapacity, p[1]};
auto e = iox::capro::IdString_t{iox::cxx::TruncateToCapacity, p[2]};
return {s, i, e};
};
static iox::NodeName_t node(const dlsm::Str::ParseOpts& opts) {
return {iox::cxx::TruncateToCapacity, opts.get("node", "")};
}
static std::uint64_t history(const dlsm::Str::ParseOpts& opts) { return std::stoull(opts.get("history", "0")); }

class Pub {
iox::popo::UntypedPublisher pub_;

iox::popo::PublisherOptions options(const dlsm::Str::ParseOpts& opts) {
auto discard = opts.get("onfull", "discard") == "discard";
using P = iox::popo::ConsumerTooSlowPolicy;
return {
.historyCapacity = history(opts),
.nodeName = node(opts),
.offerOnCreate = opts.get("oncreate", "on") == "on",
.subscriberTooSlowPolicy = discard ? P::DISCARD_OLDEST_DATA : P::WAIT_FOR_CONSUMER,
};
}

public:
Pub([[maybe_unused]] IOX& iox, std::string_view config) : Pub{iox, dlsm::Str::ParseOpts{config}} {}
Pub([[maybe_unused]] IOX& iox, const dlsm::Str::ParseOpts& opts) : pub_{service(opts), options(opts)} {}

inline void* loan(const std::uint32_t payload) {
void* result = nullptr;
pub_.loan(payload).and_then([&](auto& payload) { result = payload; });
return result;
}
inline void publish(void* payload) { pub_.publish(payload); }
inline void release(void* payload) { pub_.release(payload); }
};

class Sub {
iox::popo::UntypedSubscriber sub_;

iox::popo::SubscriberOptions options(const dlsm::Str::ParseOpts& opts) {
auto discard = opts.get("onfull", "discard") == "discard";
auto capacity = std::stoull(opts.get("capacity", "0"));
using P = iox::popo::QueueFullPolicy;
return {
.queueCapacity = capacity ? capacity : iox::popo::SubscriberChunkQueueData_t::MAX_CAPACITY,
.historyRequest = history(opts),
.nodeName = node(opts),
.subscribeOnCreate = opts.get("oncreate", "on") == "on",
.queueFullPolicy = discard ? P::DISCARD_OLDEST_DATA : P::BLOCK_PRODUCER,
.requiresPublisherHistorySupport = false,
};
}

public:
Sub([[maybe_unused]] IOX& iox, std::string_view config) : Sub{iox, dlsm::Str::ParseOpts{config}} {}
Sub([[maybe_unused]] IOX& iox, const dlsm::Str::ParseOpts& opts) : sub_{service(opts), options(opts)} {}

inline const void* take() {
const void* result = nullptr;
sub_.take().and_then([&](const void* payload) { result = payload; });
return result;
}
inline void release(const void* payload) { sub_.release(payload); }
};
};

struct ZMQ {
static_assert((ZMQ_VERSION_MAJOR == 4) && (ZMQ_VERSION_MINOR >= 3), "ZeroMQ 4.3+ is required");

Expand Down Expand Up @@ -359,7 +223,6 @@ void Transport<Runtime>::Sub::release(const void* payload) {
p->release(payload);
}

template class Transport<IOX>;
template class Transport<ZMQ>;

} // namespace dlsm
20 changes: 0 additions & 20 deletions tests/perf/PerfTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,23 +197,3 @@ BENCHMARK_CAPTURE(TransportPubSub, tcp, (dlsm::ZMQ*)nullptr, "io_threads=2"s, "e
->Iterations(1)
->Repetitions(repeats)
->Args({4, num_msgs, 0, 1});

// BENCHMARK_CAPTURE(TransportPubSub, iox, (dlsm::IOX*)nullptr, "name=iox,inproc=on,pools=64x10000,log=off"s,
// "service=iox/test/perf,onfull=wait"s, "service=iox/test/perf,onfull=wait"s)
// ->MeasureProcessCPUTime()
// ->UseManualTime()
// ->Unit(benchmark::kSecond)
// ->Iterations(1)
// ->Repetitions(repeats)
// ->Args({4, num_msgs, 0, 1});

// BENCHMARK_CAPTURE(TransportPubSub, iox, (dlsm::IOX*)nullptr,
// "name=iox,inproc=on,monitor=on,pools=32x10000000,log=verbose"s,
// "service=iox/test/perf,onfull=discard"s,
// "service=iox/test/perf,onfull=discard"s)
// ->MeasureProcessCPUTime()
// ->UseManualTime()
// ->Unit(benchmark::kSecond)
// ->Iterations(1)
// ->Repetitions(repeats)
// ->Args({1, num_msgs, 0, 1});
58 changes: 0 additions & 58 deletions tests/unit/TestTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,6 @@

using namespace std::literals;

TEST(Transport, DISABLED_IOXConstruction) {
using Transport = dlsm::Transport<dlsm::IOX>;
auto impl = Transport("name=iox,inproc=on,pools=64x1000,log=off,monitor=on");

EXPECT_THAT([] { Transport(""); }, ThrowsMessage<std::invalid_argument>("Missing required key=value for key:name"))
<< "Missing configuration values";

EXPECT_THAT([] { Transport("name=iox,inproc=on,log=bad"); }, ThrowsMessage<std::out_of_range>("map::at"))
<< "Invalid configuration values";

EXPECT_THAT([&] { impl.pub("service=bad"); },
ThrowsMessage<std::invalid_argument>(
"Unexpected IOX option value: service=bad expected: service/instance/event"));

EXPECT_NO_THROW(impl.pub("service=test/i/test"));
EXPECT_NO_THROW(impl.sub("service=test/i/test"));

EXPECT_NO_THROW(impl.pub("service=test/i/test,history=10,oncreate=off,onfull=wait,node=Pub"));
EXPECT_NO_THROW(impl.sub("service=test/i/test,history=10,oncreate=off,onfull=wait,node=Sub,capacity=5"));
}

TEST(Transport, DISABLED_IOXPubSub) {
auto impl = dlsm::Transport<dlsm::IOX>("name=iox,inproc=on,pools=64x1000,log=off");

auto pub = impl.pub("service=test/i/test");
auto sub = impl.sub("service=test/i/test");

{
auto s = pub.loan<int>();
ASSERT_TRUE(s);
s.value() = 42;
s.publish();
}
{
auto s = sub.take<int>();
ASSERT_TRUE(s);
EXPECT_EQ(s.value(), 42);
}

struct Payload {
int data = 42;

bool operator==(const Payload& that) const { return this->data == that.data; }
};

const auto SendRecv = [&](const auto& tosend, auto torecv) {
EXPECT_TRUE(pub.send(tosend));
EXPECT_TRUE(sub.recv(torecv));
EXPECT_EQ(torecv, tosend);
};
SendRecv(1234, 0);
SendRecv("1234", "1234"s);
SendRecv(Payload{42}, Payload{0});
SendRecv("std::string"s, "std__string"s);
SendRecv(std::vector<Payload>{{3}, {2}, {1}}, std::vector<Payload>{{1}, {2}, {3}});
SendRecv(std::list<int>{1, 2, 3, 4}, std::list<int>{5, 6, 7, 8});
}

TEST(Transport, ZMQConstruction) {
using Transport = dlsm::Transport<dlsm::ZMQ>;
auto impl = Transport("io_threads=1");
Expand Down

0 comments on commit 60228ef

Please sign in to comment.