Auto-complete list performance issues.

SyntaxEditor for WPF Forum

Posted 5 months ago by Sunshine - Appeon
Version: 21.1.1
Platform: .NET 5.0
Environment: Windows 10 (64-bit)
Avatar

I created a CompletionSession and set its filter properties:

session.CanFilterUnmatchedItems = true;
session.MatchOptions = CompletionMatchOptions.UseShorthand;

Then I added 3000 CompletionItems to this session.

After opening CompletionSession, my input can trigger list filtering. However, if there are still many filter list items at this time, there will be a freeze during the input process.

This happens only when the CanFilterUnmatchedItems property is set to'true'.

So I speculate that in the case of too many Items, there should be some performance problems in filtering.

Comments (9)

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

Hello,

Note that UseAcronyms will add some performance penalty and UseShorthand adds a significant performance penalty when using CanFilterUnmatchedItems.  This is due to the complex regular expression matching it's having to do on each item to determine if it passes the CanFilterUnmatchedItems filter or not.  If you don't use the shorthand option, how does your typing performance look with CanFilterUnmatchedItems?


Actipro Software Support

Posted 5 months ago by Sunshine - Appeon
Avatar

The best experience so far is UseShorthand and CanFilterUnmatchedItems.

If UseAcronyms can match uppercase letters and the string immediately following it, then it can also meet the demand. But it can only match uppercase letters.

In this situation, I can only choose one of experience and performance.

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

Hello,

We did more performance profiling on it to verify the slowdown cause:

  • CanFilterUnmatchedItems has to run the filters on all completion list items since any text edit could potentially show/hide an item.  If you have 3,000 completion items, then every time you type, it has to run the filters 3,000 times.
  • UseShorthand has a much more time-consuming Regex to consume (compared to other matchers) since it's basically allowing any number of characters to be typed between any character in the completion item's text.  While this is very flexible for matching, it can incur significant time penalty when there are lots of completion items.
  • Our StartsWith and Acronym matchers perform much faster than Shorthand, and therefore work much better right now when paired with CanFilterUnmatchedItems.

The latest Visual Studio seems to use a modified version of our Acronym matcher where as you said, they also match letters right after a capital letter.  I've made a TODO item to possibly implement that kind of logic in the future.  I don't believe a regular expression can be used to build that kind of matcher though, so some sort of custom string comparison logic would need to be built.

On a side note, you also can build custom completion item matchers with your own logic if you wish.  The IntelliPromptCompletionCustomItemMatcher QuickStart shows one way to do this.  That sample uses a Regex, but if you want to go lower level with custom non-Regex-based logic, you can inherit CompletionItemMatcherBase instead.


Actipro Software Support

Posted 4 months ago by Sunshine - Appeon
Avatar

I solved the problem by implementing a custom matcher and filter implementation.

Another question about filtering behavior:

When all items will be filtered. How to set the currently selected state to "CompletionSelectionState.Partial" and keep the last filtered items. Instead of filtering all and displaying ‘no matchs’.

Answer - Posted 4 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

There isn't an option for preventing filtering down to nothing right now.  We will write down the request for one.


Actipro Software Support

Posted 3 months ago by Sunshine - Appeon
Avatar

Does CompletionSession.FilterItems support directly setting its items?

I rewrote the filtering function myself due to performance issues and I want to judge whether there is an item that meets the filter after one input.

If there is no filter item that meets the conditions, the result of the last filter will be retained.

So in this process, I already have a collection that meets the filter conditions, but it cannot be directly set to CompletionSession.FilterItems. I can only set its callback method internally to let it filter again. This caused me some performance issues.

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Sorry but you cannot directly set items in session.FilterItems.  It is a class that inherits ListCollectionView, which is a "view" on the session's Items collection using filters.

The filter logic for the view should only really be doing anything if you set session.CanFilterUnmatchedItems to true, or have specified session.Filters.


Actipro Software Support

The latest build of this product (v21.1.3) was released 12 days ago, which was before the next post in this thread.
Posted 10 days ago by Vadim Tsedrik
Avatar

Hello,

I'm faced with the same performance problem for our customer.

I this particular case we are using more than 2000 CompletionItems that can be filtered by 10 different groups.

Also in different groups, there are a lot of similar variables, commands that includes in autocomplete list each time when typing new character. 

The performance is poor when trying to find "variable" in the list that contains the typed text. It takes 400-600ms of UI thread to show filtered items, even if result is 3-4 items.

I also tried to left only "StartWith" filter, because it's the common use case for our customers, but I cannot found how to do it properly. It always closes autocomplete box if any of the "ItemMatcher" was removed.

Basically I'm using 

session.MatchOptions = CompletionMatchOptions.IsCaseInsensitive | CompletionMatchOptions.UseAcronyms | CompletionMatchOptions.UseShorthand

match options, but any other combination doesn't show me autocomplete box at all.

So the question 1. Can we improve performance somehow for this particular case? Maybe some custom ItemMatcher can help.

Question 2. Can we leave only "StartWith" ItemMatcher to display only CompletionItems that matched only this particular filter?

How to reproduce:

https://share.getcloudapp.com/mXuKb2dJ

Thanks

Posted 10 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Vadim,

You shouldn't have to set any match options at all for it to work ok, since it will fall back to using starts-with matching only in that case.

Can you make a new simple sample project that shows it not working and send that to our support address?  Please exclude the bin/obj folders from the .zip you send so it doesn't get spam blocked.  Then we can look at that sample and see why it's not showing the completion list when match options aren't set.  Reference this thread in your e-mail.  Thanks!


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.