Currently, the ApproximateTimeSynchronizer only allows the execution of one callback simultaneously, as the call to self.signalMessage(*msgs) is inside of the lock.
For parallel execution oif callbacks (e.g. using a MultithreadedExecutor) it would be desirable to have the callback call outside of this lock. Parallel threads could then acquire the lock again and start comparing timestamps. This would allow a higher throughput for callbacks that take some time to process, in our case a deep learning model.
Additionally, the usage of a context manager for the lock and more inline comments would probably make the code more readable.
To sum it up, handle inside the lock:
Compare timestamps
Clear outdated messages from the buffer
Find matches, remember them somewhere and remove them from the buffer
Afterwards, outside of the lock
Call the callback of the matched messages
What do you think about this? We will implement this change internally and report if we can parallel execution to work.
Currently, the ApproximateTimeSynchronizer only allows the execution of one callback simultaneously, as the call to
self.signalMessage(*msgs)
is inside of the lock.For parallel execution oif callbacks (e.g. using a MultithreadedExecutor) it would be desirable to have the callback call outside of this lock. Parallel threads could then acquire the lock again and start comparing timestamps. This would allow a higher throughput for callbacks that take some time to process, in our case a deep learning model.
Additionally, the usage of a context manager for the lock and more inline comments would probably make the code more readable.
To sum it up, handle inside the lock:
Afterwards, outside of the lock
What do you think about this? We will implement this change internally and report if we can parallel execution to work.