IntelliPromptCompletion perfomance issue.

SyntaxEditor for WPF Forum

Posted 6 years ago by Roger
Version: 13.1.0582
Platform: .NET 4.0
Environment: Windows 7 (64-bit)
Avatar

We have found issue in IntelliPromptCompletion performance when we have 2000 item in Intellisense.

This is the source code and we measure the performance when we open the intellisense in Syntax Editor.

	private void ShowCompletionList(bool allowAutoComplete)
	{
            // Ensure the editor has focus
            editor.Focus();

            var session = this.CreateCompletionSession();
            session.CanCommitWithoutPopup = allowAutoComplete;

            // Open the session
            session.Open(editor.ActiveView);
        }

        private CompletionSession CreateCompletionSession()
        {
            // Create a session
            var session = new CompletionSession();
            session.CanFilterUnmatchedItems = filterUnmatchedItemsCheckBox.IsChecked.Value;
            session.MatchOptions = CompletionMatchOptions.UseAcronyms | CompletionMatchOptions.UseShorthand;

            // Add some items
            session.Items.Add(new CompletionItem("_intValue", new CommonImageSourceProvider(CommonImage.FieldPrivate),
                new HtmlContentProvider("<span style=\"color: #0000ff;\">int</span> <b>Foo._intValue</b><br/><span style=\"color: #008000;\">An integer value.</span>")));
            //// add more .... 
            for (int i = 0; i < 2000; i++)
            {
                var addText = string.Format("Add more Item[{0}]", i);
                session.Items.Add(new CompletionItem(addText, new CommonImageSourceProvider(CommonImage.FieldPrivate),
                    new HtmlContentProvider("<span style=\"color: #0000ff;\">int</span> <b>Foo._intValue</b><br/><span style=\"color: #008000;\">An integer value.</span>")));
            }

            session.Items.Add(new CompletionItem("Equals", new CommonImageSourceProvider(CommonImage.MethodPublic),
                new HtmlContentProvider("<span style=\"color: #0000ff;\">bool</span> <b>object.Equals</b>(<span style=\"color: #0000ff;\">object</span> obj)<br/><span style=\"color: #008000;\">Determines whether the specified <b>System.Object</b> is equal to the current <b>System.Object</b>.</span>")));
            session.Items.Add(new CompletionItem("GetHashCode", new CommonImageSourceProvider(CommonImage.MethodPublic),
                new HtmlContentProvider("<span style=\"color: #0000ff;\">int</span> <b>object.GetHashCode</b>()<br/><span style=\"color: #008000;\">Gets a hash code for this <b>System.Object</b>.</span>")));
            session.Items.Add(new CompletionItem("GetType", new CommonImageSourceProvider(CommonImage.MethodPublic),
                new HtmlContentProvider("<span style=\"color: #008080;\">Type</span> <b>object.GetType</b>()<br/><span style=\"color: #008000;\">Gets the <b>System.Type</b> of the current instance.</span>")));
            session.Items.Add(new CompletionItem("IntValue", new CommonImageSourceProvider(CommonImage.PropertyPublic),
                new HtmlContentProvider("<span style=\"color: #0000ff;\">int</span> <b>Foo.IntValue</b><br/><span style=\"color: #008000;\">An integer value.</span>")));
            session.Items.Add(new CompletionItem("IntValueChanged", new CommonImageSourceProvider(CommonImage.EventPublic),
                new HtmlContentProvider("<span style=\"color: #008080;\">EventHandler</span> <b>Foo.IntValueChanged</b>")));
            session.Items.Add(new CompletionItem("OnIntValueChanged", new CommonImageSourceProvider(CommonImage.MethodProtected),
                new HtmlContentProvider("<span style=\"color: #0000ff;\">void</span> <b>Foo.OnIntValueChanged</b>(<span style=\"color: #008080;\">EventArgs</span> e)")));
            session.Items.Add(new CompletionItem("ToString", new CommonImageSourceProvider(CommonImage.MethodPublic),
                new HtmlContentProvider("<span style=\"color: #0000ff;\">string</span> <b>object.ToString</b>()<br/><span style=\"color: #008000;\">Returns the string representation of the object.</span>")));

 It tooks 2s to open the intellisense in ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation.CompletionSession.Open(IEditorView).

This is the performance measure result.

29.69%   Open  •  2,072 ms  •  1 call  •  ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation.CompletionSession.Open(IEditorView)
  29.66%   Open  •  2,070 ms  •  1 call  •  ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation.IntelliPromptSessionBase.Open(IEditorView, TextRange)
    29.51%   OnOpened  •  2,059 ms  •  1 call  •  ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation.CompletionSession.OnOpened(EventArgs)
      28.42%   SetValue  •  1,983 ms  •  5 calls  •  System.Windows.DependencyObject.SetValue(DependencyProperty, Object)
        21.91%   OnApplyTemplate  •  1,529 ms  •  1 call  •  ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.IntelliPromptCompletionList.OnApplyTemplate
          21.77%   #Jlc  •  1,519 ms  •  1 call  •  ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.IntelliPromptCompletionList.#Jlc
            13.81%   Measure  •  963 ms  •  2,002 calls  •  System.Windows.UIElement.Measure(Size)
              12.86%   MeasureOverride  •  897 ms  •  2,002 calls  •  ActiproSoftware.Windows.Controls.PixelSnapper.MeasureOverride(Size)
                12.81%   Measure  •  894 ms  •  2,002 calls  •  System.Windows.UIElement.Measure(Size)
                  10.20%   MeasureOverride  •  711 ms  •  2,002 calls  •  ActiproSoftware.Windows.Controls.PixelSnapper.MeasureOverride(Size)
                    10.12%   Measure  •  706 ms  •  2,002 calls  •  System.Windows.UIElement.Measure(Size)
                      9.81%   MeasureOverride  •  684 ms  •  2,002 calls  •  ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.IntelliPromptCompletionItemText.MeasureOverride(Size)
                        ►9.72%   #Hub  •  678 ms  •  2,002 calls  •  ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.IntelliPromptCompletionItemText.#Hub(DrawingContext)

It spents most time to measure the text width and height in ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.IntelliPromptCompletionItemText.#Hub(DrawingContext).

If we can  improve the measure logic using better logic or fixed value, it will be 2 times faster than original.

We have Syntax Editor source code. So we changed the code and measured the performance. 

[Modified 6 years ago]

Comments (6)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Roger,

That code is trying to go through the list items and measure each one to find the maximum width so that the list displays at the same width as you scroll through the list (instead of resizing as you scroll).  You could make an implicit style for IntelliPromptCompletionList and set:

<Setter Property="VirtualizingStackPanel.IsVirtualizing" Value="False" />

That will cause that method to be skipped but I believe the same thing will still happen behind the scenes since it's no longer virtualized.  We can write down to look into trying to improve this in the future. 


Actipro Software Support

Answer - Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Roger,

We have made some code updates related to this for the upcoming 2015.1 version that improved very large list display time by almost 10x in the scenario we tested.  This version should be out in the next several weeks.


Actipro Software Support

Posted 5 years ago by Ken Hanson
Avatar

I am also eagerly waiting for this improvment, probably along with everyone else who uses the syntax editor.  Any further word on release dates for 2015.1?

Best Regards,

Ken

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

We are working on trying to squeeze another large language update in before releasing.  If it's taking too long, we may have to postpone it.  We're aiming to have 2015.1 out by the end of the month.


Actipro Software Support

Posted 5 years ago by Ken Hanson
Avatar

How close are we to seeing 2015.1?  I know it's tough to close the door on development, but the performance improvement in inteli-sense indicated here will be a very big deal, worth a release all on it's own.

Thanks,

Ken

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Ken,

We are hopefully releasing it today.  Will be doing some final testing shortly.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.