depthai-core icon indicating copy to clipboard operation
depthai-core copied to clipboard

reduce RPC calls by use of locally present data, e.g. `Device::getMxId()`

Open diablodale opened this issue 1 year ago • 0 comments

Why

I encourage use of local data which is current+valid vs. making remote network calls. The speed improvement is magnitudes better performance.

Move to the what:

Device::getMxId() is inherited from DeviceBase::getMxId(). Today's v2.21.2 implementation is to always make an RPC call to the remote OAK device. However, the MxId is already available locally in DeviceBase::deviceInfo.mxid or via DeviceInfo::getMxId(). There is no need to make an RPC call. Other code in DeviceBase like below already uses this local data.

https://github.com/luxonis/depthai-core/blob/bdbbf828da5c392c8e028a83715257b30c91b18f/src/device/DeviceBase.cpp#L628

Move to the how:

Change implementation is any RPC calls where the data is already local to use that local data. For mxid it is a one line change and perhaps adding a test for disconnected.

diablodale avatar May 12 '23 13:05 diablodale