mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-25 08:40:30 +08:00
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:
1 parent
8c3b934957
commit
cd2b157682
8 files changed
+67
-2
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user