Closed Bug 1803365 Opened 2 years ago Closed 2 years ago

[DNR] Consider adding a startupCache file for the DNR store rules

Categories

(WebExtensions :: Request Handling, task, P2)

task

Tracking

(firefox113 fixed)

RESOLVED FIXED
113 Branch
Tracking Status
firefox113 --- fixed

People

(Reporter: rpl, Assigned: rpl)

References

(Blocks 3 open bugs)

Details

(Whiteboard: [addons-jira])

Attachments

(1 file, 2 obsolete files)

As a followup to Bug 1745763 we are going to consider introducing a startupCache file for the DNR rules store, as some additional context:

  • for the static rules, the extension can enable and disable an entire static ruleset (and not single rules as for dynamic or session rules), and so the DNR store will only be tracking the list of static ruleset ids that are currently enabled, while the actual rules associated to each static ruleset is already in a static json file packaged with the extension
  • on the next browser startup, DNR internals will load the DNR store data and to convert the list of ruleset ids into the sets of actual rules, all the static rulesets json files packaged with the extension will have to be loaded again and also validate and normalize each of the rules being loaded

And so, to minimize the amount of work needed to initialize the DNR store and be ready to process intercepted network requests near after the browser startup, we are considering to store into a startupCache file the last status of the DNR store, included all the enbled rules already normalized and validated.

This draft patch adds a per-extension startupCache file for the DNR data store,
I decided to split it out from the other patch because we may consider a
different strategy (e.g. one startup cache file for all extensions) and to
move this part in its own followup bugzilla issue.

Blocks: 1782685
Type: defect → task
Severity: -- → N/A
Priority: -- → P2
Blocks: 1821676
Assignee: nobody → lgreco
Status: NEW → ASSIGNED
Attachment #9306035 - Attachment description: WIP: Bug 1803365 - prototype DNR rules store per-extension startupCache file. → Bug 1803365 - Add startupCache file to ExtensionDNRStore. r?robwu!

DNRStore's #getManifestStaticRulesets method is currently using extension.readJSON to load the JSON files
for the DNR static rulesets enabled, but internally extension.readJSON calls String.prototype.replace with
a regular expression to remove inline comments from the JSON files data retrieved and that have a noticebeable
impact due to the size that the DNR rulesets size may likely have (especially compared to the usual size of
manifest.json and locale files may have).

Given that Chrome doesn't support inline comments in DNR rulesets, we can consider replacing the call to
extension.readJSON with fetch, which wouldn't allow inline comments in the rulesets JSON files but
it would have a smaller impact due to not going through a call to String.prototype.replace and through
the js RegExp evaluations.

Alternatively we may consider keeping the call to extension.readJSON but tweak it to make sure we opt
out from the call to String.prototype.replace for this particular call (by also tweaking readJSON
method to allow that).

Depends on D162402

Depends on: 1823390

Comment on attachment 9323100 [details]
Bug 1803365 - Replace extension.readJSON with fetch to reduce perf impact of loading the DNR ruleset. r?robwu!

Revision D172604 was moved to bug 1823390. Setting attachment 9323100 [details] to obsolete.

Attachment #9323100 - Attachment is obsolete: true

Comment on attachment 9323099 [details]
Bug 1803365 - Fix typo in assertion message in head_dnr.js. r?robwu!

Revision D172603 was moved to bug 1823390. Setting attachment 9323099 [details] to obsolete.

Attachment #9323099 - Attachment is obsolete: true
Blocks: 1825510
Pushed by luca.greco@alcacoop.it: https://hg.mozilla.org/integration/autoland/rev/68dacf19e09d Add startupCache file to ExtensionDNRStore. r=robwu
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 113 Branch
See Also: → 1825953
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: