Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HUGE amount of writes by storage.js.temp. Possible LZ4 archivation or less frequent rewrite? #892

Closed
AjvarXX opened this issue Nov 12, 2017 · 24 comments
Assignees
Labels
Milestone

Comments

@AjvarXX
Copy link

AjvarXX commented Nov 12, 2017

Steps to reproduce

  1. Freshly launched Firefox 56 with 20 startup tabs but only few actually been loaded at least once.
  2. 4 hours of launched Firefox where light browsing took 2 hours (4 active tabs max), 2 hours of inactivity.
  3. ...
  4. PROFIT!

Expected behavior

For such a light session of 4 hours Adguard shouldn't have written whopping 461MB

Actual behavior

Looks like Adguard extension rewrites non-archieved storage.js.tmp file over and over again. This alone would provide up to 4GB of writes per day on SSD.

Screenshot:

<adguard firefox usage>
I noticed that Firefox had same problem with sessionrestore (sessionrestore.js, recovery.js) and now they "bandaged over" it with including LZ4 archieving which cuts up from 30% to 90% depending on what's inside. Also you can reduce frequency from default 15 seconds of backing up session.
https://bugzilla.mozilla.org/show_bug.cgi?id=1304389
https://bugzilla.mozilla.org/show_bug.cgi?id=934967

Screenshot of the browser console:

Your environment

  • Adguard AdBlocker extension version: 2.7.3
  • Environment name and version: Firefox 64bit v.56.0.2
  • Filters you use in Adguard: English, Counter and Analitics, widgets from social networks, Russian, Japaneese. Adguard shows number of blocked adverts.
  • Any other browser extensions you have installed:
Addons:

<addon list>

@wdbw
Copy link

wdbw commented Nov 13, 2017

I cannot provide any data, but I can confirm that the timestamp of storage.js is updated very often (-> disk writes).

It's probably related to updating the block counter whenever something has been blocked.

@vbagirov vbagirov added this to the 2.8 milestone Nov 16, 2017
@ameshkov
Copy link
Member

This is actually an important issue caused by the way FF implemented browser.storage API.

We will fix it asap.

@AjvarXX
Copy link
Author

AjvarXX commented Nov 18, 2017

Oh, I am glad I helped. And thank you guys for working on it.

@wdbw
Copy link

wdbw commented Dec 23, 2017

Any news? The issue was fixed long ago, but even a month later there is no new point release available.

@zebrum
Copy link
Member

zebrum commented Dec 25, 2017

@wdbw
Copy link

wdbw commented Apr 5, 2018

@AjvarXX Can you confirm whether this issue is fixed or not?

While using the program FileActivityWatch I saw that several MB were written to the .js.tmp file after opening a website (on YouTube I even got multiple writes).

Adguard extension 2.8.6 and Firefox 64bit v.60b9

@AjvarXX
Copy link
Author

AjvarXX commented Apr 5, 2018

Absolutely positive that it is fixed for me.
Latest Waterfox (fork of Firefox) and latest Adguard 2.8.6

@wdbw
Copy link

wdbw commented Apr 5, 2018

What do you see instead? When do writes occur? For me the storage file (~5MB) is rewritten on every page load, and that can add up quickly.

I would like to test with blocking statistics disabled, but there is no option for that.

@wdbw
Copy link

wdbw commented Apr 7, 2018

I have disabled the storage of the total block count, and that eliminates the writes.

https://github.com/AdguardTeam/AdguardBrowserExtension/blob/master/Extension/lib/utils/page-stats.js#L85

Why is this call not done on shutdown only?

@wdbw
Copy link

wdbw commented Apr 9, 2018

After upgrading to version 2.9.2 I took a closer look at the read/writes. Playing a three and a half minute YouTube video resulted in ~150MB of data written to the storage file.

@ameshkov Any idea why this issue is not fixed for me? I doubt that this is the intended behavior.

@ameshkov
Copy link
Member

Why is this call not done on shutdown only?

That wouldn't be reliable.

