Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/rtps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ set(RTPS_TUNING_KNOBS
SPDP_DEFAULT_REMOTE_LEASE_DURATION_S
SPDP_MAX_REMOTE_LEASE_DURATION_S
SPDP_EVICT_MIN_AGE_MS
SPDP_EVICT_READMIT_HOLDOFF_MS
)
foreach(knob ${RTPS_TUNING_KNOBS})
if(DEFINED CONFIG_RTPS_${knob} AND NOT "${CONFIG_RTPS_${knob}}" STREQUAL "" AND NOT "${CONFIG_RTPS_${knob}}" STREQUAL "0")
Expand Down
34 changes: 28 additions & 6 deletions components/rtps/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,15 @@ menu "RTPS"
participant takes the slot of the
oldest one none of this participant's user endpoints match
(an expired one first), so a peer you need can still be
discovered on a domain crowded with peers you do not. At most
one eviction per SPDP_RESEND_PERIOD_MS, never of a participant
discovered less than SPDP_EVICT_MIN_AGE_MS ago, each logged as
a warning. Off: a participant beyond the pool is ignored until
a lease frees a slot (the previous behaviour).
discovered on a domain crowded with peers you do not. Never of
a participant discovered less than SPDP_EVICT_MIN_AGE_MS ago;
a peer evicted before waits SPDP_EVICT_READMIT_HOLDOFF_MS;
then one eviction per SPDP_RESEND_PERIOD_MS from the budget
of its kind (former evictees and never-evicted peers each
have their own, so neither starves the other and the churn is
at most two per period); each logged as a warning.
Off: a participant beyond the pool is ignored until a lease
frees a slot (the previous behaviour).

config RTPS_SPDP_EVICT_MIN_AGE_MS
int "SPDP_EVICT_MIN_AGE_MS: youngest participant eviction may forget, ms (0 = profile default)"
Expand All @@ -337,6 +341,24 @@ menu "RTPS"
selected profile's value (3 x SPDP_RESEND_PERIOD_MS: 6000
embedded, 3000 host).

config RTPS_SPDP_EVICT_READMIT_HOLDOFF_MS
int "SPDP_EVICT_READMIT_HOLDOFF_MS: no eviction for a peer evicted this recently, ms (0 = profile default)"
depends on RTPS_SPDP_EVICT_UNUSED_PARTICIPANTS
default 0
range 0 600000
help
A peer this participant evicted less than this long ago has
nothing evicted for it when it announces again (a free slot it
still takes at once). On a domain that stays bigger than the
pool, the peers that do not fit re-announce every period and
would otherwise take turns displacing each other ahead of a
peer never seen before - the one you may need (which has its
own one-per-period eviction budget, as the former evictees have
theirs). Longer: less churn, but a peer you evicted and now
need waits this long. 0
keeps the selected profile's value (5 x SPDP_RESEND_PERIOD_MS:
10000 embedded, 5000 host).

endmenu

menu "Tasks (advanced)"
Expand Down Expand Up @@ -372,7 +394,7 @@ menu "RTPS"
callback, and the reactor ("rtps_reactor"). Raise it when a
callback needs more than the default; a value below 2048 is
refused at build time. 0 keeps the selected profile's value
(6144 on the embedded profile).
(8192 on the embedded profile).

config RTPS_SPDP_WRITER_PRIO
int "SPDP_WRITER_PRIO: protocol task priority (0 = profile default)"
Expand Down
2 changes: 1 addition & 1 deletion components/rtps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ via `include/rtps/config.hpp`.
| `RTPS_ENABLE_RPC` | on (default) | Compile in services + actions (RMI/AMI). Disable to drop that code + its threads on a pure-pub/sub device. |
| `RTPS_DOMAIN_ID` | 0 | DDS domain id (the `ROS_DOMAIN_ID` equivalent, 0..232). Derives the port base `7400 + 250 * id` and GUID prefix byte 9, so every participant on a domain must use the same value. Compile-time. |
| `RTPS_THREAD_POOL_READER_PRIO` | 0 = profile default (5 on ESP32) | FreeRTOS priority of the transport's worker pool and reactor tasks, which send and receive all traffic (see [Priority scheduling](#priority-scheduling-bands-dedicated-ports-dscp)). |
| `RTPS_THREAD_POOL_READER_STACKSIZE` | 0 = profile default (6144 on ESP32) | Stack of those tasks (they also run every reader and matched callback). ESP only: a host `std::thread` uses the platform default stack. |
| `RTPS_THREAD_POOL_READER_STACKSIZE` | 0 = profile default (8192 on ESP32) | Stack of those tasks (they also run every reader and matched callback). ESP only: a host `std::thread` uses the platform default stack. |
| `RTPS_SPDP_WRITER_PRIO` / `RTPS_SPDP_WRITER_STACKSIZE` | 0 = profile default (5 / 4096 on ESP32) | Priority and stack of the protocol task (`rtps_protocol`: SPDP announcements, reliable-writer HEARTBEATs, liveliness checks). The stack is raised to at least 4096 before the task is created; ESP only, as above. |
| (runtime) `RtpsParticipant::Config::tasks` | the above | Per-participant overrides of the same tasks - an `espp::Task::BaseConfig` (stack, priority, core id) for the receive workers (and their count), the reactor, the transport's job-retry task and the protocol task; an unset entry keeps the Kconfig default. An action server's execute workers are configured by `ActionConfig::execute_workers` / `execute_task`. |
| `RTPS_SPDP_RESEND_PERIOD_MS` | 0 = profile default (2000 on ESP32) | Participant announcement period. Keep it well below the announced lease. |
Expand Down
26 changes: 21 additions & 5 deletions components/rtps/include/rtps/config_desktop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ const uint8_t MAX_TOPICNAME_LENGTH = RTPS_CFG_MAX_TOPICNAME_LENGTH;
// The 1600 is a host figure that nothing applies; selected ON the target (the
// Kconfig limits-profile choice puts this header on an ESP32 too) this IS the
// FreeRTOS stack of every receive worker, and 1600 overflows on the first
// datagram - so on ESP it is the embedded profile's 6144, as the capacity
// datagram - so on ESP it is the embedded profile's 8192, as the capacity
// profiles are about pool sizes, not task stacks.
#ifndef RTPS_CFG_THREAD_POOL_READER_STACKSIZE
#if defined(ESP_PLATFORM)
#define RTPS_CFG_THREAD_POOL_READER_STACKSIZE 6144
#define RTPS_CFG_THREAD_POOL_READER_STACKSIZE 8192
#else
#define RTPS_CFG_THREAD_POOL_READER_STACKSIZE 1600
#endif
Expand Down Expand Up @@ -284,9 +284,10 @@ const Duration_t SPDP_MAX_REMOTE_LEASE_DURATION = {RTPS_CFG_SPDP_MAX_REMOTE_LEAS
// endpoints matched by any user endpoint of ours) so the newcomer gets the
// slot: oldest discovered first, never one discovered less than
// SPDP_EVICT_MIN_AGE_MS ago (its endpoint discovery may still be in flight),
// at most one per SPDP_RESEND_PERIOD_MS, and an expired participant before any
// live one. Each eviction is logged: a domain that keeps evicting wants a bigger
// SPDP_MAX_NUMBER_FOUND_PARTICIPANTS. menuconfig RTPS -> Discovery timing.
// at most one per SPDP_RESEND_PERIOD_MS for a peer evicted before and one for a
// peer never evicted (two budgets, see SPDP_EVICT_READMIT_HOLDOFF_MS), and an
// expired participant before any live one. Each eviction is logged: a domain that keeps evicting
// wants a bigger SPDP_MAX_NUMBER_FOUND_PARTICIPANTS. menuconfig RTPS -> Discovery timing.
#ifndef RTPS_CFG_SPDP_EVICT_UNUSED_PARTICIPANTS
#define RTPS_CFG_SPDP_EVICT_UNUSED_PARTICIPANTS 1
#endif
Expand All @@ -295,6 +296,21 @@ const bool SPDP_EVICT_UNUSED_PARTICIPANTS = RTPS_CFG_SPDP_EVICT_UNUSED_PARTICIPA
#define RTPS_CFG_SPDP_EVICT_MIN_AGE_MS (3 * RTPS_CFG_SPDP_RESEND_PERIOD_MS)
#endif
const uint32_t SPDP_EVICT_MIN_AGE_MS = RTPS_CFG_SPDP_EVICT_MIN_AGE_MS;
// A participant this one evicted is not let back in by evicting another one
// for this long after (it still takes a free slot at once). Without it, on a
// domain that stays bigger than the pool, the rejected peers re-announce every
// period and take turns displacing each other at the eviction rate, and a peer
// never seen before - the one this participant may actually need - competes
// with all of them for the one slot per period and can lose every round. Held
// off, the just-evicted go to the back of the queue, and the one eviction per
// period is budgeted per kind - former evictees and never-evicted peers each
// have their own - so a stream of fresh GUIDs cannot starve a peer evicted
// earlier that is needed now, nor the other way round; the churn is at most
// two per period. menuconfig RTPS -> Discovery timing.
#ifndef RTPS_CFG_SPDP_EVICT_READMIT_HOLDOFF_MS
#define RTPS_CFG_SPDP_EVICT_READMIT_HOLDOFF_MS (5 * RTPS_CFG_SPDP_RESEND_PERIOD_MS)
#endif
const uint32_t SPDP_EVICT_READMIT_HOLDOFF_MS = RTPS_CFG_SPDP_EVICT_READMIT_HOLDOFF_MS;

// Transport channel pool: 2 shared multicast channels (SPDP metatraffic +
// user multicast) + 2 unicast channels per participant (builtin + user), plus
Expand Down
24 changes: 20 additions & 4 deletions components/rtps/include/rtps/config_esp32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const uint8_t MAX_TOPICNAME_LENGTH = RTPS_CFG_MAX_TOPICNAME_LENGTH;
// sets stacks through esp_pthread; a host std::thread uses the platform
// default). menuconfig RTPS -> Tasks.
#ifndef RTPS_CFG_THREAD_POOL_READER_STACKSIZE
#define RTPS_CFG_THREAD_POOL_READER_STACKSIZE 6144
#define RTPS_CFG_THREAD_POOL_READER_STACKSIZE 8192
#endif
const int THREAD_POOL_READER_STACKSIZE = RTPS_CFG_THREAD_POOL_READER_STACKSIZE; // byte
// Stack requested for the protocol task (SPDP announcements, heartbeats,
Expand Down Expand Up @@ -245,9 +245,10 @@ const Duration_t SPDP_MAX_REMOTE_LEASE_DURATION = {RTPS_CFG_SPDP_MAX_REMOTE_LEAS
// endpoints matched by any user endpoint of ours) so the newcomer gets the
// slot: oldest discovered first, never one discovered less than
// SPDP_EVICT_MIN_AGE_MS ago (its endpoint discovery may still be in flight),
// at most one per SPDP_RESEND_PERIOD_MS, and an expired participant before any
// live one. Each eviction is logged: a domain that keeps evicting wants a bigger
// SPDP_MAX_NUMBER_FOUND_PARTICIPANTS. menuconfig RTPS -> Discovery timing.
// at most one per SPDP_RESEND_PERIOD_MS for a peer evicted before and one for a
// peer never evicted (two budgets, see SPDP_EVICT_READMIT_HOLDOFF_MS), and an
// expired participant before any live one. Each eviction is logged: a domain that keeps evicting
// wants a bigger SPDP_MAX_NUMBER_FOUND_PARTICIPANTS. menuconfig RTPS -> Discovery timing.
#ifndef RTPS_CFG_SPDP_EVICT_UNUSED_PARTICIPANTS
#define RTPS_CFG_SPDP_EVICT_UNUSED_PARTICIPANTS 1
#endif
Expand All @@ -256,6 +257,21 @@ const bool SPDP_EVICT_UNUSED_PARTICIPANTS = RTPS_CFG_SPDP_EVICT_UNUSED_PARTICIPA
#define RTPS_CFG_SPDP_EVICT_MIN_AGE_MS (3 * RTPS_CFG_SPDP_RESEND_PERIOD_MS)
#endif
const uint32_t SPDP_EVICT_MIN_AGE_MS = RTPS_CFG_SPDP_EVICT_MIN_AGE_MS;
// A participant this one evicted is not let back in by evicting another one
// for this long after (it still takes a free slot at once). Without it, on a
// domain that stays bigger than the pool, the rejected peers re-announce every
// period and take turns displacing each other at the eviction rate, and a peer
// never seen before - the one this participant may actually need - competes
// with all of them for the one slot per period and can lose every round. Held
// off, the just-evicted go to the back of the queue, and the one eviction per
// period is budgeted per kind - former evictees and never-evicted peers each
// have their own - so a stream of fresh GUIDs cannot starve a peer evicted
// earlier that is needed now, nor the other way round; the churn is at most
// two per period. menuconfig RTPS -> Discovery timing.
#ifndef RTPS_CFG_SPDP_EVICT_READMIT_HOLDOFF_MS
#define RTPS_CFG_SPDP_EVICT_READMIT_HOLDOFF_MS (5 * RTPS_CFG_SPDP_RESEND_PERIOD_MS)
#endif
const uint32_t SPDP_EVICT_READMIT_HOLDOFF_MS = RTPS_CFG_SPDP_EVICT_READMIT_HOLDOFF_MS;

// Transport channel pool: 2 shared multicast channels (SPDP metatraffic +
// user multicast) + 2 unicast channels per participant (builtin + user), plus
Expand Down
26 changes: 21 additions & 5 deletions components/rtps/include/rtps/config_host_large.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ const uint8_t MAX_TOPICNAME_LENGTH = RTPS_CFG_MAX_TOPICNAME_LENGTH;
// The 1600 is a host figure that nothing applies; selected ON the target (the
// Kconfig limits-profile choice puts this header on an ESP32 too) this IS the
// FreeRTOS stack of every receive worker, and 1600 overflows on the first
// datagram - so on ESP it is the embedded profile's 6144, as the capacity
// datagram - so on ESP it is the embedded profile's 8192, as the capacity
// profiles are about pool sizes, not task stacks.
#ifndef RTPS_CFG_THREAD_POOL_READER_STACKSIZE
#if defined(ESP_PLATFORM)
#define RTPS_CFG_THREAD_POOL_READER_STACKSIZE 6144
#define RTPS_CFG_THREAD_POOL_READER_STACKSIZE 8192
#else
#define RTPS_CFG_THREAD_POOL_READER_STACKSIZE 1600
#endif
Expand Down Expand Up @@ -281,9 +281,10 @@ const Duration_t SPDP_MAX_REMOTE_LEASE_DURATION = {RTPS_CFG_SPDP_MAX_REMOTE_LEAS
// endpoints matched by any user endpoint of ours) so the newcomer gets the
// slot: oldest discovered first, never one discovered less than
// SPDP_EVICT_MIN_AGE_MS ago (its endpoint discovery may still be in flight),
// at most one per SPDP_RESEND_PERIOD_MS, and an expired participant before any
// live one. Each eviction is logged: a domain that keeps evicting wants a bigger
// SPDP_MAX_NUMBER_FOUND_PARTICIPANTS. menuconfig RTPS -> Discovery timing.
// at most one per SPDP_RESEND_PERIOD_MS for a peer evicted before and one for a
// peer never evicted (two budgets, see SPDP_EVICT_READMIT_HOLDOFF_MS), and an
// expired participant before any live one. Each eviction is logged: a domain that keeps evicting
// wants a bigger SPDP_MAX_NUMBER_FOUND_PARTICIPANTS. menuconfig RTPS -> Discovery timing.
#ifndef RTPS_CFG_SPDP_EVICT_UNUSED_PARTICIPANTS
#define RTPS_CFG_SPDP_EVICT_UNUSED_PARTICIPANTS 1
#endif
Expand All @@ -292,6 +293,21 @@ const bool SPDP_EVICT_UNUSED_PARTICIPANTS = RTPS_CFG_SPDP_EVICT_UNUSED_PARTICIPA
#define RTPS_CFG_SPDP_EVICT_MIN_AGE_MS (3 * RTPS_CFG_SPDP_RESEND_PERIOD_MS)
#endif
const uint32_t SPDP_EVICT_MIN_AGE_MS = RTPS_CFG_SPDP_EVICT_MIN_AGE_MS;
// A participant this one evicted is not let back in by evicting another one
// for this long after (it still takes a free slot at once). Without it, on a
// domain that stays bigger than the pool, the rejected peers re-announce every
// period and take turns displacing each other at the eviction rate, and a peer
// never seen before - the one this participant may actually need - competes
// with all of them for the one slot per period and can lose every round. Held
// off, the just-evicted go to the back of the queue, and the one eviction per
// period is budgeted per kind - former evictees and never-evicted peers each
// have their own - so a stream of fresh GUIDs cannot starve a peer evicted
// earlier that is needed now, nor the other way round; the churn is at most
// two per period. menuconfig RTPS -> Discovery timing.
#ifndef RTPS_CFG_SPDP_EVICT_READMIT_HOLDOFF_MS
#define RTPS_CFG_SPDP_EVICT_READMIT_HOLDOFF_MS (5 * RTPS_CFG_SPDP_RESEND_PERIOD_MS)
#endif
const uint32_t SPDP_EVICT_READMIT_HOLDOFF_MS = RTPS_CFG_SPDP_EVICT_READMIT_HOLDOFF_MS;

// Transport channel pool: 2 shared multicast channels (SPDP metatraffic +
// user multicast) + 2 unicast channels per participant (builtin + user), plus
Expand Down
Loading
Loading