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

do not fetch topsite information if not shown #5486

Closed
wants to merge 2 commits into from

Conversation

AndriusA
Copy link

@AndriusA AndriusA commented May 7, 2020

Relates to brave/brave-browser#9481

Mitigates performance issues with topsites when user has thousands of bookmarks (see brave/brave-browser#9481 (comment)) by not fetching topsite information when the widget is disabled.

Looking at chromium side of bookmarks code, looking up by { url: url } goes to execution path that checks URL index as a hashmap, vs. looking up by just url having to iterate the entire list of all the bookmarks each time (the former is faster when done).

Submitter Checklist:

Test Plan:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@AndriusA AndriusA requested review from petemill, simonhong and cezaraugusto and removed request for petemill and simonhong May 7, 2020 14:45
@AndriusA AndriusA self-assigned this May 7, 2020
Copy link
Contributor

@cezaraugusto cezaraugusto left a comment

Choose a reason for hiding this comment

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

++

Copy link
Member

@petemill petemill left a comment

Choose a reason for hiding this comment

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

This is great. Small change requested so far.

components/brave_new_tab_ui/api/initialData.ts Outdated Show resolved Hide resolved
@petemill
Copy link
Member

petemill commented May 7, 2020

Do we have a simple test plan with a sample data set that can be used to confirm the issue is fixed and the performance impact?

@cezaraugusto
Copy link
Contributor

@petemill I think this PR goal is just not to call any chrome API if users disabled the feature

@AndriusA
Copy link
Author

AndriusA commented May 7, 2020

correct, and to call search api with a different parameter (per https://developer.chrome.com/extensions/bookmarks#method-search)

Can share bookmarks used for testing

@petemill
Copy link
Member

petemill commented May 7, 2020

Sure but we still need to validate that turning the API request off fixes the issue users have encountered and we can do that with test data.

@petemill
Copy link
Member

petemill commented May 7, 2020

If you can, please squash the "code review comments" in to the PR commit so we can keep the changes together and easier to explain when looking in the future

@AndriusA AndriusA force-pushed the 9481-disabled-topsites-bookmarks branch from 25f110a to 53619ee Compare May 7, 2020 16:25
@AndriusA
Copy link
Author

AndriusA commented May 7, 2020

PTAL

@petemill
Copy link
Member

petemill commented May 7, 2020

Seems to be getting a build error, which makes sense.

@AndriusA @cezaraugusto are you not getting this error?

ERR! /home/travis/build/brave/brave-core/components/brave_new_tab_ui/api/initialData.ts
ERR! [tsl] ERROR in /home/travis/build/brave/brave-core/components/brave_new_tab_ui/api/initialData.ts(57,7)
ERR!       TS2322: Type 'Stats | undefined' is not assignable to type 'Stats'.
ERR!   Type 'undefined' is not assignable to type 'Stats'.
ERR! /home/travis/build/brave/brave-core/components/brave_new_tab_ui/api/initialData.ts
ERR! [tsl] ERROR in /home/travis/build/brave/brave-core/components/brave_new_tab_ui/api/initialData.ts(59,7)
ERR!       TS2322: Type 'MostVisitedURL[] | undefined' is not assignable to type 'MostVisitedURL[]'.
ERR!   Type 'undefined' is not assignable to type 'MostVisitedURL[]'.

@AndriusA
Copy link
Author

AndriusA commented May 7, 2020

weirdly - no, locally everything seemed fine. Possibly something didn't get picked up for incremental build.

Feel free to fix it up or throw out altogether, looks like assumptions about every source of data always being there are baked in all the way, even if user has disabled them

@petemill
Copy link
Member

petemill commented May 8, 2020

@AndriusA if this is P1 we should definitely fix, right? Might be as simple as setting the correct nullable type on 1 property in the store. Do you know the rough perf improvement on the change of { url: url }?

@AndriusA
Copy link
Author

that's made obsolete by #5490 so we may not have a major performance issue on it for now

the topSites and stats shouldn't be as heavy and while I don't think it makes sense to load that data even when not shown, it requires more time than I'm prepared to spend to keep the exact same ux of widgets appearing fully loaded on a toggle

@AndriusA AndriusA closed this May 11, 2020
@bsclifton bsclifton deleted the 9481-disabled-topsites-bookmarks branch May 11, 2020 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants