Closed Bug 1772447 Opened 2 years ago Closed 2 years ago

Add quick suggest results in chunks so the main thread isn't blocked too long

Categories

(Firefox :: Address Bar, task, P1)

task
Points:
3

Tracking

()

VERIFIED FIXED
103 Branch
Tracking Status
firefox102 --- verified
firefox103 --- verified

People

(Reporter: adw, Assigned: adw)

References

Details

(Whiteboard: [snt-triaged])

Attachments

(1 file)

This is something Nan and I discussed -- we have a large number of incoming keywords, and since right now we add entries to the _resultsByKeyword map all at once, there's the possibility we might block the main thread for too long. We shouldn't let our UI responsiveness or startup smoothness depend on the number of quick suggest keywords/results.

This modifies UrlbarQuickSuggest.addResults() so it adds entries to the
_resultsByKeyword map in chunks. Each chunk uses the idle queue of the main
thread.

I chose 1,000 as the chunk size. On my machine, a chunk with 1,000 entries
usually takes less than a millisecond, sometimes 1ms. A chunk with 10,000 takes
10x the time, ~10ms. Per the recent Slack thread, the latest total number of
keywords is 134,276, so that's 135 chunks of size 1,000. Seems OK...? I'm open
to suggestions.

Pushed by dwillcoxon@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/847ac2732d90
Add quick suggest results in chunks so the main thread isn't blocked too long. r=nanj
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 103 Branch
Flags: qe-verify-
Flags: in-testsuite+

Notes for QA:

This bug changed how Suggest suggestions are registered internally, and there shouldn't be any user-visible changes, with one possible exception: It may take slightly longer to load all suggestions on app startup. So if you type a query right after startup that matches a suggestion and the suggestion does not appear, it may be because it hasn't loaded yet. If you wait a second or two and try again, eventually it should appear. We're talking a small number of seconds here, so if the suggestion does not appear soon, then that's a problem.

If necessary, you can set browser.urlbar.quicksuggest.log to true to enable logging. At startup, you should see several messages logged like this:

console.debug: QuickSuggest: "Adding 54 results"

Eventually these messages will stop, and after that all suggestions will have been loaded.

So there aren't any concrete STR for this bug. We just need to make sure sponsored and non-sponsored Firefox Suggest suggestions still appear as they usually do, for example when you type "amazon", "wikipedia", etc.

Flags: qe-verify- → qe-verify+

Comment on attachment 9279536 [details]
Bug 1772447 - Add quick suggest results in chunks so the main thread isn't blocked too long.

Beta/Release Uplift Approval Request

  • User impact if declined: This is a nice-to-have sooner rather than later. It improves startup performance related to Firefox Suggest, which is especially important since we plan to increase the number of Suggest suggestions in the near future.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: Please see comment 5
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): No user-visible changes other than an improvement in startup performance and a possible delay in loading Firefox Suggest suggestions, which is a very minor concern. Has an automated test.
  • String changes made/needed:
  • Is Android affected?: No
Attachment #9279536 - Flags: approval-mozilla-beta?
QA Whiteboard: [qa-triaged]

We have verified that the sponsored and non-sponsored Firefox Suggest suggestions are still displayed as usual. Messages like "Adding 54 results" were also observed in the Browser Console with "browser.urlbar.quicksuggest.log" set to true. Tested on Firefox Nightly 103.0a1 (Build ID: 20220605213032) using Windows 10, macOS 11.6 and Linux Mint 20.2.

Status: RESOLVED → VERIFIED
Flags: qe-verify+

Comment on attachment 9279536 [details]
Bug 1772447 - Add quick suggest results in chunks so the main thread isn't blocked too long.

Approved for 102 beta 5, thanks.

Attachment #9279536 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Flags: qe-verify+

We have verified that the sponsored and non-sponsored Firefox Suggest suggestions are still displayed as usual on Beta. Messages like "Adding 54 results" were also observed in the Browser Console with "browser.urlbar.quicksuggest.log" set to true. Tested on Firefox Beta 102.0b5 (Build ID: 20220607212916) using Windows 10, macOS 11.6.6 and Linux Mint 20.2.

Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: