Performance problem with GoViewGridStyle

I have noticed a perfromance problem with the painting of the DOTS when when the UserGridStyle property is set to <span =“highlight”>GoViewGridStyle.Dots.

When the dots are spaced fairly close together (about 1/8" on my screen), the goView paints very slowly. You can see this by dragging another window over the goView (especially if the other window is in the same application – same message pump?) – everything slows down and the dragging goes very slowly.

Other than turning of DOTS, is there any way to improve this performance?

I just tried this in Demo1 and found that the performance was pretty good. I couldn’t really tell that it was slower when the GridCellSize is 5x5 pixels. I tried dragging GoObjects around the view as well as other windows, both from the same application and different applications.

So you had tried your application with and without the visible grid? Perhaps there's something else that is slower than you would like, such as when there are many or large images.

Hi. Thanks for the quick response.

I have tried my app with and without the visible grid. And it makes a difference.

I also see the problem in Demo1, though it is not quite as bad, there.

  1. On GraphicDoc 1:
    Set GridCellSizeHeight=5
    Set GridCellSizeWidth=5
    SetGridStyle=Dot

  2. Make the main window really big, so GraphDoc1 is not the entire window (so you have some dark gray background).

  3. Make Graphdoc1 take up about 3/4 of the main window.

  4. Do “File Open” to open a new window.

  5. Drag the new window over GraphDoc1. It is “jumpy” (repaints slowly). When you drag over the dark gray background, this does not happen.

  6. Turn off dots and the problem goes away. So it doesn’t seem like it is the painting of the shapes in the drawing.

This is a minor problem, but we are trying to optimize our application start time, so this is an area I am looking at.

Ah, yes, I see it, but for me on my machine, it’s subtle.

But even on slow machines, I don't think you are going to be able to reduce the application start time by a noticeable amount by turning off the grid. Dragging around occluding windows causes a lot of painting to happen very often. Opening a window causes painting to happen just once, when drawing the whole view.

What’s your PC / video card? I have a new HP core duo laptop with nvidia go 7600 and I can set the grid cell to 2 and I don’t see any lag.

Hi. I have a 3Ghz DUO with Nvidia (not sure which), too. Our app is more noticeable than the demo – I don’t know why yet.

Our app does a bunch of resizing of panels at startup (which forces repaints), and everything seems to be getting invalidated. So we end up repainting a lot (not caused by the goDiagram, I should mention).

So I am just removing issues one at a time, and I noticed the DOTS had some effect.

So it may be nothing, but it does seem that having the DOTS make the paint a lot slower. Compared to just having shapes.

Yes, it’s true that if there are going to be resizes of the GoView control, or if there are other changes which cause scrollbars to appear or disappear, it will invalidate the whole control.

If you want to optimize out the painting during this initialization process, you can call GoView.BeginUpdate() followed by GoView.EndUpdate().
Even better, call GoDocument.BeginUpdateViews() followed by GoDocument.EndUpdateViews(), which automatically calls the corresponding GoView methods on all GoViews that are displaying the given document.
As a reminder to all who might read this post -- don't perform unnecessary "optimizations"! Improper or premature optimizations are a leading cause of bugs. Only do this kind of optimization when you can prove that there is a significant improvement, and that you are correctly implementing such optimization.
That's why we tell people not to set any "SuspendsUpdates" property, even though it's available. I think calling BeginUpdate/EndUpdate is safer than setting SuspendsUpdates, but you still need to make sure the calls are always paired up (use try/finally!) and only called when you are sure it's worth it.

I guess I remain convinced that there is a problem with the DOT painting. It’s unusually slow.

Try this with demo 1:

  1. Turn on DOTS on a 5x5 grid (as previously indicated in post).
  2. Drag a shape (on GraphDoc1) around on the page. Notice how slowly it drags with DOTS on.
  3. Turn of DOTS and see how fast it drags.

I have a 3.4G dual with a Nvida 7300.

Well, on this machine, which is a 3GHz single processor with Nvidia 5200 and 1GB memory, I really have a hard time telling the difference in behavior when dragging an object around quickly, with or without GoView.GridStyle == GoViewGridStyle.Dot. I’m running the unmodified Demo1.exe for .NET 2.0.

Maybe there's some other reason for the performance difference.

Maybe there’s some other reason for the performance difference.
Oops, I think the demo is ok. The demo is only slow if the properties window is open while you drag. :)

I guess I’m not sure what’s making my app slow in the case of dragging with the GRID dots. Will keep looking.