Look at the save method, it can't be called more often than once in a second:
https://github.com/AdguardTeam/AdguardBrowserExtension/blob/master/Extension/lib/utils/page-stats.js#L49

Also, it seems that the fix of this issue is under review right now:
https://bugzilla.mozilla.org/show_bug.cgi?id=1406181

For me the storage file (~5MB) is rewritten on every page load, and that can add up quickly.

Why is it THAT HUGE in your case? It should be a couple of kilobytes max.

Please try reinstalling AdGuard from scratch, maybe the old data is still there.

@wdbw
Copy link

wdbw commented Apr 15, 2018

Look at the save method, it can't be called more often than once in a second:
https://github.com/AdguardTeam/AdguardBrowserExtension/blob/master/Extension/lib/utils/page-stats.js#L49

It was called on YouTube while playing a video every ~7 seconds.

Why is it THAT HUGE in your case? It should be a couple of kilobytes max.

A fresh storage.js has this size: 3,60 MB (3.784.484 bytes)

My file size is slightly bigger due to having more filter lists enabled.

@ameshkov
Copy link
Member

ameshkov commented Apr 15, 2018

A fresh storage.js has this size: 3,60 MB (3.784.484 bytes)

In my case, it is 1.5 KB. What's inside?

For instance, here's what inside of mine:

$ cat storage.js
{"adguard-settings":{"app-version":"2.9.2","filters-state":"{\"1\":{\"loaded\":true,\"enabled\":true,\"installed\":true},\"2\":{\"loaded\":true,\"enabled\":true,\"installed\":true},\"3\":{\"loaded\":true,\"enabled\":true,\"installed\":true},\"4\":{\"loaded\":true,\"enabled\":true,\"installed\":true},\"10\":{\"loaded\":true,\"enabled\":true,\"installed\":true},\"216\":{\"loaded\":true,\"enabled\":false,\"installed\":true},\"238\":{\"loaded\":true,\"enabled\":false,\"installed\":true}}","filters-version":"{\"1\":{\"version\":\"2.0.2.18\",\"lastCheckTime\":1523727859962,\"lastUpdateTime\":1523718332000},\"2\":{\"version\":\"2.0.4.93\",\"lastCheckTime\":1523727860178,\"lastUpdateTime\":1523718355000},\"3\":{\"version\":\"2.0.1.23\",\"lastCheckTime\":1523727860794,\"lastUpdateTime\":1523718357000},\"4\":{\"version\":\"2.0.1.85\",\"lastCheckTime\":1523727859898,\"lastUpdateTime\":1523718358000},\"10\":{\"version\":\"2.0.0.23\",\"lastCheckTime\":1522664178690,\"lastUpdateTime\":1520616612000},\"216\":{\"version\":\"2.0.1.83\",\"lastCheckTime\":1523727859906,\"lastUpdateTime\":1523610376000},\"238\":{\"version\":\"2.0.0.22\",\"lastCheckTime\":1522664178524,\"lastUpdateTime\":1522530158000}}","client-id":"z32lgs8c64441426","safebrowsing-disabled":false,"sb-cache":"{}","page-statistic":"{\"totalBlocked\":2}","show-info-about-adguard-disabled":true,"white-list-domains":"[]","block-list-domains":"[]","detect-filters-disabled":true}}

@wdbw
Copy link

wdbw commented Apr 15, 2018

What's inside?

Mine contains the filter list entries also, and that makes the file that big.

