-
Notifications
You must be signed in to change notification settings - Fork 68
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
VTK Performance Improvements #1637
Conversation
🏆 @chaosphere2112 Great job with the analyses. An alternative approach, I would suggest, is just getting the world position of the picked point from the interactor and then looping through the possible actors to determine if they would be of interest. This eliminates the n calls to calculate the world pick position (this is done internally in PickProp) which does a bunch of coordinate transform calculations. You could also fine tune which props to select from using this approach. |
I gathered up the actors we're checking for and passed them in as a
|
@chaosphere2112 Yeah I would've expected that. Each renderer internally maintains a |
@sankhesh I managed to shave off a considerable chunk of execution time by running through the significant actors and checking if any of them are in the renderer prior to using |
|
👏 |
OK, so now it should pass all but three tests. @doutriaux1 and I had a conversation yesterday, and we've decided that we're going to keep |
@chaosphere2112 @doutriaux1 Mind if I ask why change the pattern behavior? I am asking since there were extensive discussions when that was being implemented and @durack1 and other users had liked the idea of having those additional features. Additionally the current way, a |
Hey alll @sankhesh @chaosphere2112 @doutriaux1 its not a great idea to change the behavior without a general discussion. If you want to do that, then the best thing is to start a discussion here (on a separate issue) or in the mailing list. For the project management and community effort, that's the best approach as there are lot of people out there using UV-CDAT. |
My biggest problem is that it's a weird and inconsistent API. I'll let @doutriaux1 fill in his arguments when he gets in this afternoon (he's got the morning off). @aashish24 I'd be happy to move this change into a different PR; it was convenient to do since I was already rooting around in that code here. The issue mostly came up because @doutriaux1 is working on his colormap/color update, and was confused by some behavior in the pattern tests. |
I agree with @chaosphere2112. Pattern are usually used to highlight an area of interest the background color is introducing inconsistencies in the API and can easily be dealt with by plotting a regular isofill underneath it. |
@chaosphere2112 @doutriaux1 I'd be more than happy to provide my input on this one.. But I'm a little lost as to what the proposed change is, and how it affects my ability to plot colors and overplot hatches/patterns.. @chaosphere2112 can we talk about this next week? |
@durack1 it does not affects any capability but makes it a little less confusing since the |
@doutriaux1, thanks for clarifying.. It did seem to me from reading the above that you're aiming at standardizing behaviors.. And as long these changes also allow overplotting and opacity control, I'm all for making behaviors more consistent and consequently easier for a user to interpret and use.. |
I think in general its better to do something like this in another PR mostly because of clarity and consistency. This PR which is for performance improvements now is going to the change the API and the behavior which is not best as it makes it harder to draw the line and to review the code. |
@doutriaux1 @chaosphere2112 please create another issue and discussion topic for the pattern and opacity stuff. I would like @sankhesh and @durack1 to be involved as well and let's just focus on the PI on this branch. |
Sure, I'll go ahead and make another issue for discussing that. I've already removed the offending code, and I'm passing all tests (ish). The NOGUI build failed for some unrelated reason (wasn't able to pull CMOR), FULL on crunchy failed on an unrelated test, and I'm not sure what garant's issue is. |
thanks @chaosphere2112 much appreciated!.. you are awesome 😃 : |
VTK Performance Improvements
This pull request addresses performance issues experienced in the VCS interactive features.
TL;DR
I made significant cuts to the number of renderers and actors (we now use fewer than in 2.2), but performance of prop picking is still worse than in 2.2. Need help getting it lower, @sankhesh @aashish24 @doutriaux1 @jbeezley.
The Problem
The problem boils down to determining what exactly is under the mouse. To do that, I use VTK's
vtkPropPicker
, which, as far as I can tell, is the best tool for determining what actors are at a given (X, Y) coordinate. This object'sPickProp
method is called on every mouse move event and every mouse click event (this can be optimized out, since a mouse move will always happen before a mouse click, but is such a small fraction of the events triggering thePickProp
that it's basically irrelevant).The amount of time we spend hunting for actors has ballooned dramatically since 2.2; using methods detailed below, I discovered that the amount of time we spend in actor_at_point has nearly doubled. There are two main axes which we can adjust to effect the numbers on the profile; the number of renderers (each renderer has
PickProp
called on it separately) and the number of props. I discovered through experimentaiton thePickProp
's performance is linear with regards to the number of props, so reducing the number of renderers doesn't accomplish anything besides decreasing the total number of calls toPickProp
(and maybe some fringe benefits with regards to render time that I haven't explored too much). That means that as far as I can tell, the only way to decrease the time spent picking is to reduce the total number of props in use. So, below is the detailed rundown of how I went about making some improvements to the performance of this function.Methodology
This calls the relevant function (
actor_at_point
) a bunch of times, descending across to the right (wraps around eventually).2.2.0 Profile
This release had quite tolerable performance. I'd say it's basically the goal.
Dividing
ncalls
ofPickProp
byncalls
ofactor_at_point
, we get 17 renderers in use.2.4-RC2 Profile
This is where we're at right now. It takes a smidge less than twice as long to do the same task, which is super annoying while you're mousing around. You'll notice that the
percall
time has increased, as well as thencalls
time. The reasonncalls
has gone up is because we are operating with quite a lot more renderers, and we're picking across all of them. This means that the functionPickProp
, which has gotten slower since 2.2.0, will take longer and is called more. 😞Dividing
ncalls
ofPickProp
byncalls
ofactor_at_point
, we get 23 renderers in use.Reduced Renderers Profile
I started with the low-hanging fruit; I dramatically reduced the number of times we're going to call
PickProp
by reducing the number of renderers we're using. This dropped thencalls
to even lower than 2.2.0 👍 , but it tripled thepercall
time 👎 ; looks likePickProp
is roughly linear with the number of props. So, we're going to have to examine the use of props.Dividing
ncalls
ofPickProp
byncalls
ofactor_at_point
, we get 8 renderers in use.Prop Analysis
Uh, wow. That's a big uptick in actors. Decided to double check my renderer count just in case the math was fuzzy above.
Alright, so where are those coming from? Guess it's time to dive into the types of actors in use...
There wasn't any easy way to gather this info externally, so I just added some print statements to every place I found that created a vtkActor() in the codebase and tallied them up afterwards.
2.2.0
So, a lot of lines, and a few other things. Not too bad.
2.4-RC2
The code in
prepFillarea
was changed during the pattern/hatch PR to create a separatevtkPolyData
/vtkPolyDataMapper
/vtkActor
per filled box, which is why we have so many actors. I cleaned that up a bit (now will only make one for each patterned fill and one that does all of the "solid" fills). This brought our actor count back down to where it was for 2.2, but, sadly, the performance gains did not keep pace.Reduced Renderers + FillArea Refactor Actor Counts
Reduced Renderers + FillArea Refactor Profile
Alright, we shaved 25 seconds off of the execution time of the test, and .001 seconds off the
percall
time. That is still a pretty sizable gap between here and 2.2 performance, though...Line Polydata Optimization
So, let's start getting wild and crazy and actually try and be better behaved than 2.2. 59 lines is a lot of actors/polydata. How about we combine a few of those? As is, every single line that is drawn on screen gets its own actor/polydata pipeline. I merged them down so that each vcs Line that is passed in will only generate one actor per line width and line pattern (since those are set on the actor itself). In practice, this pretty much means one actor per vcs Line object plotted.
This shaves another 11 seconds off of the testcase.
Line Polydata Optimization Actor Counts
Line Polydata + Reduced Renderers + Fillarea Polydata Profile
So now I've reduced the number of actors to as few as possible, reduced the number of renderers to as few as possible, and performance is still worse than it was (and at this point I would expect it to be better). I'm not sure where to go from here to get those last 20 seconds of execution time back, so I'm opening it up to suggestions.