Closed Bug 1540997 Opened 7 years ago Closed 7 years ago

Reddit Enhancement Suite 5.14.5 is ten times slower loading batched options with ExtensionStorageIDB.enabled

Categories

(WebExtensions :: Developer Outreach, defect, P3)

66 Branch
defect

Tracking

(firefox-esr60 unaffected, firefox66 wontfix, firefox67 wontfix, firefox68 wontfix)

RESOLVED FIXED
Tracking Status
firefox-esr60 --- unaffected
firefox66 --- wontfix
firefox67 --- wontfix
firefox68 --- wontfix

People

(Reporter: ke5trel, Unassigned)

References

()

Details

(Keywords: regression)

Attachments

(2 files, 1 obsolete file)

Attached image Performance comparison (obsolete) —

STR:

  1. Install Reddit Enhancement Suite extension.
  2. Go to https://old.reddit.com/r/all
  3. Refresh page and take note of how long it takes for the icons under each post to change from a play arrow to a camera.
  4. Do the same thing with extensions.webextensions.ExtensionStorageIDB.enabled = false.

With ExtensionStorageIDB enabled there is a 500ms delay before the extension style is applied which can be measured in screen captures and performance recordings.

(In reply to Kestrel from comment #0)

Created attachment 9055082 [details]
Performance comparison

STR:

  1. Install Reddit Enhancement Suite extension.
  2. Go to https://old.reddit.com/r/all
  3. Refresh page and take note of how long it takes for the icons under each post to change from a play arrow to a camera.
  4. Do the same thing with extensions.webextensions.ExtensionStorageIDB.enabled = false.

With ExtensionStorageIDB enabled there is a 500ms delay before the extension style is applied which can be measured in screen captures and performance recordings.

Can you tell us some specs about your machine and whatever else might be affecting performance (other extensions, running programs, etc)? I'd like to get QA to reproduce this, but want to baseline performance considerations.

Flags: needinfo?(ke5trel)

(This bug will be closed in next week's triage if there is still no response.)

Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INACTIVE

The delay is best measured between the extension's loadOptions and beforeLoad which occur sequentially (filter Javascript call tree for "storage"). Measured with performance capture, the time to load options for the old storage method was 80ms and with the new method it is 900ms.

foreground.entry.js:38860

const beforeLoad = loadOptions.then(() => _runModuleStage('beforeLoad'));
Attachment #9055082 - Attachment is obsolete: true
Flags: needinfo?(ke5trel)
Status: RESOLVED → REOPENED
Resolution: INACTIVE → ---
Summary: Reddit Enhancement Suite 500ms regression applying styles with ExtensionStorageIDB.enabled → Reddit Enhancement Suite 10 times slower applying styles with ExtensionStorageIDB.enabled

The priority flag is not set for this bug.
:ddurst, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(ddurst)
Flags: needinfo?(ddurst)

Can we get a link to that profile? That's more helpful than the picture.

Flags: needinfo?(ke5trel)
Flags: needinfo?(ke5trel)
Component: Storage → Developer Outreach
Flags: needinfo?(lgreco)

I took an initial look to the profiling report linked in comment 7 and gave it a try locally, but I'm wondering if there is any particular set of configurations for the RES extension that I may need to set to be able to reproduce it locally (and then properly compare it with what have been experienced by the reporter with and without the IDB backend).

In the meantime I've applied the following small change locally (to get a console.time/timeEnd log restricted to the content script code mentioned in comment 4):

diff -u reddit-enhanced-orig/foreground.entry.js reddit-enhanced/foreground.entry.js
--- reddit-enhanced-orig/foreground.entry.js    1979-12-31 00:00:00.000000000 +0100
+++ reddit-enhanced/foreground.entry.js 2019-05-20 18:53:25.289735895 +0200
@@ -37978,7 +37978,14 @@
 const onInit = loadI18n.then(() => _runModuleStage('onInit', {
   skipEnabledCheck: true
 }));
-const init_loadOptions = onInit.then(() => Promise.all([_loadModuleOptions(), _loadModulePrefs()]));
+const init_loadOptions = onInit.then(() => {
+  console.time("TIMER init_loadOptions");
+  let res = Promise.all([_loadModuleOptions(), _loadModulePrefs()]);
+  res.then(() => {
+    console.timeEnd("TIMER init_loadOptions");
+  });
+  return res;
+});
 const addModuleBodyClasses = init_loadOptions.then(() => _addModuleBodyClasses());
 const init_always = init_loadOptions.then(() => _runModuleStage('always', {
   skipEnabledCheck: true
@@ -38007,4 +38014,4 @@
 establish(init_contentStart);

and then I loaded https://old.reddit.com/r/all in a tab with the modified extension installed and the extensions.webextensions.ExtensionStorageIDB.enabled pref set to both true and false, but the time logged by the call to console.timeEnd wasn't actually that different:

  • extensions.webextensions.ExtensionStorageIDB.enabled = false: 134ms for the first page load and ~70-80ms for the other loads.
  • extensions.webextensions.ExtensionStorageIDB.enabled = true: 86ms for the first page load and ~70-80ms for the other loads.

and so it seems that, to be able to reproduce the visible lag as the reporter experienced, we may have to ensure that the scenario we are testing is actually similar enough to the one from the reporter, e.g.

  • extensions configuration that we may have to set
  • specs of the machine were the issue have been noticed (as David mentioned in comment 2)

It may be also helpful to collect a profile with ExtensionStorageIDB.enabled set to false to see if we may notice differences between the profiles collected that may point us to the right direction.

Flags: needinfo?(lgreco) → needinfo?(ke5trel)
Priority: -- → P3

Testing was done with a clean profile and default RES settings with 6x3Ghz cores.

I can confirm the latest version of RES now works the same with IDB backend enabled (time measured using supplied patch). I went back to RES 5.14.5 and was able to reproduce the problem, updating to RES 5.16.1 fixed it.

Most likely fix commit:

init: Don't batch loading of options

Loading multiple items together can be so slow that RES doesn't initalize (adding option body classes, custom styles etc) before Firefox decides to paint the first frame, causing a FOUC.

https://github.com/honestbleeps/Reddit-Enhancement-Suite/commit/2f82da4157174ed208018053d064e71fc503dd65

Flags: needinfo?(ke5trel)
Summary: Reddit Enhancement Suite 10 times slower applying styles with ExtensionStorageIDB.enabled → Reddit Enhancement Suite 5.14.5 is ten times slower loading batched options with ExtensionStorageIDB.enabled
Status: REOPENED → RESOLVED
Closed: 7 years ago → 7 years ago
Resolution: --- → FIXED
Version: Firefox 66 → 66 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: