New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: qvtkConnect and qvtkDisconnect performance improvement #378
ENH: qvtkConnect and qvtkDisconnect performance improvement #378
Conversation
… for wildcards When ctkVTKObjectEventsObserverPrivate::findConnection receives 0 parameter for an input then it cannot be used for retrieving an entry from the cache. Then we have to do a linear search.
Whenever a new connection is added or deleted, it's searched in the list of already existing connections using ctkVTKObjectEventsObserverPrivate::findConnection(). This findConnection() method is very slow if there are many connections, because the time-consuming ctkVTKConnection::isEqual() method is executed for each existing connection (before this commit, 40% of the time was spent in vtkConnection::isEqual while creating 10000 connections). To solve this performance issue, added a ConnectionIndex structure, which stores a pointer to each connection object using a hash map. When searching for a fully specified connection, the ConnectionIndex is used to find the connection directly, instead of iterating through all the children. Result of the optimization (ctkVTKObjectTest1): Create 10000 connections: 2.343 sec => 1.019 sec (2.3x speed improvement) Remove 10000 connections: 3.599 sec => 2.031 sec (1.77x speed improvement)
…an/CTK into vtkconnect-performance-improvement Conflicts: Libs/Visualization/VTK/Core/ctkVTKObjectEventsObserver.cpp
That's something I wanted to do for a while. Thanks for fixing it. |
@finetjul: Thanks for the comments, I've fixed all of them. There is one more thing that may worth considering: ctkVTKConnectionTest1 always fails, as the ctkVTKConnection / vtkCallbacks execution time ratio is well above 1.2 (typically between 3-6). |
Andras, I always had a ratio < 1.2
You might have some odd results if you run it in Debug mode (especially on Windows). |
This is interesting. Event execution seems to be very slow on your computer. Is it a debug-mode build? Without any compiler optimization? On my Win7 desktop (i7, 3.4GHz) in release mode ctkVTKConnection is 7x faster, vtkCallbacks are 32x faster: On my Win7 laptop (i5, 2.5GHz) in release mode it's 5x and 27x faster: On the desktop in debug mode everything is much slower: It would be nice to see the results on more computers/OSs, but the http://my.cdash.org/index.php?project=CTK seems to be completely abandoned. Is there a CTK dashboard where people actually submit their build results? |
Here is what I have when building in Release mode (on MacBook Pro Lion 2.4Ghz):
I agree, the CTK dashboard is a bit abandoned unfortunately :-( |
This seems like a nice optimization. Could it be rebased? This week would be a good time to merge. |
This has been merged into CTK already. The only outstanding issue is that the tests are failing as acceptable slowdown factor of ctkVTK events vs raw VTK events is 1.2x, while actually ctkVTK event processing is several times slower then pure VTK events. It seems that the bottleneck is Qt, so we cannot do much about it. Probably we should do two things:
|
Changing the success threshold so that the test can pass on all normal platforms sounds like the correct answer. The test should confirm the working state of the code, not set a bar that we cannot yet attain. |
+1 On Wed, May 7, 2014 at 10:49 AM, Steve Pieper notifications@github.comwrote:
+1 919 869 8849 |
The associated have already been integrated. See a2ade62 |
As discussed in [1], the test should check that the code works as expected and not set a bar that we cannot yet attain. [1] commontk#378 (comment)
As discussed in [1], the test should check that the code works as expected and not set a bar that we cannot yet attain. [1] commontk#378 (comment)
Whenever a new connection is added or deleted, it's searched in the list of already existing connections using ctkVTKObjectEventsObserverPrivate::findConnection(). This findConnection() method is very slow if there are many connections, because the time-consuming ctkVTKConnection::isEqual() method is executed for each existing connection (before this commit, 40% of the time was spent in vtkConnection::isEqual while creating 10000 connections).
To solve this performance issue, added a ConnectionIndex structure, which stores a pointer to each connection object using a hash map. When searching for a fully specified connection, the ConnectionIndex is used to find the connection directly, instead of iterating through all the children.
Result of the optimization (ctkVTKObjectTest1):
Create 10000 connections: 2.343 sec => 1.019 sec (2.3x speed improvement)
Remove 10000 connections: 3.599 sec => 2.031 sec (1.77x speed improvement)