libcyphal icon indicating copy to clipboard operation
libcyphal copied to clipboard

Remove background cleanup of stale states

Open pavel-kirienko opened this issue 6 years ago • 0 comments

Once #181 and #185 are implemented, it will no longer be necessary to waste time on periodic list traversals to remove stale entries from them:

https://github.com/UAVCAN/libuavcan/blob/67da0aae7dd4eedae7905ab98941592cebab4723/libuavcan/src/transport/uc_dispatcher.cpp#L306-L312

This behavior is bad for hard real-time applications because it steals time from the spin() thread and the amount of time stolen is a function of the number of publishers, service clients, subscribed ports, and nodes on the bus (I will skip the detailed complexity analysis, suffice to say it's terrible). There shall be no cleanup.

But a keenly-eyed reader would object: "Hey, what about TransferReceiver objects that reach the transfer ID timeout condition, defined in section 4.3.2.3 of the UAVCAN specification? Wouldn't it make sense to get rid of them lest they use up all RAM?" To which I say that the worst case number of dead objects (which is also the number of memory pool blocks taken) is the number of used ports times 128, so it's easy to account for. Those rare embedded applications that trade-off determinism for memory can be served with a dedicated crutch in the form of a method that does this clean-up when invoked manually, but it's safe to omit it from the first release.

pavel-kirienko avatar Nov 19 '18 12:11 pavel-kirienko