{"adguard-settings":{"app-version":"2.9.2","filters-state":"{\"2\":{\"loaded\":true,\"enabled\":true,\"installed\":true},\"10\":{\"loaded\":true,\"enabled\":true,\"installed\":true}}","filters-version":"{\"2\":{\"version\":\"2.0.4.14\",\"lastCheckTime\":1523826032801,\"lastUpdateTime\":1522767910000},\"10\":{\"version\":\"2.0.0.23\",\"lastCheckTime\":1523826032816,\"lastUpdateTime\":1520616612000}}","client-id":"MBHGgXhu26036774"},"filterrules_2.txt":["! Checksum: 0gJbfZH+VzNbIKdoLKtWiA","! Title: English Filter","! Description: ... <snip>

@ameshkov
Copy link
Member

Mine contains the filter list entries also, and that makes the file that big.

Hm, I don't understand why is it happening. Filters must be stored elsewhere in v2.9, that was the change that fixed this issue.

What exact AdGuard distr do you use? AMO or smth else?

@wdbw
Copy link

wdbw commented Apr 15, 2018

I do have the AMO version installed.

Browser console output (enabling the extension with no storage.js present):

1523832642367	addons.webextension.adguardadblocker@adguard.com	WARN	Please specify whether you want browser_style or not in your browser_action options.
XML Parsing Error: unclosed token
Location: moz-extension://7ed592f8-9840-4c32-9978-6ae3ea15ffb4/background.html
Line Number 1, Column 1:  background.html:1:1
2018-04-15T22:50:42.567Z: Adguard rulesStorage error: InvalidStateError: A mutation operation was attempted on a database that did not allow mutations.
Stack trace:
  log.js:71:9
	print moz-extension://7ed592f8-9840-4c32-9978-6ae3ea15ffb4/lib/utils/log.js:71:9
	error moz-extension://7ed592f8-9840-4c32-9978-6ae3ea15ffb4/lib/utils/log.js:91:13
	onError moz-extension://7ed592f8-9840-4c32-9978-6ae3ea15ffb4/lib/utils/rules-storage-indexeddb.js:36:9
	init/request.onblocked moz-extension://7ed592f8-9840-4c32-9978-6ae3ea15ffb4/lib/utils/rules-storage-indexeddb.js:150:13
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.  background.html
2018-04-15T22:50:42.580Z: Starting adguard... Version: 2.9.2. Id: adguardadblocker@adguard.com  log.js:71:9
2018-04-15T22:50:42.589Z: Filters metadata loaded  log.js:71:9
2018-04-15T22:50:42.600Z: Filters i18n metadata loaded  log.js:71:9
2018-04-15T22:50:42.669Z: Retrieved response from server for filter 2, rules count: 84878  log.js:71:9
2018-04-15T22:50:42.683Z: Retrieved response from server for filter 10, rules count: 164  log.js:71:9
NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIWebNavigation.loadURIWithOptions] browser-child.js:359
2018-04-15T22:50:43.843Z: Starting loading filter rules from the storage  log.js:71:9
2018-04-15T22:50:44.501Z: Finished loading filter rules from the storage in 658 ms  log.js:71:9
2018-04-15T22:50:44.502Z: Starting request filter initialization. Async=false  log.js:71:9
2018-04-15T22:50:44.864Z: Cannot create rule from filter 2: @@||hdslb.com^$domain=bilibili.com,stealth, cause Unknown option: STEALTH  log.js:71:9
2018-04-15T22:50:44.865Z: Cannot create rule from filter 2: @@||iatv.tmgrup.com.tr^$script,stealth, cause Unknown option: STEALTH  log.js:71:9
2018-04-15T22:50:44.865Z: Cannot create rule from filter 2: @@||i.tmgrup.com.tr^$script,stealth, cause Unknown option: STEALTH  log.js:71:9
2018-04-15T22:50:45.229Z: Cannot create rule from filter 2: |http://$image,ping,script,stylesheet,subdocument,third-party,xmlhttprequest,domain=watchers.to, cause Unknown option: PING  log.js:71:9
2018-04-15T22:50:45.230Z: Cannot create rule from filter 2: |https://$image,ping,script,stylesheet,subdocument,third-party,xmlhttprequest,domain=watchers.to, cause Unknown option: PING  log.js:71:9
2018-04-15T22:50:45.404Z: Finished request filter initialization in 903 ms. Rules count: 80986

@ameshkov
Copy link
Member

ameshkov commented Apr 16, 2018

  1. Is user filter empty?
  2. What exact version of FF do you use?

The culprit is this error:
InvalidStateError: A mutation operation was attempted on a database that did not allow mutations.

It makes AG use the browser storage instead of the indexedDB

@atropnikov
Copy link
Member

@wdbw Could you also check dom.indexedDB.enabled flag on the about:config page?

@wdbw
Copy link

wdbw commented Apr 16, 2018

60.0b12 (64-bit) + dom.indexedDB.enabled=true

I have found the cause for this problem. According to the following bug report, the usage of indexedDB is disabled in private browsing mode:

https://bugzilla.mozilla.org/show_bug.cgi?id=781982

@ameshkov
Copy link
Member

Not sure about this. It could've been true if we had used "incognito": "split": https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/incognito

Anyway, we'll check it and get back to you soon.

@ameshkov
Copy link
Member

ameshkov commented May 4, 2018

Uh, sorry for the late reply. I've filed a new issue about this particular incognito problem: #1006

@maximtop
Copy link
Contributor

maximtop commented May 8, 2018

@wdbw Could you export your firefox profile, please? I can't reproduce this issue with my configuration.

@maximtop maximtop reopened this May 8, 2018
@wdbw
Copy link

wdbw commented May 10, 2018

I can reproduce the problem with the following steps:

  1. Create a new Firefox profile
  2. Open the settings page and under "Privacy & Security" switch to "Never remember history"
  3. Install the extension from AMO

@maximtop
Copy link
Contributor

resolved in pull request browser-extension/pull-requests/135

adguard pushed a commit that referenced this issue Jun 9, 2021
…ing events

Merge in EXTENSIONS/browser-extension from feature/AG-8370 to feature/AG-2737

Squashed commit of the following:

commit 347b552
Merge: 3acf245 3acdedf
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Wed Jun 9 11:43:14 2021 +0300

    Merge remote-tracking branch 'origin/feature/AG-2737' into feature/AG-8370

commit 3acf245
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Tue Jun 8 10:02:59 2021 +0300

    add localized status column title

commit 9f8eb66
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 17:40:31 2021 +0300

    fix status css

commit a75f363
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 16:14:24 2021 +0300

    temporary disable auto update

commit 7770785
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 16:07:25 2021 +0300

    delete unused element in filter events

commit 898e375
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 14:11:39 2021 +0300

    remove commented import

commit b4fd685
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 14:06:08 2021 +0300

    update eslint config

commit 47200cf
Merge: 1552036 bdd98dd
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 13:35:46 2021 +0300

    resolve conflicts

commit 1552036
Merge: 5b91e11 e06c20b
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 13:20:01 2021 +0300

    Merge remote-tracking branch 'origin/feature/AG-8229' into feature/AG-8370

commit e06c20b
Author: anton <a.kaprielov@adguard.com>
Date:   Mon Jun 7 13:08:33 2021 +0300

    feature/AG-8229 fix styles

commit 5b91e11
Merge: 6819b29 46e754f
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 13:04:05 2021 +0300

    Merge remote-tracking branch 'origin/feature/AG-8229' into feature/AG-8370

commit 6819b29
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 12:49:49 2021 +0300

    remove log event updated

commit 2f3473d
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 12:45:16 2021 +0300

    rename responseStatusCode to statusCode

commit c5d8359
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 12:39:24 2021 +0300

    fix formatting, split Status components in separated files

commit 46e754f
Merge: 81de786 f43de63
Author: Maxim Topciu <maximtop@gmail.com>
Date:   Mon Jun 7 12:15:41 2021 +0300

    Merge branch 'feature/AG-2737' into feature/AG-8229

commit ca073b7
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 11:56:04 2021 +0300

    add localized titles in filter log statuses

commit 4aa757f
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 11:35:15 2021 +0300

    update request context storage tests

commit 482dd5b
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 11:09:45 2021 +0300

    fix formatting

commit ae53866
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Mon Jun 7 11:04:15 2021 +0300

    update request info filter status

commit 75a64b4
Author: Vladimir Zhelvis <v.zhelvis@adguard.com>
Date:   Fri Jun 4 23:31:56 2021 +0300

    feature/AG-8370 add conditional rendering in Status comonent, update Status component css

... and 37 more commits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants