wooque / site-bleacher

Remove automatically cookies, local storages, IndexedDBs, service workers, cache storages, filesystems and webSQLs
43 stars 2 forks source link

High resource (CPU) utilisation #10

Open koobs opened 4 years ago

koobs commented 4 years ago

I'm observing site bleacher CPU, utilisation issues in the following environment:

This was a fresh (first-time) installation of the addon.

Symptoms start when either closing an existing tab, or opening a new one (edit: also when switching tabsand the utilisation seems to scale with the number of operations begin a short time after activating the addon, up to "~200" in the energy impact details of about:performance

2019-09-23 15_49_16-Window

Processor explorer shows the following in what I believe is the 'main' firefox.exe process (other/content processes are shown within the [+] tree of the main one.

2019-09-23 16_33_16-Window

"Cycles Delta" before or after high CPU utilisation is 7,000,000 to 100,000,000 (millions) with firefox idle, compared to 3,500,000,000 (billions) when the issue is observable

Two snapshots of the stack for the above thread during high utilisation:

2019-09-23 16_33_31-Window

2019-09-23 16_33_45-Window

After disabling or removing the addon, CPU utilisation returns to normal immediately (not after a delay).

A snapshot of the stack for the above thread after high utilisation (addon disabled)

2019-09-23 16_37_27-Window

koobs commented 4 years ago

On a theory it might be an interaction with another addon, disabling all addons except site bleacher, the issue is still reproducible.

Also, the original report that high utilisation is not seen until some tab interaction takes place doesn't seem to be the case, just enabling the addon and waiting is enough to trigger it.

Also, during high utilisation, looking at the thread stack call delta, and resource monitor, high IO utilisation is seen (along with CPU utilisation). I haven't been able to definitively isolate it, but it looks like additional/excessive IO relating to places.sqlite and webappsstore.sqlite is taking place.

It might be worth producing a version of the addon with the ability to Enable/Disable cleaning for certain storage areas on an individual basis (☒ cookies, ☒ local storage, ☒ IndexedDB and ☒ service workers) to isolate which cleaning component(s) are affected.

wooque commented 4 years ago

Thanks for detailed report, I don't have currently time to look into the issue, but will as soon as I have some free time.

wooque commented 4 years ago

@koobs Couldn't reproduce the issue, thou I don't use Windows, so I tested it on Linux. Energy impact is usually <1 and at most 2. It can potentially happen when you freshly install Site Bleacher and you have really big history, but it should stabilize after some time.

theltalpha commented 4 years ago

Hallo!

I can confirm exactly the same problem with a freshly installed Site-Bleacher extension. @wooque What exactly do you mean by "really big history"? Which history do you mean? Is there anything I can delete in order to make the history smaller? Or is there a way to expedite stabilising? Currently it's impossible to use your extension.

koobs commented 4 years ago

@theltalpha The WebExtension API for history removal appears only to support single URL's (history.deleteUrl) and all URL's. (history.deleteAll) which means Extensions need to loop over individual URL's one by one in order to provide a "delete history for <hostname|domain>" function, which I imagine all current history cleaning extensions currently do.

More poignantly, there is no API to delete all history items on a per-host|domain basis like history.deleteByDomain() or history.deleteAll(domain=)

All of this not surprisingly means deleting lots of history entries is slow, and is likely the underlying cause of this behaviour, though it may be compounded by non-optimal routines within the WebExtension)

You can also see this in action even outside of the WebExtension context, affecting Firefox itself, by opening the history window, selecting lots of entries and pressing delete. Firefox will lock up or become very unresponsive while it iterates through deleting items individually. Looking at Firefox's processes, you'll see a single process utilising a non-trivial (but not entirely saturating) amount of CPU.

See Also: Firefox Bug 734643: Extremely slow deleting from history

Users could make their histories smaller in advance of extensions needing to prune lots of entries, by either:

The root resolution to this is for Firefox to make available a new WebExtensions History API method, or add an optional domain argument to an existing method, to enable deleting history items by domain.

theltalpha commented 4 years ago

Hallo!

Thank you for your quick and detailed explanation. I must admit it is even too detailed for me. What I did now is letting Site Bleacher work a some hours until the high CPU usage stopped. When I use Site Bleacher now, the CPU usage is not nearly as high as before, but there is still a remarkable latency.

Do I presume it correctly, if I don't clean out all history, there will always be this latency? I would like to avoid loosing my history of visited websites.

wooque commented 4 years ago

I'll take a closer look over the weekend

theltalpha commented 4 years ago

Hallo!

Thank you! If you need any further information please do not hesitate to ask.

What I noticed: Above I mentioned that I let Site Bleacher just work several hours until it finished (by the way, what does it do in these hours?). When it is finished, Firefox behaves normal, i.e. without latency, even when opening new tabs and closing tabs. But as soon as I close Firefox and re-open it, the latency is here again. Something must happen on complete closure of Firefox and/or on opening it.

What I do not understand though is how the Firefox history is involved here. When we talk about history we mean the file places.sqlite, right? Because in Site Bleacher's own description I do not see that it affects the history of visited websites, respectively the mentioned file.

Maybe for my intended use case Site Bleacher is just not the right tool? I want to retain the history (i.e. a list) of all visited website. I want to have deleted everything else a website stores/stored on my computer, except from those sites which I have whitelisted.

theltalpha commented 4 years ago

It might be worth producing a version of the addon with the ability to Enable/Disable cleaning for certain storage areas on an individual basis (☒ cookies, ☒ local storage, ☒ IndexedDB and ☒ service workers) to isolate which cleaning component(s) are affected.

Hi!

I want to pick this issue up again. May @koobs proposal be a good way to individually overcome the problem?