Closed Bug 1544578 Opened 6 years ago Closed 6 years ago

Avoid unnecessary TopStoriesFeed work when Discovery Stream is enabled

Categories

(Firefox :: New Tab Page, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
Firefox 68
Iteration:
69.1 - May 13 - 26
Tracking Status
firefox68 --- fixed

People

(Reporter: Mardak, Assigned: pdahiya)

References

Details

(Keywords: github-merged)

Attachments

(1 file)

I noticed that TopStoriesFeed does some work during startup even though the page is showing discovery stream:

  • register with SectionsManager
  • read/write with PersistentCache (might be addressed with bug 1544052)
  • network requests for endpoints
  • loading PersonalityProvider and other jsms
  • transforming stories

Only the first item should be necessary right now (with the implementation of bug 1533601). The others are probably unnecessarily slowing down the rest of startup.

The complicated part is probably how to correctly initialize TopStoriesFeed if it actually needs to do stuff.

I'm trying a quick hack of returning early in TopStoriesFeed and avoiding importing various modules:

https://treeherder.mozilla.org/#/jobs?repo=try&revision=45f149c8f9971e34d019e39c9a602ae94bbb16e3&selectedJob=240743708

Here's a profile without the hack from my development machine checking main process times searching for stacks:
https://profiler.firefox.com/public/3b6a35864e132811978c0eaf9360aa494a0b464a/calltree/?profileName=&published&search=activity-stream&v=3

activity-stream: 847ms
PersonalityProvider: 565ms
TopStoriesFeed: 58ms

And a profile with the hack:
https://profiler.firefox.com/public/93417068c5c035ddb1ee218f8c007c8957f49cea/calltree/?profileName=&published&search=activity-stream&v=3

activity-stream: 86ms
PersonalityProvider: 0ms
TopStoriesFeed: 2ms

So a big chunk is related to PersonalityProvider with 306ms getting the attachment, 193ms writing topstories with PersistentCache, and 152ms maybeDownloadAttachment which seems to calculate hash from file contents.

All the work in the PersonalityProvider is for Pocket personalization V2. Does (or will) DiscoveryStream need that for now? If not, I think we can disable it to avoid the overhead.

Loop in Jonathan.

Scott - is the LOE vs. ROI?

Flags: needinfo?(sdowne)

Let's not do this this week, but it can be significant enough to be worth the work in certain situations.

I tested two profiles with DS turned on, 1 with ed's patch, 1 without (control). Non of the tests had DS cache, and I did two sets of tests on the control profile, one with AS cache, and one without.

The examples I have are potentially the best case and the worst case. This is because I tested with a bad machine using a good network, cache loads lose out to network requests.

For the case of fast internet and slow machine and using existing AS cache, we get a 31% increase. This is because DS is only using the network and AS is loading from disk. While this isn't really fair, it is a possible situation, which would likely be our biggest gain.

I also did a test where AS didn't have cache, and it used just the network, and I saw no gains. This is our worst case.

I think because our worst case isn't a regression and best case shows improvements, it's probably worth it in the future, but probably not our best bet for right now.

Flags: needinfo?(sdowne)
Assignee: nobody → sdowne
Priority: -- → P1
Iteration: --- → 68.4 - Apr 29 - May 12
Assignee: sdowne → pdahiya
Iteration: 68.4 - Apr 29 - May 12 → 69.1 - May 13 - 26
Keywords: github-merged
Attached file GitHub Pull Request
Iteration: 69.1 - May 13 - 26 → 68.4 - Apr 29 - May 12
Blocks: 1551751
Type: defect → enhancement
Status: NEW → RESOLVED
Iteration: 68.4 - Apr 29 - May 12 → 69.1 - May 13 - 26
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 68
Regressions: 1559243
Component: Activity Streams: Newtab → New Tab Page
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: