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
10 changes: 10 additions & 0 deletions components/rtps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ foreach(knob ${RTPS_LIMIT_KNOBS})
endif()
endforeach()

# Transport task priority (Kconfig "Transport task priority"): a nonzero value
# overrides the selected profile's THREAD_POOL_READER_PRIO, which the transport
# gives its worker pool and reactor tasks. 0 keeps the profile's value.
if(DEFINED CONFIG_RTPS_THREAD_POOL_READER_PRIO
AND NOT "${CONFIG_RTPS_THREAD_POOL_READER_PRIO}" STREQUAL ""
AND NOT "${CONFIG_RTPS_THREAD_POOL_READER_PRIO}" STREQUAL "0")
target_compile_definitions(${COMPONENT_LIB} PUBLIC
"RTPS_CFG_THREAD_POOL_READER_PRIO=${CONFIG_RTPS_THREAD_POOL_READER_PRIO}")
endif()

# Cross-limit capacity check (mirrors lib/espp.cmake): every participant
# consumes 1 stateless writer/reader + 2 stateful writers/readers from the
# GLOBAL pools for its builtin discovery endpoints. Effective value = the
Expand Down
23 changes: 23 additions & 0 deletions components/rtps/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,29 @@ menu "RTPS"

endmenu

menu "Transport task priority (advanced)"
config RTPS_THREAD_POOL_READER_PRIO
int "THREAD_POOL_READER_PRIO: worker pool and reactor (0 = profile default)"
default 0
range 0 24
help
FreeRTOS priority of the transport's tasks: the worker pool
("rtps_worker_<n>"), which sends and receives all RTPS traffic
(publish() only queues a sample; a worker sends it) and runs
every reader and matched callback, and the reactor
("rtps_reactor"), the select() loop that hands received
datagrams to the pool. 0 keeps the selected profile's value
(5 on the embedded profile, 3 on the host profiles).

Raise it when a busy task of higher priority (a UI renderer, a
long computation) can run on the same core as these tasks:
until it yields, nothing is sent or received. Bands (QosBand)
order work inside the pool and cannot help when the pool's
tasks are not scheduled. The callbacks then run at this
priority too, so keep them short.

endmenu

config RTPS_STORAGE_DYNAMIC
bool "Use dynamic (heap) history/queue storage"
default n
Expand Down
10 changes: 10 additions & 0 deletions components/rtps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ via `include/rtps/config.hpp`.
| `RTPS_STORAGE_DYNAMIC` | off on ESP32 / on host | Static `std::array` history (zero-heap, drop-oldest) vs heap-backed `std::deque` (grows). Orthogonal to the profile. |
| `RTPS_ENABLE_FRAGMENTATION` | off on ESP32 / on host | DATA_FRAG for samples > ~64 KB (interoperates with FastDDS/ROS 2). |
| `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_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)). |

The domain id, announcement/heartbeat periods, and pool sizes live in the profile
headers.
Expand Down Expand Up @@ -251,6 +252,15 @@ of its underlying service/topic endpoints (note a ROS action server is ~8
endpoints — more than the default ration, so most fall back to deferred
dispatch unless the cap is raised).

Bands order work *inside* the transport's worker pool. The pool's tasks
themselves (`rtps_worker_<n>`, plus the `rtps_reactor` `select()` loop) run at
the profile's `THREAD_POOL_READER_PRIO` (5 on ESP32) on no particular core.
Every send and receive goes through them (`publish()` only queues the sample),
so a busy task of higher priority on their core stalls all traffic until it
yields. On ESP-IDF, menuconfig `RTPS -> Transport task priority (advanced)`
sets their priority; `0` keeps the profile default. The reader and matched
callbacks then run at that priority too, so keep them short.

---

## ESPP component dependencies
Expand Down
7 changes: 6 additions & 1 deletion components/rtps/include/rtps/config_desktop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ const int MAX_NUM_UDP_CONNECTIONS = RTPS_CFG_MAX_NUM_UDP_CONNECTIONS;
const int THREAD_POOL_NUM_WRITERS = 2;
const int THREAD_POOL_NUM_READERS = 2;
const int THREAD_POOL_WRITER_PRIO = 3;
const int THREAD_POOL_READER_PRIO = 3;
// The transport's worker pool and reactor tasks (EsppTransport). On ESP-IDF,
// menuconfig RTPS -> Transport task priority overrides it.
#ifndef RTPS_CFG_THREAD_POOL_READER_PRIO
#define RTPS_CFG_THREAD_POOL_READER_PRIO 3
#endif
const int THREAD_POOL_READER_PRIO = RTPS_CFG_THREAD_POOL_READER_PRIO;
const int THREAD_POOL_WORKLOAD_QUEUE_LENGTH_USERTRAFFIC = 32;
const int THREAD_POOL_WORKLOAD_QUEUE_LENGTH_METATRAFFIC = 32;

Expand Down
7 changes: 6 additions & 1 deletion components/rtps/include/rtps/config_esp32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ const int MAX_NUM_UDP_CONNECTIONS = RTPS_CFG_MAX_NUM_UDP_CONNECTIONS;
const int THREAD_POOL_NUM_WRITERS = 2;
const int THREAD_POOL_NUM_READERS = 2;
const int THREAD_POOL_WRITER_PRIO = 5;
const int THREAD_POOL_READER_PRIO = 5;
// The transport's worker pool and reactor tasks (EsppTransport). On ESP-IDF,
// menuconfig RTPS -> Transport task priority overrides it.
#ifndef RTPS_CFG_THREAD_POOL_READER_PRIO
#define RTPS_CFG_THREAD_POOL_READER_PRIO 5
#endif
const int THREAD_POOL_READER_PRIO = RTPS_CFG_THREAD_POOL_READER_PRIO;
const int THREAD_POOL_WORKLOAD_QUEUE_LENGTH_USERTRAFFIC = 60;
const int THREAD_POOL_WORKLOAD_QUEUE_LENGTH_METATRAFFIC = 60;

Expand Down
7 changes: 6 additions & 1 deletion components/rtps/include/rtps/config_host_large.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,12 @@ const int MAX_NUM_UDP_CONNECTIONS = RTPS_CFG_MAX_NUM_UDP_CONNECTIONS;
const int THREAD_POOL_NUM_WRITERS = 2;
const int THREAD_POOL_NUM_READERS = 2;
const int THREAD_POOL_WRITER_PRIO = 3;
const int THREAD_POOL_READER_PRIO = 3;
// The transport's worker pool and reactor tasks (EsppTransport). On ESP-IDF,
// menuconfig RTPS -> Transport task priority overrides it.
#ifndef RTPS_CFG_THREAD_POOL_READER_PRIO
#define RTPS_CFG_THREAD_POOL_READER_PRIO 3
#endif
const int THREAD_POOL_READER_PRIO = RTPS_CFG_THREAD_POOL_READER_PRIO;
const int THREAD_POOL_WORKLOAD_QUEUE_LENGTH_USERTRAFFIC = 64;
const int THREAD_POOL_WORKLOAD_QUEUE_LENGTH_METATRAFFIC = 64;

Expand Down
Loading