perf(uORB): skip subscription lookups until a device node is added (#29249)

While a topic has no device node, every Subscription::update(), copy(),
updated() and advertised() repeats the device node lookup and fails
again. Polling modules touch many optional topics on every loop: in a
SITL flight about 8% of all instructions, and about a quarter of each
MAVLink thread, were such failed lookups.

Device nodes are never removed, so a lookup that failed cannot succeed
before a node is added. Count the nodes added in DeviceMaster and only
retry the lookup once that count has changed. Protected builds, where
user space has no cheap access to it, keep retrying every time.

Assisted-by: Claude:claude-opus-5-5

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
Benjamin Cabé authored and GitHub committed 2026-10-24 07:06:39 -08:00
1 parent 8c3b934957
commit cd2b157682
8 files changed
+67 -2

No files matched your search

+7
View File
@@ -419,6 +419,13 @@ bool uORB::Manager::orb_device_node_exists(ORB_ID orb_id, uint8_t instance)
device_master->deviceNodeExists(orb_id, instance);
}
unsigned uORB::Manager::orb_node_generation()
{
// no device master means no device node yet: 0, so that subscribers retry
const DeviceMaster *device_master = uORB::Manager::get_instance()->_device_master;
return (device_master != nullptr) ? device_master->nodeGeneration() : 0;
}
void *uORB::Manager::orb_add_internal_subscriber(ORB_ID orb_id, uint8_t instance, unsigned *initial_generation)
{
uORB::DeviceNode *node = nullptr;