Closed Bug 1956081 Opened 1 year ago Closed 1 year ago

Fenix applink load may wait on Network Connectivity Service's initial checks, introducing additional latency on slower networks

Categories

(Core :: Networking, task, P2)

task

Tracking

()

RESOLVED FIXED
140 Branch
Tracking Status
firefox140 --- fixed

People

(Reporter: acreskey, Assigned: valentin)

References

(Blocks 4 open bugs)

Details

(Whiteboard: [necko-triaged])

Attachments

(3 files)

The exact mechanism isn't clear to me yet, but from a series of Fenix Applink Startup profiles, the network connectivity service's initial checks look to be blocking the document load.

https://share.firefox.dev/41RhIe4
https://share.firefox.dev/422Duf1
https://share.firefox.dev/4l0HhlK

In all of these cases we see the target url, https://theme-crave-demo.myshopify.com/, start to load immediately after the connectivity service's request of http://detectportal.firefox.com/success.txt?ipv6 completes (possibly DNS check).

(I believe these requests are coming from the connectivity service, network.connectivity-service.enabled because the captive portal service appears to be disabled, i.e. network.captive-portal-service.enabled:false)

Blocks: 1951764

Perhaps somewhere up the stack we are blocking on the connectivity service completing initial tests?

I've disabled the connectivity services in this PerfCompare, currently showing a 10% improvement but the test may be noisy so taking with a grain of salt
https://perf.compare/compare-results?baseRev=f6fa6f1d572aed73aaddd82dfda787331616bea5&newRev=c0d19018e3413053fe5a13f18d2e032f8725c671&baseRepo=try&newRepo=try&framework=15

In this profile I've disabled the connectivity service. Still a large delay from the first network requests (location services, wallpers) to the applink target, but that is likely separate issue.
https://share.firefox.dev/4j5pckJ

Summary: Network Connectivity Service's initial checks appear to block applink document load, introducing additional latency on slower networks → Fenix applink load appears to wait on Network Connectivity Service's initial checks, introducing additional latency on slower networks

This may be on purpose, since a pageload if we're in a captive portal situation will get hijacked.
If it isn't, this could be a win

Severity: -- → S3
Priority: -- → P2
Whiteboard: [necko-triaged][necko-priority-new]

The CI runs on the shopify test did not pickup any improvements and I've also since learned that those tests are not stable enough to draw conclusions from.

From a local test, disabling network.connectivity-service.enabled did not yield any improvements.
It looks like load is waiting for the browser to be created, mozilla::dom::ContentParent::CreateBrowser.
See also, bug to create applink host speculative connection, bug 1956356.

Whiteboard: [necko-triaged][necko-priority-new] → [necko-triaged]
Summary: Fenix applink load appears to wait on Network Connectivity Service's initial checks, introducing additional latency on slower networks → Fenix applink load may wait on Network Connectivity Service's initial checks, introducing additional latency on slower networks

Looking at the profile from comment 1 I did notice that we do two connectivity checks, one in response to the a connectivity change, then one in response to the idle-startup-finished link
I think the good fix here would be to just avoid doing any checks before idle-startup-finished.

Assignee: nobody → valentin.gosu
Pushed by valentin.gosu@gmail.com: https://hg.mozilla.org/integration/autoland/rev/5106137ef312 Don't perform any connectivity checks before idle-startup-finished r=necko-reviewers,kershaw
Pushed by abutkovits@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/02695117ae0e Revert "Bug 1956081 - Don't perform any connectivity checks before idle-startup-finished r=necko-reviewers,kershaw" for causing failures at test_network_connectivity_service.js.
Flags: needinfo?(valentin.gosu)
Pushed by valentin.gosu@gmail.com: https://hg.mozilla.org/integration/autoland/rev/bc91e5d29183 Don't perform any connectivity checks before idle-startup-finished r=necko-reviewers,kershaw
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 140 Branch
Blocks: 1966774

Even though it has already landed, I compared this patch on the newssite-applink-startup applink_startup (without profiling runs) by disabling the option.

Possibly it's leading to improvements of up to ~2.6% on the test. But I'm adding more retriggers to gain confidence.

https://perf.compare/compare-results?baseRev=5b9c61473c0118627f35a04ec63424f130a3e249&newRev=77ac96ad1ce81db0107b8ab6082b147499eeb01b&baseRepo=try&newRepo=try&framework=15

I'll try to run it live in a large batch.
If we have evidence that removing the additional requests is measurably beneficial, that could help in deferring all of the other launch request loads.

Attached file valentin_fix.txt

Dataset with applink_startup results from Valentin's fix.

Dataset with applink_startup results where Valentin's fix was reverted via pref

I compared this fix on a long run of the shopify applink test (250 iterations instead of 5).
It didn't pickup any measurable improvements, but this test is relatively noisy, even locally, standard deviation of 140ms.

We may need to disable all of the requests that preceed the applink URL to measure the impact in a local test.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: