Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1030 Add option to configure the chunk count for …
Browse files Browse the repository at this point in the history
…the intropsection mempools
  • Loading branch information
elBoberido committed Sep 5, 2023
1 parent d656def commit e34da1f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ struct DefaultRouDiMemory
DefaultRouDiMemory(const DefaultRouDiMemory&) = delete;
DefaultRouDiMemory& operator=(const DefaultRouDiMemory&) = delete;

mepoo::MePooConfig introspectionMemPoolConfig() const noexcept;

MemPoolCollectionMemoryBlock m_introspectionMemPoolBlock;
MemPoolSegmentManagerMemoryBlock m_segmentManagerBlock;
PosixShmMemoryProvider m_managementShm;

private:
mepoo::MePooConfig introspectionMemPoolConfig(const uint32_t chunkCount) const noexcept;
};
} // namespace roudi
} // namespace iox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class RouDiMemoryManager
expected<void, RouDiMemoryManagerError> destroyMemory() noexcept;

private:
mepoo::MePooConfig introspectionMemPoolConfig() const noexcept;
vector<MemoryProvider*, MAX_NUMBER_OF_MEMORY_PROVIDER> m_memoryProvider;
};
} // namespace roudi
Expand Down
5 changes: 5 additions & 0 deletions iceoryx_posh/include/iceoryx_posh/roudi/roudi_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ namespace config
{
struct RouDiConfig
{
// have some spare chunks to still deliver introspection data in case there are multiple subscriber to the data
// which are caching different samples; could probably be reduced to 2 with the instruction to not cache the
// introspection samples
uint32_t introspectionChunkCount{10};

RouDiConfig& setDefaults() noexcept;
RouDiConfig& optimize() noexcept;
};
Expand Down
18 changes: 7 additions & 11 deletions iceoryx_posh/source/roudi/memory/default_roudi_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace iox
namespace roudi
{
DefaultRouDiMemory::DefaultRouDiMemory(const RouDiConfig_t& roudiConfig) noexcept
: m_introspectionMemPoolBlock(introspectionMemPoolConfig())
: m_introspectionMemPoolBlock(introspectionMemPoolConfig(roudiConfig.introspectionChunkCount))
, m_segmentManagerBlock(roudiConfig)
, m_managementShm(SHM_NAME, posix::AccessMode::READ_WRITE, posix::OpenMode::PURGE_AND_CREATE)
{
Expand All @@ -38,25 +38,21 @@ DefaultRouDiMemory::DefaultRouDiMemory(const RouDiConfig_t& roudiConfig) noexcep
ErrorLevel::FATAL);
});
}
mepoo::MePooConfig DefaultRouDiMemory::introspectionMemPoolConfig() const noexcept
mepoo::MePooConfig DefaultRouDiMemory::introspectionMemPoolConfig(const uint32_t chunkCount) const noexcept
{
constexpr uint32_t ALIGNMENT{mepoo::MemPool::CHUNK_MEMORY_ALIGNMENT};
// have some spare chunks to still deliver introspection data in case there are multiple subscriber to the data
// which are caching different samples; could probably be reduced to 2 with the instruction to not cache the
// introspection samples
constexpr uint32_t CHUNK_COUNT{10U};
mepoo::MePooConfig mempoolConfig;
mempoolConfig.m_mempoolConfig.push_back(
{align(static_cast<uint32_t>(sizeof(roudi::MemPoolIntrospectionInfoContainer)), ALIGNMENT), CHUNK_COUNT});
{align(static_cast<uint32_t>(sizeof(roudi::MemPoolIntrospectionInfoContainer)), ALIGNMENT), chunkCount});
mempoolConfig.m_mempoolConfig.push_back(
{align(static_cast<uint32_t>(sizeof(roudi::ProcessIntrospectionFieldTopic)), ALIGNMENT), CHUNK_COUNT});
{align(static_cast<uint32_t>(sizeof(roudi::ProcessIntrospectionFieldTopic)), ALIGNMENT), chunkCount});
mempoolConfig.m_mempoolConfig.push_back(
{align(static_cast<uint32_t>(sizeof(roudi::PortIntrospectionFieldTopic)), ALIGNMENT), CHUNK_COUNT});
{align(static_cast<uint32_t>(sizeof(roudi::PortIntrospectionFieldTopic)), ALIGNMENT), chunkCount});
mempoolConfig.m_mempoolConfig.push_back(
{align(static_cast<uint32_t>(sizeof(roudi::PortThroughputIntrospectionFieldTopic)), ALIGNMENT), CHUNK_COUNT});
{align(static_cast<uint32_t>(sizeof(roudi::PortThroughputIntrospectionFieldTopic)), ALIGNMENT), chunkCount});
mempoolConfig.m_mempoolConfig.push_back(
{align(static_cast<uint32_t>(sizeof(roudi::SubscriberPortChangingIntrospectionFieldTopic)), ALIGNMENT),
CHUNK_COUNT});
chunkCount});

mempoolConfig.optimize();
return mempoolConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PublisherSubscriberCommunication_test : public RouDi_GTest
{
public:
PublisherSubscriberCommunication_test()
: RouDi_GTest(MinimalRouDiConfigBuilder().chunk_size(512).chunk_count(10).create())
: RouDi_GTest(MinimalRouDiConfigBuilder().payloadChunkSize(512).create())
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ namespace testing
/// shared memory.
class MinimalRouDiConfigBuilder
{
/// @brief Set the chunk size. Default = 128
IOX_BUILDER_PARAMETER(uint32_t, chunk_size, 128)
/// @brief Set the chunk count. Default = 10
IOX_BUILDER_PARAMETER(uint32_t, chunk_count, 10)
/// @brief Set the payload chunk size. Default = 128
IOX_BUILDER_PARAMETER(uint32_t, payloadChunkSize, 128)

/// @brief Set the payload chunk count. Default = 10
IOX_BUILDER_PARAMETER(uint32_t, payloadChunkCount, 10)

/// @brief Set the introspection chunk count. Default = 2
IOX_BUILDER_PARAMETER(uint32_t, introspectionChunkCount, 2)

public:
/// @brief creates the previously configured RouDiConfig_t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ RouDiConfig_t MinimalRouDiConfigBuilder::create() const noexcept
{
RouDiConfig_t roudiConfig;
mepoo::MePooConfig mepooConfig;
mepooConfig.addMemPool({m_chunk_size, m_chunk_count});
mepooConfig.addMemPool({m_payloadChunkSize, m_payloadChunkCount});
auto currentGroup = iox::posix::PosixGroup::getGroupOfCurrentProcess();
roudiConfig.m_sharedMemorySegments.push_back({currentGroup.getName(), currentGroup.getName(), mepooConfig});
roudiConfig.introspectionChunkCount = m_introspectionChunkCount;
return roudiConfig;
}
} // namespace testing
Expand Down

0 comments on commit e34da1f

Please sign in to comment.