eclipse-iceoryx / iceoryx

Eclipse iceoryx™ - true zero-copy inter-process-communication
https://iceoryx.io
Apache License 2.0
1.62k stars 383 forks source link

It is possible to specify a queue size greater than 256 #2317

Closed khromenokroman closed 1 month ago

khromenokroman commented 1 month ago

I do it like this

iox::popo::SubscriberOptions subscriberOptions;
subscriberOptions.queueCapacity = 5000U;
iox::runtime::PoshRuntime::initRuntime(name_app);
iox::popo::Listener listener;
iox::popo::UntypedSubscriber subscriber_ses({"SES", run_context, "Event"},subscriberOptions);

after

listener
    .attachEvent(subscriber_ses,
         iox::popo::SubscriberEvent::DATA_RECEIVED,
         iox::popo::createNotificationCallback(get_events_wrapper))
     .or_else([](auto) {
          ::fmt::print("Error\n");
});

I get this message [Warning]: Requested queue capacity 5000 exceeds the maximum possible one for this subscriber, limiting from 5000 to 256

Sorry for the stupid question, but can I increase the queue?

I found it here https://iceoryx.io/latest/advanced/configuration-guide/

I tried to build it like this cmake -Bbuild -Hiceoryx_meta -DBUILD_SHARED_LIBS=ON -DIOX_MAX_PUBLISHER_HISTORY=32768 but it didn't help

my publishers produce a lot of messages and I would like to get a little more than 256 at a time, can I do it somehow? I really need help :)

elBoberido commented 1 month ago

It is a compile time option. When you run cmake there is this output

-- [i] <<<<<<<<<<<<< Start iceoryx_posh configuration: >>>>>>>>>>>>>
-- [i] Using m:n communication!
-- [i] IOX_MAX_PUBLISHERS: 512
-- [i] IOX_MAX_SUBSCRIBERS: 1024
-- [i] IOX_MAX_INTERFACE_NUMBER: 4
-- [i] IOX_MAX_SUBSCRIBERS_PER_PUBLISHER: 256
-- [i] IOX_MAX_CHUNKS_ALLOCATED_PER_PUBLISHER_SIMULTANEOUSLY: 8
-- [i] IOX_MAX_PUBLISHER_HISTORY: 16
-- [i] IOX_MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY: 256
-- [i] IOX_MAX_PROCESS_NUMBER: 300
-- [i] IOX_MAX_NODE_NUMBER: 300
-- [i] IOX_MAX_NODE_PER_PROCESS: 1
-- [i] IOX_MAX_SHM_SEGMENTS: 100
-- [i] IOX_MAX_NUMBER_OF_MEMPOOLS: 32
-- [i] IOX_MAX_NUMBER_OF_CONDITION_VARIABLES: 1024
-- [i] IOX_MAX_NODE_NAME_LENGTH: 87
-- [i] IOX_MAX_ID_STRING_LENGTH: 100
-- [i] IOX_MAX_RUNTIME_NAME_LENGTH: 87
-- [i] IOX_MAX_RESPONSES_PROCESSED_SIMULTANEOUSLY: 16
-- [i] IOX_MAX_RESPONSE_QUEUE_CAPACITY: 16
-- [i] IOX_MAX_REQUEST_QUEUE_CAPACITY: 1024
-- [i] IOX_MAX_CLIENTS_PER_SERVER: 256
-- [i] IOX_MAX_NUMBER_OF_NOTIFIERS: 256
-- [i] IOX_MAX_REQUESTS_PROCESSED_SIMULTANEOUSLY: 4
-- [i] IOX_DEFAULT_RESOURCE_PREFIX: iox1
-- [i] IOX_EXPERIMENTAL_POSH_FLAG: false
-- [i] <<<<<<<<<<<<<< End iceoryx_posh configuration: >>>>>>>>>>>>>>

This means you need to run cmake with -DIOX_MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY=5000.

But be aware, with iceoryx1 you will get a massive increase in the static memory usage. When you run ../build/iox-roudi -l debug, roudi will print

2024-07-15 20:41:16.044 [Debug]: Trying to reserve 70585936 bytes in the shared memory [iceoryx_mgmt]
2024-07-15 20:41:16.121 [Debug]: Acquired 70585936 bytes successfully in the shared memory [iceoryx_mgmt]
2024-07-15 20:41:16.121 [Debug]: Registered memory segment 0x7daf46aaf000 with size 70585936 to id 1
2024-07-15 20:41:16.122 [Debug]: Trying to reserve 149264720 bytes in the shared memory [mathias]
2024-07-15 20:41:16.240 [Debug]: Acquired 149264720 bytes successfully in the shared memory [mathias]
2024-07-15 20:41:16.240 [Debug]: Roudi registered payload data segment 0x7daf3dc55000 with size 149264720 to id 2

So with the default configuration it is around 70MB for the iceoryx_mgmt shared memory segment. A queue size 5000 will increase this to around 265MB since every queues will support this size and with the static nature of iceoryx1 there is somewhere a max of max data structure which leads to this memory increase. With iceoryx2 this is not a problem since it is a runtime configuration and also per publisher-subscriber pairs.

khromenokroman commented 1 month ago

Thanks for the help, but I also had to do this

iox::popo::SubscriberOptions subscriberOptions;
subscriberOptions.historyRequest = 5000;
subscriberOptions.queueCapacity = 5000;

iox::popo::UntypedSubscriber subscriber({"Radar", "FrontLeft", "Object"}, subscriberOptions);

and when building the project, he indicated -DIOX_MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY=32000