Skip to content
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

Improve Preference Filtering #8263

Conversation

colin-grant-work
Copy link
Contributor

@colin-grant-work colin-grant-work commented Jul 29, 2020

Signed-off-by: Colin Grant colin.grant@ericsson.com

What it does

This PR aims to make the filtering of nodes in the preference widget more performant, and to smooth the way for feature enhancements like #8252.

At the moment, filtering and scope changing actually modify the root of the TreeModel, rather than maintaining the same root and conditionally rendering tree nodes based on various criteria. The performance fix in #7936 improves the situation, but at the cost of some flexibility in scoping preferences. This PR moves that functionality into a modified TreeModel implementation and uses an iterative strategy parallel to the doUpdateRows function in the TreeWidget to determine which nodes to display. This will make filtering more performant as well as more flexible in response to changing demands.

In addition, this PR refactors away some of the not-well-encapsulated code from #7105 by eliminating the PreferenceEventService and locating emitters and state tracking in the classes logically responsible for them.

Also fixes #8689

How to test

It should retain the functionality of #7105, #7773, #7764, and #7936.

In addition:

  • Switching from User/Workspace to Folder scope or vice versa should be faster.
  1. Open a multi-root or saved workspace.
  2. Open preferences widget.
  3. Switch between User scope and Folder scope.
  4. Observe that the transition is quick, with little visible delay.
  • Filter performance is improved.
  1. Open preference widget
  2. Type a text query in the search bar.
  3. Observe that the filter is smooth, with little delay.
  • Node visibility is preserved better.
  1. Open preferences widget.
  2. Scroll in editor until some preference in the section css.lint is at the top of the visible window.
  3. Switch to folder scope.
  4. Observe that the same preference is still visible. (Formerly this would have caused a scroll to top.)
  5. Type the name of the preference in the filter bar.
  6. Observe that the preference is still at the top of the screen. (Formerly a filter would have caused a scroll to top.)
  • User and Workspace scopes are distinguished properly
  1. Follow the steps outlined in Switching preference scopes in Preference UI does not properly populate tree #8689
  2. Observe that the transition between User and Workspace scopes is managed correctly.

Further:

Review checklist

Reminder for reviewers

@colin-grant-work colin-grant-work marked this pull request as draft July 29, 2020 15:53
@colin-grant-work colin-grant-work force-pushed the feature/filter-improvements branch 3 times, most recently from e06345d to afaa91d Compare August 2, 2020 17:57
@colin-grant-work
Copy link
Contributor Author

@kenneth-marut-work, would you be willing to take a look at this?

@colin-grant-work colin-grant-work changed the title WIP: Improve Preference Filtering Improve Preference Filtering Aug 3, 2020
@colin-grant-work colin-grant-work marked this pull request as ready for review August 3, 2020 14:27
@kenneth-marut-work
Copy link
Contributor

In the third set of steps, I can confirm that typing the name of a preference (css.lint for example) scrolls to the correct preference. However, deleting the search query does not revert the editor back to its default (scroll-to-top) position, instead I am seeing a quick flicker and the editor returns back to the previously searched query.
In VSCode, if a query is searched for, and a preference is selected, clearing the search query reverts the editor to its default state.

@colin-grant-work
Copy link
Contributor Author

Thanks for the suggestions, @kenneth-marut-work. I have adjusted the editor to scroll to top when the text filter is cleared, as you indicated, and cleaned up the code you commented on.

@colin-grant-work colin-grant-work force-pushed the feature/filter-improvements branch 3 times, most recently from b91918d to b9a073b Compare August 7, 2020 18:39
@vince-fugnitto vince-fugnitto added performance issues related to performance preferences issues related to preferences labels Aug 13, 2020
protected lastSearchedLiteral: string = '';
protected _currentScope: number = Number(Preference.DEFAULT_SCOPE.scope);
protected _isFiltered: boolean = false;
protected _currentRows: Map<string, PreferenceTreeNodeRow> = new Map();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tree model should not had such representation. Why do you need it here? Flat rows should be computed in the widget based on nodes' attributes like visible.

Copy link
Contributor Author

@colin-grant-work colin-grant-work Aug 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this tree - and the rules about what should and shouldn't be displayed - are common to the PreferenceTreeWidget and PreferenceEditorWidget it's more convenient and more efficient to simply share that data in a location accessible to both widgets. Formerly, a separate service generated a tree that was consumed by both widgets, but that required that the downstream widgets implement logic determining visibility separately, even though the requirements are (nearly) identical.

If your concern is with the checks made elsewhere in the standard TreeModel implementation that use TreeNode.isVisible to determine whether to select a node, the function that generates the rows here can be altered to modify the .visible field on each node appropriately.

@colin-grant-work
Copy link
Contributor Author

@vince-fugnitto, @marechal-p, I've brought this up to date with master and it looks like the functionality is working well. If you wouldn't mind taking a look, I'd appreciate it - and I think it'll improve the preference system a fair bit 😄.

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colin-grant-work I verified the changes with the provided use-cases and it works as described 👍

  • preferences are generally much more responsive and seamless
  • switching between preference scopes works well (user, workspace and folder)
  • searching is more responsive, switching scopes with a search term present is also quick

Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although I wasn't able to notice a difference with performance. Is there something to specifically do or is my computer just fast enough to make the diff negligible?

@colin-grant-work
Copy link
Contributor Author

Yeah, on fast machines it isn't really noticeable - but the bugfix for workspace-scoped vs. user-scoped preferences still applies. The main difference is that in the old code, the entire tree was reconstructed for any update, and now it's just being filtered in a style similar to the way nodes are hidden or shown on expansion.

Signed-off-by: Colin Grant <colin.grant@ericsson.com>
@colin-grant-work colin-grant-work merged commit f66bc8c into eclipse-theia:master Feb 23, 2021
@colin-grant-work colin-grant-work deleted the feature/filter-improvements branch February 23, 2021 01:48
@paul-marechal paul-marechal added this to the 1.11.0 milestone Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance issues related to performance preferences issues related to preferences
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switching preference scopes in Preference UI does not properly populate tree
5 participants