Topology manager import optimisation#59
Conversation
|
Thanks for the PR! Optimizations and cleanup are always welcome, however after reviewing it there are still a few concerns/thoughts that come to mind. I'm mostly concerned since we've had quite a few concurrency issues in the past (ConcurrentModificationExceptions, deadlocks, race conditions etc) so making big changes relating to concurrency should probably be reviewed in great detail and load tested somehow.
Sorry for the long list, but as I said I'm wary of making big changes to multiple concurrency mechanisms in code that proved trickier than it seems in the past, without clear advantages - "if it ain't broke..." :-) That being said, if everyone's convinced it's all good and a real improvement then I'm all for it! |
388695f to
4d802ff
Compare
4d802ff to
4d31e21
Compare
|
Thanks for having a look. That's a big list. I hope most of the points are covered now |
|
Could you please clarify what is the bug being solved here? Are you experiencing a performance bottleneck that needs to be optimized, or are there concurrency issues? Could you elaborate on the use case where this change is needed and the current implementation is insufficient, maybe with a more concrete example? |
|
The suggested changes create a race condition between all processed events by dispatching each one to be individually processed in a separate thread, which may result in the events being processed out of order, i.e. an endpoint that is added and then immediately removed may end up first processing the remove (no-op) and then the addition (importing a service that should no longer exist), and vice versa. The race seems to be inherent to the design in the PR (if I understood the description correctly, which admittedly, I'm not sure I did). So I think the PR should not be accepted at this point. This did bring to my attention a different race condition in the existing implementation, so thanks for that. It seems like an easy fix and will be applied in a separate PR. |
This update addresses the issue where multiple events related to the same filter could cause the same number of threads from the executor in the
TopologyManagerImportclass to operate on the sameImportRegistrationobjects, resulting in diminished throughput.To resolve this, the proposed change ensures that each import registration or closing of an import registration is managed by a single thread within the executor of the topology manager. As a result, when multiple events occur for the same filter, only one thread will be responsible for the import or closing of each
ImportRegistration.